Luke Cartwright / Mbed 2 deprecated ELEC2645_Project_el18loc_nearlythere

Dependencies:   mbed

Committer:
lukeocarwright
Date:
Mon May 25 10:46:02 2020 +0000
Revision:
28:eb0f12304a45
Parent:
26:a6033830d01c
Child:
31:cfdb014ff086
Added multiple Octaves to allow a greater frequency range.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
lukeocarwright 7:33cb5f2db1ee 1 #ifndef FRONT_H
lukeocarwright 7:33cb5f2db1ee 2 #define FRONT_H
lukeocarwright 7:33cb5f2db1ee 3
lukeocarwright 7:33cb5f2db1ee 4 #include "mbed.h"
lukeocarwright 7:33cb5f2db1ee 5 #include "N5110.h"
lukeocarwright 7:33cb5f2db1ee 6 #include "Gamepad.h"
lukeocarwright 8:f305ea78b2b1 7 #include "Menu.h"
lukeocarwright 14:9cfe0041cc4e 8 #include "Sound.h"
lukeocarwright 18:204cd747b54a 9 #include "Envelope.h"
lukeocarwright 24:c3bb1b0b2207 10 #include "Filter.h"
lukeocarwright 13:27300c533dd1 11
lukeocarwright 7:33cb5f2db1ee 12 /** Front class
lukeocarwright 7:33cb5f2db1ee 13 * @author Luke Cartwright, University of Leeds
lukeocarwright 7:33cb5f2db1ee 14 * @brief manages front pannel of Synth
lukeocarwright 7:33cb5f2db1ee 15 * @date May 2020
lukeocarwright 7:33cb5f2db1ee 16 */
lukeocarwright 8:f305ea78b2b1 17
lukeocarwright 7:33cb5f2db1ee 18 class Front
lukeocarwright 7:33cb5f2db1ee 19 {
lukeocarwright 7:33cb5f2db1ee 20 public:
lukeocarwright 7:33cb5f2db1ee 21 //variables
lukeocarwright 7:33cb5f2db1ee 22 int submenu;
lukeocarwright 8:f305ea78b2b1 23 int a;
lukeocarwright 8:f305ea78b2b1 24 int d;
lukeocarwright 8:f305ea78b2b1 25 int s;
lukeocarwright 8:f305ea78b2b1 26 int r;
lukeocarwright 13:27300c533dd1 27 int dir;
lukeocarwright 18:204cd747b54a 28 int envelope_in;
lukeocarwright 13:27300c533dd1 29 int dir_1;
lukeocarwright 14:9cfe0041cc4e 30 uint16_t out;
lukeocarwright 24:c3bb1b0b2207 31 int frequency;
lukeocarwright 14:9cfe0041cc4e 32
lukeocarwright 14:9cfe0041cc4e 33 //Methods
lukeocarwright 21:60f01b17b0a6 34 /** Constructor */
lukeocarwright 7:33cb5f2db1ee 35 Front();
lukeocarwright 7:33cb5f2db1ee 36
lukeocarwright 21:60f01b17b0a6 37 /** Destructior */
lukeocarwright 7:33cb5f2db1ee 38 ~Front();
lukeocarwright 8:f305ea78b2b1 39
lukeocarwright 21:60f01b17b0a6 40 /** Runs whole front pannel
lukeocarwright 21:60f01b17b0a6 41 * @function to process whole front pannel
lukeocarwright 21:60f01b17b0a6 42 * Deals with ADSR and sound generation bby calling other classes */
lukeocarwright 7:33cb5f2db1ee 43 void frontrun(N5110 &lcd, Gamepad &pad, int submenu);
lukeocarwright 14:9cfe0041cc4e 44
lukeocarwright 14:9cfe0041cc4e 45
lukeocarwright 7:33cb5f2db1ee 46 private:
lukeocarwright 7:33cb5f2db1ee 47 //variables
lukeocarwright 21:60f01b17b0a6 48 int menuflag; //Flag to exit front function or change menu
lukeocarwright 13:27300c533dd1 49 int used; //1->4 (A<D<S<R)
lukeocarwright 13:27300c533dd1 50 bool use; //1=use 0=!use
lukeocarwright 13:27300c533dd1 51 bool initial; //sets to run 1st time
lukeocarwright 13:27300c533dd1 52 int adsr; //incrament correct val
lukeocarwright 13:27300c533dd1 53 int ud; //up/down
lukeocarwright 18:204cd747b54a 54 bool noteon; //trigger for play tone
lukeocarwright 19:08862f49cd9e 55 int release_flag; //sets 1 for if release on
lukeocarwright 25:f230af268e8b 56 int filter_type;
lukeocarwright 28:eb0f12304a45 57 int oct;
lukeocarwright 19:08862f49cd9e 58
lukeocarwright 21:60f01b17b0a6 59 #ifdef CSV //COMMA SEPERATED VALUE
lukeocarwright 21:60f01b17b0a6 60 int itterator; //Itterator for CSV
lukeocarwright 18:204cd747b54a 61 #endif
lukeocarwright 7:33cb5f2db1ee 62
lukeocarwright 8:f305ea78b2b1 63 //methods
lukeocarwright 21:60f01b17b0a6 64 /** initial setup of front panel
lukeocarwright 21:60f01b17b0a6 65 */
lukeocarwright 25:f230af268e8b 66 void frontsetup(N5110 &lcd, Gamepad &pad, int submenu, int filter_type, bool initial);
lukeocarwright 24:c3bb1b0b2207 67
lukeocarwright 24:c3bb1b0b2207 68 /** Initialises front
lukeocarwright 24:c3bb1b0b2207 69 * @ Runs all initial front functions
lukeocarwright 24:c3bb1b0b2207 70 */
lukeocarwright 24:c3bb1b0b2207 71 void initialise(Gamepad &pad, N5110 &lcd, int submenu);
lukeocarwright 24:c3bb1b0b2207 72
lukeocarwright 21:60f01b17b0a6 73 /**prints waveforms for front disp. to LCD
lukeocarwright 21:60f01b17b0a6 74 */
lukeocarwright 8:f305ea78b2b1 75 void printwav(N5110 &lcd, int submenu);
lukeocarwright 8:f305ea78b2b1 76
lukeocarwright 21:60f01b17b0a6 77 /**prints single fader to LCD
lukeocarwright 21:60f01b17b0a6 78 */
lukeocarwright 7:33cb5f2db1ee 79 void printfader(N5110 &lcd,int x, int y);
lukeocarwright 13:27300c533dd1 80
lukeocarwright 21:60f01b17b0a6 81 /**prints all ADSR sliders to LCD
lukeocarwright 21:60f01b17b0a6 82 */
lukeocarwright 13:27300c533dd1 83 void printsliders(N5110 &lcd, int a, int d,int s,int r, int used);
lukeocarwright 14:9cfe0041cc4e 84
lukeocarwright 21:60f01b17b0a6 85 /**prints individual slider to LCD
lukeocarwright 21:60f01b17b0a6 86 */
lukeocarwright 13:27300c533dd1 87 void printslider(N5110 &lcd, int x_val, int y_val, bool use);
lukeocarwright 25:f230af268e8b 88
lukeocarwright 25:f230af268e8b 89 /**Prints Filter Graphic
lukeocarwright 25:f230af268e8b 90 * @prints correct graphic dependant on filter_type
lukeocarwright 25:f230af268e8b 91 */
lukeocarwright 25:f230af268e8b 92 void printfilter(N5110 &lcd, int filter_type);
lukeocarwright 25:f230af268e8b 93
lukeocarwright 25:f230af268e8b 94 /**Manages Parameter
lukeocarwright 25:f230af268e8b 95 * @manages joystick input
lukeocarwright 25:f230af268e8b 96 * @converts to parameter sleected + value
lukeocarwright 25:f230af268e8b 97 */
lukeocarwright 25:f230af268e8b 98 int parameter_manager(Gamepad &pad, int dir, int a, int d, int s, int r);
lukeocarwright 14:9cfe0041cc4e 99
lukeocarwright 21:60f01b17b0a6 100 /**incraments correct adsr value
lukeocarwright 21:60f01b17b0a6 101 * @outputs new ADSR value when called
lukeocarwright 21:60f01b17b0a6 102 */
lukeocarwright 13:27300c533dd1 103 int incrament_adsr(int used, int adsr, int ud);
lukeocarwright 19:08862f49cd9e 104
lukeocarwright 26:a6033830d01c 105 /**Incraments Filter type
lukeocarwright 26:a6033830d01c 106 *outputs new filter value
lukeocarwright 26:a6033830d01c 107 */
lukeocarwright 26:a6033830d01c 108 int incrament_filter(int adsr, int ud);
lukeocarwright 26:a6033830d01c 109
lukeocarwright 24:c3bb1b0b2207 110 /**Converts Float to Frequency
lukeocarwright 24:c3bb1b0b2207 111 * @changes Pot 1 value to Frequency of tone (int)
lukeocarwright 24:c3bb1b0b2207 112 */
lukeocarwright 28:eb0f12304a45 113 int frequency_convert(Gamepad &pad, int oct);
lukeocarwright 26:a6033830d01c 114
lukeocarwright 19:08862f49cd9e 115 //pre compilation directive function
lukeocarwright 19:08862f49cd9e 116 #ifdef SLOW_TIME
lukeocarwright 21:60f01b17b0a6 117 /**prints slow time front values output from loop
lukeocarwright 21:60f01b17b0a6 118 * @prints values to pc if SLOW_TIME Macro used
lukeocarwright 21:60f01b17b0a6 119 */
lukeocarwright 19:08862f49cd9e 120 void print_SLOWTIME_out (uint16_t out, bool noteon, int a, int d, int s, int r, int release_flag, int silent_flag);
lukeocarwright 19:08862f49cd9e 121 #endif
lukeocarwright 21:60f01b17b0a6 122
lukeocarwright 7:33cb5f2db1ee 123 };
lukeocarwright 7:33cb5f2db1ee 124
lukeocarwright 7:33cb5f2db1ee 125 #endif