Luke Cartwright / Mbed 2 deprecated ELEC2645_Project_el18loc_nearlythere

Dependencies:   mbed

Committer:
lukeocarwright
Date:
Sat May 23 14:40:40 2020 +0000
Revision:
21:60f01b17b0a6
Parent:
19:08862f49cd9e
Child:
30:08cc4ec58d07
Publish to check Documentation;

Who changed what in which revision?

UserRevisionLine numberNew 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 //variables
lukeocarwright 18:204cd747b54a 18
lukeocarwright 18:204cd747b54a 19 //methods
lukeocarwright 18:204cd747b54a 20 //Methods
lukeocarwright 21:60f01b17b0a6 21 /**Constructor*/
lukeocarwright 18:204cd747b54a 22 Envelope();
lukeocarwright 18:204cd747b54a 23
lukeocarwright 21:60f01b17b0a6 24 /**Destructior*/
lukeocarwright 18:204cd747b54a 25 ~Envelope();
lukeocarwright 18:204cd747b54a 26
lukeocarwright 21:60f01b17b0a6 27 /**Outputs unigned value with input modulated by ADS input variables
lukeocarwright 21:60f01b17b0a6 28 *input -32767.>32767 Output 0->65535
lukeocarwright 21:60f01b17b0a6 29 * @returns a Unsigned Short corresponding to Envelope Output */
lukeocarwright 18:204cd747b54a 30 uint16_t env_in(int a, int d, int s, int r, int in, bool init);
lukeocarwright 21:60f01b17b0a6 31
lukeocarwright 21:60f01b17b0a6 32 /** Deals with the release part of the note
lukeocarwright 21:60f01b17b0a6 33 *(triggered when note off button pressed)
lukeocarwright 21:60f01b17b0a6 34 * @Returns an Unsigned short (for release part)
lukeocarwright 21:60f01b17b0a6 35 * @Corresponding to envelope output */
lukeocarwright 19:08862f49cd9e 36 uint16_t release(int s, int r, int in, bool init);
lukeocarwright 18:204cd747b54a 37
lukeocarwright 18:204cd747b54a 38
lukeocarwright 18:204cd747b54a 39 private://----------------------------------------------------------------------
lukeocarwright 18:204cd747b54a 40 //variables
lukeocarwright 21:60f01b17b0a6 41 uint16_t out; //main output variable
lukeocarwright 21:60f01b17b0a6 42 int samples; //itterator for samples counter
lukeocarwright 18:204cd747b54a 43 //float time;
lukeocarwright 21:60f01b17b0a6 44 //ADSR variables multiplied up when applied to volume envelope
lukeocarwright 18:204cd747b54a 45 int av; //a volume
lukeocarwright 18:204cd747b54a 46 int dv;
lukeocarwright 18:204cd747b54a 47 int sv;
lukeocarwright 18:204cd747b54a 48 int rv;
lukeocarwright 21:60f01b17b0a6 49 //Difference per sample variables
lukeocarwright 18:204cd747b54a 50 int a_vec;
lukeocarwright 18:204cd747b54a 51 int d_vec;
lukeocarwright 18:204cd747b54a 52 int r_vec;
lukeocarwright 21:60f01b17b0a6 53 //incramented multiplier for output
lukeocarwright 18:204cd747b54a 54 int at;
lukeocarwright 21:60f01b17b0a6 55 int samples_r;//release samples itterator
lukeocarwright 18:204cd747b54a 56
lukeocarwright 18:204cd747b54a 57 //methods
lukeocarwright 21:60f01b17b0a6 58 /** Calculates the a_vec variable for use
lukeocarwright 21:60f01b17b0a6 59 * (used as difference per sample in attack part of note) */
lukeocarwright 18:204cd747b54a 60 int a_vector_calc(int av);
lukeocarwright 21:60f01b17b0a6 61
lukeocarwright 21:60f01b17b0a6 62 /** Calculates the d_vec variable for use
lukeocarwright 21:60f01b17b0a6 63 * (used as difference per sample in decay part of note)
lukeocarwright 21:60f01b17b0a6 64 * Positive only value */
lukeocarwright 19:08862f49cd9e 65 int d_vector_calc(int dv, int sv);
lukeocarwright 21:60f01b17b0a6 66
lukeocarwright 21:60f01b17b0a6 67 /** Calculates the r_vec variable for use
lukeocarwright 21:60f01b17b0a6 68 * (used as difference per sample in release part of note)
lukeocarwright 21:60f01b17b0a6 69 * Positive only value */
lukeocarwright 19:08862f49cd9e 70 int r_vector_calc(int sv, int rv);
lukeocarwright 18:204cd747b54a 71 };
lukeocarwright 18:204cd747b54a 72 #endif