Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Envelope/Envelope.h@30:08cc4ec58d07, 2020-05-26 (annotated)
- Committer:
- lukeocarwright
- Date:
- Tue May 26 10:17:47 2020 +0000
- Revision:
- 30:08cc4ec58d07
- Parent:
- 21:60f01b17b0a6
Sorted Settings Menu Final Touches. More Code Tidying.
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| lukeocarwright | 18:204cd747b54a | 1 | #ifndef ENVELOPE_H |
| lukeocarwright | 18:204cd747b54a | 2 | #define ENVELOPE_H |
| lukeocarwright | 18:204cd747b54a | 3 | |
| lukeocarwright | 18:204cd747b54a | 4 | #include "mbed.h" |
| lukeocarwright | 18:204cd747b54a | 5 | #include "N5110.h" |
| lukeocarwright | 18:204cd747b54a | 6 | #include "Gamepad.h" |
| lukeocarwright | 18:204cd747b54a | 7 | |
| lukeocarwright | 18:204cd747b54a | 8 | /** Envelope class |
| lukeocarwright | 18:204cd747b54a | 9 | * @author Luke Cartwright, University of Leeds |
| lukeocarwright | 18:204cd747b54a | 10 | * @brief converts output to env output |
| lukeocarwright | 18:204cd747b54a | 11 | * @date May 2020 |
| lukeocarwright | 18:204cd747b54a | 12 | */ |
| lukeocarwright | 18:204cd747b54a | 13 | |
| lukeocarwright | 18:204cd747b54a | 14 | class Envelope |
| lukeocarwright | 18:204cd747b54a | 15 | { |
| lukeocarwright | 18:204cd747b54a | 16 | public://----------------------------------------------------------------------- |
| lukeocarwright | 18:204cd747b54a | 17 | //Methods |
| lukeocarwright | 21:60f01b17b0a6 | 18 | /**Constructor*/ |
| lukeocarwright | 18:204cd747b54a | 19 | Envelope(); |
| lukeocarwright | 18:204cd747b54a | 20 | |
| lukeocarwright | 21:60f01b17b0a6 | 21 | /**Destructior*/ |
| lukeocarwright | 18:204cd747b54a | 22 | ~Envelope(); |
| lukeocarwright | 18:204cd747b54a | 23 | |
| lukeocarwright | 21:60f01b17b0a6 | 24 | /**Outputs unigned value with input modulated by ADS input variables |
| lukeocarwright | 21:60f01b17b0a6 | 25 | *input -32767.>32767 Output 0->65535 |
| lukeocarwright | 21:60f01b17b0a6 | 26 | * @returns a Unsigned Short corresponding to Envelope Output */ |
| lukeocarwright | 18:204cd747b54a | 27 | uint16_t env_in(int a, int d, int s, int r, int in, bool init); |
| lukeocarwright | 21:60f01b17b0a6 | 28 | |
| lukeocarwright | 21:60f01b17b0a6 | 29 | /** Deals with the release part of the note |
| lukeocarwright | 21:60f01b17b0a6 | 30 | *(triggered when note off button pressed) |
| lukeocarwright | 21:60f01b17b0a6 | 31 | * @Returns an Unsigned short (for release part) |
| lukeocarwright | 21:60f01b17b0a6 | 32 | * @Corresponding to envelope output */ |
| lukeocarwright | 19:08862f49cd9e | 33 | uint16_t release(int s, int r, int in, bool init); |
| lukeocarwright | 18:204cd747b54a | 34 | |
| lukeocarwright | 18:204cd747b54a | 35 | |
| lukeocarwright | 18:204cd747b54a | 36 | private://---------------------------------------------------------------------- |
| lukeocarwright | 18:204cd747b54a | 37 | //variables |
| lukeocarwright | 21:60f01b17b0a6 | 38 | uint16_t out; //main output variable |
| lukeocarwright | 21:60f01b17b0a6 | 39 | int samples; //itterator for samples counter |
| lukeocarwright | 30:08cc4ec58d07 | 40 | int samples_r; //release samples itterator |
| lukeocarwright | 30:08cc4ec58d07 | 41 | int at; //incramented multiplier for output |
| lukeocarwright | 21:60f01b17b0a6 | 42 | //ADSR variables multiplied up when applied to volume envelope |
| lukeocarwright | 30:08cc4ec58d07 | 43 | int av; |
| lukeocarwright | 18:204cd747b54a | 44 | int dv; |
| lukeocarwright | 18:204cd747b54a | 45 | int sv; |
| lukeocarwright | 18:204cd747b54a | 46 | int rv; |
| lukeocarwright | 21:60f01b17b0a6 | 47 | //Difference per sample variables |
| lukeocarwright | 18:204cd747b54a | 48 | int a_vec; |
| lukeocarwright | 18:204cd747b54a | 49 | int d_vec; |
| lukeocarwright | 18:204cd747b54a | 50 | int r_vec; |
| lukeocarwright | 30:08cc4ec58d07 | 51 | |
| lukeocarwright | 18:204cd747b54a | 52 | |
| lukeocarwright | 30:08cc4ec58d07 | 53 | //Methods |
| lukeocarwright | 21:60f01b17b0a6 | 54 | /** Calculates the a_vec variable for use |
| lukeocarwright | 21:60f01b17b0a6 | 55 | * (used as difference per sample in attack part of note) */ |
| lukeocarwright | 18:204cd747b54a | 56 | int a_vector_calc(int av); |
| lukeocarwright | 21:60f01b17b0a6 | 57 | |
| lukeocarwright | 21:60f01b17b0a6 | 58 | /** Calculates the d_vec variable for use |
| lukeocarwright | 21:60f01b17b0a6 | 59 | * (used as difference per sample in decay part of note) |
| lukeocarwright | 21:60f01b17b0a6 | 60 | * Positive only value */ |
| lukeocarwright | 19:08862f49cd9e | 61 | int d_vector_calc(int dv, int sv); |
| lukeocarwright | 21:60f01b17b0a6 | 62 | |
| lukeocarwright | 21:60f01b17b0a6 | 63 | /** Calculates the r_vec variable for use |
| lukeocarwright | 21:60f01b17b0a6 | 64 | * (used as difference per sample in release part of note) |
| lukeocarwright | 21:60f01b17b0a6 | 65 | * Positive only value */ |
| lukeocarwright | 19:08862f49cd9e | 66 | int r_vector_calc(int sv, int rv); |
| lukeocarwright | 18:204cd747b54a | 67 | }; |
| lukeocarwright | 18:204cd747b54a | 68 | #endif |