ELEC2645 (2019/20) / Mbed 2 deprecated el18loc_final

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Envelope.h Source File

Envelope.h

00001 #ifndef ENVELOPE_H
00002 #define ENVELOPE_H
00003 
00004 #include "mbed.h"
00005 #include "N5110.h"
00006 #include "Gamepad.h"
00007 
00008 /** Envelope class
00009  * @author Luke Cartwright, University of Leeds
00010  * @brief converts output to env output
00011  * @date May 2020
00012 */
00013 
00014 class Envelope
00015 {
00016 public://-----------------------------------------------------------------------
00017     //Methods
00018     /**Constructor*/
00019     Envelope();
00020 
00021     /**Destructior*/
00022     ~Envelope();
00023 
00024     /**Outputs unigned value with input modulated by ADS input variables
00025     *input -32767.>32767  Output 0->65535 
00026     * @returns a Unsigned Short corresponding to Envelope Output */
00027     uint16_t env_in(int a, int d, int s, int r, int in, bool init);
00028     
00029     /** Deals with the release part of the note
00030     *(triggered when note off button pressed) 
00031     * @Returns an Unsigned short (for release part) 
00032     * @Corresponding to envelope output */
00033     uint16_t release(int s, int r, int in, bool init);
00034 
00035 
00036 private://----------------------------------------------------------------------
00037 //variables
00038     uint16_t out; //main output variable
00039     int samples; //itterator for samples counter
00040     int samples_r; //release samples itterator
00041     int at; //incramented multiplier for output
00042     //ADSR variables multiplied up when applied to volume envelope
00043     int av;
00044     int dv;
00045     int sv;
00046     int rv;
00047     //Difference per sample variables
00048     int a_vec;
00049     int d_vec;
00050     int r_vec;
00051 
00052 
00053     //Methods
00054     /** Calculates the a_vec variable for use
00055     * (used as difference per sample in attack part of note) */
00056     int a_vector_calc(int av);
00057     
00058     /** Calculates the d_vec variable for use
00059     * (used as difference per sample in decay part of note)
00060     * Positive  only value */
00061     int d_vector_calc(int dv, int sv);
00062     
00063     /** Calculates the r_vec variable for use
00064     * (used as difference per sample in release part of note) 
00065     * Positive only value */
00066     int r_vector_calc(int sv, int rv);
00067 };
00068 #endif