ELEC2645 (2019/20) / Mbed 2 deprecated el18loc_final

Dependencies:   mbed

Committer:
lukeocarwright
Date:
Sun May 24 17:10:27 2020 +0000
Revision:
25:f230af268e8b
Parent:
24:c3bb1b0b2207
Child:
26:a6033830d01c
Added Filter Graph Sprites and added initial GUI elements for this

Who changed what in which revision?

UserRevisionLine numberNew contents of line
lukeocarwright 7:33cb5f2db1ee 1 #include "mbed.h"
lukeocarwright 7:33cb5f2db1ee 2 #include "Front.h"
lukeocarwright 7:33cb5f2db1ee 3
lukeocarwright 14:9cfe0041cc4e 4 //Objects-----------------------------------------------------------------------
lukeocarwright 14:9cfe0041cc4e 5 Sound sound;
lukeocarwright 18:204cd747b54a 6 Envelope envelope;
lukeocarwright 24:c3bb1b0b2207 7 Filter filter;
lukeocarwright 14:9cfe0041cc4e 8
lukeocarwright 14:9cfe0041cc4e 9 //Sprites-----------------------------------------------------------------------
lukeocarwright 19:08862f49cd9e 10 const int fader[35][5] = { //Fader Sprite
lukeocarwright 7:33cb5f2db1ee 11 { 1,1,1,1,1 },
lukeocarwright 7:33cb5f2db1ee 12 { 0,0,1,0,0 },
lukeocarwright 7:33cb5f2db1ee 13 { 0,0,1,0,0 },
lukeocarwright 7:33cb5f2db1ee 14 { 0,0,1,0,0 },
lukeocarwright 7:33cb5f2db1ee 15 { 0,0,1,0,0 },
lukeocarwright 7:33cb5f2db1ee 16 { 1,1,1,0,0 },
lukeocarwright 7:33cb5f2db1ee 17 { 0,0,1,0,0 },
lukeocarwright 7:33cb5f2db1ee 18 { 0,0,1,0,0 },
lukeocarwright 7:33cb5f2db1ee 19 { 0,0,1,0,0 },
lukeocarwright 7:33cb5f2db1ee 20 { 0,0,1,0,0 },
lukeocarwright 7:33cb5f2db1ee 21 { 1,1,1,0,0 },
lukeocarwright 7:33cb5f2db1ee 22 { 0,0,1,0,0 },
lukeocarwright 7:33cb5f2db1ee 23 { 0,0,1,0,0 },
lukeocarwright 7:33cb5f2db1ee 24 { 0,0,1,0,0 },
lukeocarwright 7:33cb5f2db1ee 25 { 0,0,1,0,0 },
lukeocarwright 7:33cb5f2db1ee 26 { 1,1,1,0,0 },
lukeocarwright 7:33cb5f2db1ee 27 { 0,0,1,0,0 },
lukeocarwright 7:33cb5f2db1ee 28 { 0,0,1,0,0 },
lukeocarwright 7:33cb5f2db1ee 29 { 0,0,1,0,0 },
lukeocarwright 7:33cb5f2db1ee 30 { 0,0,1,0,0 },
lukeocarwright 7:33cb5f2db1ee 31 { 1,1,1,0,0 },
lukeocarwright 7:33cb5f2db1ee 32 { 0,0,1,0,0 },
lukeocarwright 7:33cb5f2db1ee 33 { 0,0,1,0,0 },
lukeocarwright 7:33cb5f2db1ee 34 { 0,0,1,0,0 },
lukeocarwright 7:33cb5f2db1ee 35 { 0,0,1,0,0 },
lukeocarwright 7:33cb5f2db1ee 36 { 1,1,1,0,0 },
lukeocarwright 7:33cb5f2db1ee 37 { 0,0,1,0,0 },
lukeocarwright 7:33cb5f2db1ee 38 { 0,0,1,0,0 },
lukeocarwright 7:33cb5f2db1ee 39 { 0,0,1,0,0 },
lukeocarwright 7:33cb5f2db1ee 40 { 0,0,1,0,0 },
lukeocarwright 7:33cb5f2db1ee 41 { 1,1,1,0,0 },
lukeocarwright 7:33cb5f2db1ee 42 { 0,0,1,0,0 },
lukeocarwright 7:33cb5f2db1ee 43 { 0,0,1,0,0 },
lukeocarwright 7:33cb5f2db1ee 44 { 0,0,1,0,0 },
lukeocarwright 7:33cb5f2db1ee 45 { 1,1,1,1,1 },
lukeocarwright 7:33cb5f2db1ee 46 };
lukeocarwright 7:33cb5f2db1ee 47
lukeocarwright 14:9cfe0041cc4e 48 const int sin_wav[6][28] = {//sub 1 sin sprite
lukeocarwright 7:33cb5f2db1ee 49 { 0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0 },
lukeocarwright 7:33cb5f2db1ee 50 { 0,1,1,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,1,1,0,0 },
lukeocarwright 7:33cb5f2db1ee 51 { 1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0 },
lukeocarwright 7:33cb5f2db1ee 52 { 0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1 },
lukeocarwright 7:33cb5f2db1ee 53 { 0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0 },
lukeocarwright 7:33cb5f2db1ee 54 { 0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0 },
lukeocarwright 7:33cb5f2db1ee 55 };
lukeocarwright 14:9cfe0041cc4e 56 const int tri_wav[6][28] = {//sub 2 tri sprite
lukeocarwright 7:33cb5f2db1ee 57 { 0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0 },
lukeocarwright 7:33cb5f2db1ee 58 { 0,0,1,0,1,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,1,0,1,0,0,0 },
lukeocarwright 7:33cb5f2db1ee 59 { 0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,1,0,0 },
lukeocarwright 7:33cb5f2db1ee 60 { 1,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,1,0 },
lukeocarwright 7:33cb5f2db1ee 61 { 0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,1 },
lukeocarwright 7:33cb5f2db1ee 62 { 0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0 },
lukeocarwright 7:33cb5f2db1ee 63 };
lukeocarwright 14:9cfe0041cc4e 64 const int square_wav[6][28] = {//sub 3 sqr sprite
lukeocarwright 7:33cb5f2db1ee 65 { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
lukeocarwright 7:33cb5f2db1ee 66 { 1,1,1,1,1,0,0,0,1,1,1,1,1,0,0,0,1,1,1,1,1,0,0,0,1,1,1,1 },
lukeocarwright 7:33cb5f2db1ee 67 { 0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0 },
lukeocarwright 7:33cb5f2db1ee 68 { 0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0 },
lukeocarwright 7:33cb5f2db1ee 69 { 0,0,0,0,1,1,1,1,1,0,0,0,1,1,1,1,1,0,0,0,1,1,1,1,1,0,0,0 },
lukeocarwright 7:33cb5f2db1ee 70 { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
lukeocarwright 7:33cb5f2db1ee 71 };
lukeocarwright 25:f230af268e8b 72
lukeocarwright 25:f230af268e8b 73 const int Low_pass[19][29]= {//LPF plot
lukeocarwright 25:f230af268e8b 74 { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
lukeocarwright 25:f230af268e8b 75 { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
lukeocarwright 25:f230af268e8b 76 { 0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0 },
lukeocarwright 25:f230af268e8b 77 { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0 },
lukeocarwright 25:f230af268e8b 78 { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0 },
lukeocarwright 25:f230af268e8b 79 { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0 },
lukeocarwright 25:f230af268e8b 80 { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0 },
lukeocarwright 25:f230af268e8b 81 { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0 },
lukeocarwright 25:f230af268e8b 82 { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0 },
lukeocarwright 25:f230af268e8b 83 { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0 },
lukeocarwright 25:f230af268e8b 84 { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0 },
lukeocarwright 25:f230af268e8b 85 { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0 },
lukeocarwright 25:f230af268e8b 86 { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0 },
lukeocarwright 25:f230af268e8b 87 { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0 },
lukeocarwright 25:f230af268e8b 88 { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0 },
lukeocarwright 25:f230af268e8b 89 { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0 },
lukeocarwright 25:f230af268e8b 90 { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0 },
lukeocarwright 25:f230af268e8b 91 { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0 },
lukeocarwright 25:f230af268e8b 92 { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0 },
lukeocarwright 25:f230af268e8b 93 };
lukeocarwright 25:f230af268e8b 94
lukeocarwright 25:f230af268e8b 95 const int High_pass[19][29]= {//HPF plot
lukeocarwright 25:f230af268e8b 96 { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
lukeocarwright 25:f230af268e8b 97 { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 },
lukeocarwright 25:f230af268e8b 98 { 0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
lukeocarwright 25:f230af268e8b 99 { 0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
lukeocarwright 25:f230af268e8b 100 { 0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
lukeocarwright 25:f230af268e8b 101 { 0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
lukeocarwright 25:f230af268e8b 102 { 0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
lukeocarwright 25:f230af268e8b 103 { 0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
lukeocarwright 25:f230af268e8b 104 { 0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
lukeocarwright 25:f230af268e8b 105 { 0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
lukeocarwright 25:f230af268e8b 106 { 0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
lukeocarwright 25:f230af268e8b 107 { 0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
lukeocarwright 25:f230af268e8b 108 { 0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
lukeocarwright 25:f230af268e8b 109 { 0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
lukeocarwright 25:f230af268e8b 110 { 0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
lukeocarwright 25:f230af268e8b 111 { 0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
lukeocarwright 25:f230af268e8b 112 { 0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
lukeocarwright 25:f230af268e8b 113 { 0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
lukeocarwright 25:f230af268e8b 114 { 0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
lukeocarwright 25:f230af268e8b 115 };
lukeocarwright 25:f230af268e8b 116
lukeocarwright 25:f230af268e8b 117 const int Band_pass[19][29]= {//BPF plot
lukeocarwright 25:f230af268e8b 118 { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
lukeocarwright 25:f230af268e8b 119 { 0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0 },
lukeocarwright 25:f230af268e8b 120 { 0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0 },
lukeocarwright 25:f230af268e8b 121 { 0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0 },
lukeocarwright 25:f230af268e8b 122 { 0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0 },
lukeocarwright 25:f230af268e8b 123 { 0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0 },
lukeocarwright 25:f230af268e8b 124 { 0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0 },
lukeocarwright 25:f230af268e8b 125 { 0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0 },
lukeocarwright 25:f230af268e8b 126 { 0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0 },
lukeocarwright 25:f230af268e8b 127 { 0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0 },
lukeocarwright 25:f230af268e8b 128 { 0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0 },
lukeocarwright 25:f230af268e8b 129 { 0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0 },
lukeocarwright 25:f230af268e8b 130 { 0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0 },
lukeocarwright 25:f230af268e8b 131 { 0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0 },
lukeocarwright 25:f230af268e8b 132 { 0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0 },
lukeocarwright 25:f230af268e8b 133 { 0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0 },
lukeocarwright 25:f230af268e8b 134 { 0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0 },
lukeocarwright 25:f230af268e8b 135 { 0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0 },
lukeocarwright 25:f230af268e8b 136 { 0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0 },
lukeocarwright 25:f230af268e8b 137 };
lukeocarwright 25:f230af268e8b 138
lukeocarwright 18:204cd747b54a 139 //Gloabal Variables
lukeocarwright 19:08862f49cd9e 140 volatile int g_isr_flag; //used for sound generation
lukeocarwright 24:c3bb1b0b2207 141 volatile extern int silent_flag; //used for note release
lukeocarwright 19:08862f49cd9e 142
lukeocarwright 14:9cfe0041cc4e 143
lukeocarwright 7:33cb5f2db1ee 144 //constructor/destructor
lukeocarwright 7:33cb5f2db1ee 145 Front::Front()
lukeocarwright 7:33cb5f2db1ee 146 {
lukeocarwright 7:33cb5f2db1ee 147 }
lukeocarwright 7:33cb5f2db1ee 148 Front::~Front()
lukeocarwright 7:33cb5f2db1ee 149 {
lukeocarwright 7:33cb5f2db1ee 150 }
lukeocarwright 7:33cb5f2db1ee 151 //PUBLIC------------------------------------------------------------------------
lukeocarwright 8:f305ea78b2b1 152
lukeocarwright 8:f305ea78b2b1 153 void Front::frontrun(N5110 &lcd, Gamepad &pad, int submenu)
lukeocarwright 18:204cd747b54a 154 {
lukeocarwright 19:08862f49cd9e 155 //printf("G_ISR_FLAG= %d\n",g_isr_flag); //DEBUG
lukeocarwright 25:f230af268e8b 156 frontsetup(lcd, pad, submenu,0, true); //Initialises front pannel display
lukeocarwright 24:c3bb1b0b2207 157 initialise(pad,lcd,submenu);
lukeocarwright 24:c3bb1b0b2207 158 frequency=frequency_convert(pad);
lukeocarwright 19:08862f49cd9e 159 menuflag=1; //sets up flags
lukeocarwright 19:08862f49cd9e 160 release_flag=silent_flag=0;
lukeocarwright 19:08862f49cd9e 161 used=1; //initialises vairables
lukeocarwright 25:f230af268e8b 162 filter_type=envelope_in=0;
lukeocarwright 19:08862f49cd9e 163 a=d=s=r=17; //starting adsr values (1->35)
lukeocarwright 19:08862f49cd9e 164 noteon=false;
lukeocarwright 19:08862f49cd9e 165 #ifdef CSV
lukeocarwright 19:08862f49cd9e 166 itterator=0; //sets itterator for CSV OUTPUT
lukeocarwright 19:08862f49cd9e 167 #endif
lukeocarwright 18:204cd747b54a 168
lukeocarwright 8:f305ea78b2b1 169 while (menuflag==1) {
lukeocarwright 18:204cd747b54a 170 #ifdef SLOW_TIME
lukeocarwright 19:08862f49cd9e 171 print_SLOWTIME_out(out,noteon,a,d,s,r,release_flag,silent_flag);
lukeocarwright 18:204cd747b54a 172 #endif
lukeocarwright 19:08862f49cd9e 173 if (noteon==true && g_isr_flag == 1) {
lukeocarwright 19:08862f49cd9e 174 pad.write_u16(out);
lukeocarwright 24:c3bb1b0b2207 175 envelope_in=(sound.sound_main(false,submenu,frequency)-32767); //value around 0
lukeocarwright 24:c3bb1b0b2207 176 envelope_in=filter.LPF(envelope_in,false);
lukeocarwright 19:08862f49cd9e 177 if (release_flag==0) {
lukeocarwright 19:08862f49cd9e 178 out=(envelope.env_in(a,d,s,r,envelope_in,false));//value around 32767
lukeocarwright 19:08862f49cd9e 179 //out=envelope_in+32767;
lukeocarwright 19:08862f49cd9e 180 } else {
lukeocarwright 19:08862f49cd9e 181 out=envelope.release(s,r,envelope_in,false);
lukeocarwright 19:08862f49cd9e 182 if (silent_flag==1) {
lukeocarwright 19:08862f49cd9e 183 release_flag=0;
lukeocarwright 19:08862f49cd9e 184 silent_flag=0;
lukeocarwright 19:08862f49cd9e 185 noteon=false;
lukeocarwright 19:08862f49cd9e 186 out=envelope.env_in(a,d,s,r,out,true);
lukeocarwright 19:08862f49cd9e 187 out=0;
lukeocarwright 19:08862f49cd9e 188 }
lukeocarwright 19:08862f49cd9e 189 }
lukeocarwright 19:08862f49cd9e 190 g_isr_flag=0;
lukeocarwright 18:204cd747b54a 191 #ifdef CSV
lukeocarwright 19:08862f49cd9e 192 printf("%d,%d\n",itterator,out);
lukeocarwright 19:08862f49cd9e 193 itterator++;
lukeocarwright 18:204cd747b54a 194 #endif
lukeocarwright 18:204cd747b54a 195 }
lukeocarwright 13:27300c533dd1 196 dir=pad.get_direction();
lukeocarwright 13:27300c533dd1 197 if (dir!=dir_1) {
lukeocarwright 13:27300c533dd1 198 printf("dir =%d\n",dir); //debug
lukeocarwright 25:f230af268e8b 199 //used=parameter_manager(pad,dir,a,d,s,r);
lukeocarwright 13:27300c533dd1 200 if(dir==3) {
lukeocarwright 13:27300c533dd1 201 used++;
lukeocarwright 25:f230af268e8b 202 if (used>5) {
lukeocarwright 25:f230af268e8b 203 used=5;
lukeocarwright 13:27300c533dd1 204 }
lukeocarwright 13:27300c533dd1 205 }
lukeocarwright 13:27300c533dd1 206 if (dir==7) {
lukeocarwright 13:27300c533dd1 207 used--;
lukeocarwright 13:27300c533dd1 208 if(used<1) {
lukeocarwright 13:27300c533dd1 209 used=1;
lukeocarwright 13:27300c533dd1 210 }
lukeocarwright 13:27300c533dd1 211 }
lukeocarwright 13:27300c533dd1 212 if (dir==1) {
lukeocarwright 13:27300c533dd1 213 if (used==1) {
lukeocarwright 13:27300c533dd1 214 a=incrament_adsr(used,a,1);
lukeocarwright 13:27300c533dd1 215 }
lukeocarwright 13:27300c533dd1 216 if (used==2) {
lukeocarwright 13:27300c533dd1 217 d=incrament_adsr(used,d,1);
lukeocarwright 13:27300c533dd1 218 }
lukeocarwright 13:27300c533dd1 219 if (used==3) {
lukeocarwright 13:27300c533dd1 220 s=incrament_adsr(used,s,1);
lukeocarwright 13:27300c533dd1 221 }
lukeocarwright 13:27300c533dd1 222 if (used==4) {
lukeocarwright 13:27300c533dd1 223 r=incrament_adsr(used,r,1);
lukeocarwright 13:27300c533dd1 224 }
lukeocarwright 13:27300c533dd1 225 }
lukeocarwright 13:27300c533dd1 226
lukeocarwright 13:27300c533dd1 227 if (dir==5) {
lukeocarwright 13:27300c533dd1 228 if (used==1) {
lukeocarwright 13:27300c533dd1 229 a=incrament_adsr(used,a,-1);
lukeocarwright 13:27300c533dd1 230 }
lukeocarwright 13:27300c533dd1 231 if (used==2) {
lukeocarwright 13:27300c533dd1 232 d=incrament_adsr(used,d,-1);
lukeocarwright 13:27300c533dd1 233 }
lukeocarwright 13:27300c533dd1 234 if (used==3) {
lukeocarwright 13:27300c533dd1 235 s=incrament_adsr(used,s,-1);
lukeocarwright 13:27300c533dd1 236 }
lukeocarwright 13:27300c533dd1 237 if (used==4) {
lukeocarwright 13:27300c533dd1 238 r=incrament_adsr(used,r,-1);
lukeocarwright 13:27300c533dd1 239 }
lukeocarwright 13:27300c533dd1 240 }
lukeocarwright 25:f230af268e8b 241 frontsetup(lcd,pad,submenu,filter_type,false);
lukeocarwright 13:27300c533dd1 242 printsliders(lcd,a,d,s,r,used);
lukeocarwright 18:204cd747b54a 243 wait_ms(50);
lukeocarwright 18:204cd747b54a 244 } //END if DIR
lukeocarwright 18:204cd747b54a 245 if ( pad.A_pressed()) { //NOTE ON
lukeocarwright 18:204cd747b54a 246 printf("NOTE_ON\n");
lukeocarwright 18:204cd747b54a 247 noteon=true;
lukeocarwright 18:204cd747b54a 248 out=envelope.env_in(a,d,s,r,out,true);
lukeocarwright 24:c3bb1b0b2207 249 frequency=frequency_convert(pad);
lukeocarwright 18:204cd747b54a 250 }
lukeocarwright 18:204cd747b54a 251 if ( pad.B_pressed()) { //NOTE OFF
lukeocarwright 19:08862f49cd9e 252 //printf("NOTE_OFF (W.release)\n");
lukeocarwright 19:08862f49cd9e 253 release_flag=1;
lukeocarwright 19:08862f49cd9e 254 envelope_in=envelope.release(s,r,envelope_in,true);
lukeocarwright 19:08862f49cd9e 255 pad.reset_buttons();
lukeocarwright 18:204cd747b54a 256 }
lukeocarwright 18:204cd747b54a 257
lukeocarwright 18:204cd747b54a 258 if (pad.start_pressed()) { //go back menu
lukeocarwright 18:204cd747b54a 259 // printf("start pressed\n");
lukeocarwright 18:204cd747b54a 260 printf("Waveforms Sub selected\n"); //debug
lukeocarwright 18:204cd747b54a 261 noteon=false;
lukeocarwright 18:204cd747b54a 262 menuflag=0; //sets flag
lukeocarwright 8:f305ea78b2b1 263 }
lukeocarwright 13:27300c533dd1 264 dir=dir_1;
lukeocarwright 19:08862f49cd9e 265 sleep(); //puts sleep until ISR wakes up
lukeocarwright 19:08862f49cd9e 266 }
lukeocarwright 8:f305ea78b2b1 267 }
lukeocarwright 8:f305ea78b2b1 268
lukeocarwright 8:f305ea78b2b1 269 //PRIVATE-----------------------------------------------------------------------
lukeocarwright 8:f305ea78b2b1 270
lukeocarwright 25:f230af268e8b 271 void Front::frontsetup(N5110 &lcd, Gamepad &pad, int submenu, int filter_type, bool initial)
lukeocarwright 7:33cb5f2db1ee 272 {
lukeocarwright 13:27300c533dd1 273 if (initial==true) {
lukeocarwright 13:27300c533dd1 274 printsliders(lcd,17,17,17,17,1);
lukeocarwright 18:204cd747b54a 275 printf("front setup complete\n\n");
lukeocarwright 25:f230af268e8b 276
lukeocarwright 13:27300c533dd1 277 }
lukeocarwright 7:33cb5f2db1ee 278 lcd.clear();
lukeocarwright 7:33cb5f2db1ee 279 lcd.printString("A D S R",3,5);
lukeocarwright 7:33cb5f2db1ee 280 printfader(lcd,3,3);
lukeocarwright 7:33cb5f2db1ee 281 printfader(lcd,15,3);
lukeocarwright 7:33cb5f2db1ee 282 printfader(lcd,27,3);
lukeocarwright 7:33cb5f2db1ee 283 printfader(lcd,39,3);
lukeocarwright 7:33cb5f2db1ee 284 lcd.drawRect(50,3,30,8,FILL_TRANSPARENT);
lukeocarwright 7:33cb5f2db1ee 285 printwav(lcd,submenu);
lukeocarwright 25:f230af268e8b 286 printfilter(lcd, 3);
lukeocarwright 7:33cb5f2db1ee 287 lcd.refresh();
lukeocarwright 15:1c67f064278e 288 }
lukeocarwright 13:27300c533dd1 289
lukeocarwright 24:c3bb1b0b2207 290 void Front::initialise(Gamepad &pad, N5110 &lcd, int submenu)
lukeocarwright 24:c3bb1b0b2207 291 {
lukeocarwright 24:c3bb1b0b2207 292 out=sound.sound_main(true,submenu,440); //initialises external variables
lukeocarwright 24:c3bb1b0b2207 293 out = filter.LPF(out,true); //initialises LPF Filter
lukeocarwright 24:c3bb1b0b2207 294 out=envelope.env_in(17,17,17,17,out,true);
lukeocarwright 24:c3bb1b0b2207 295 out=envelope.release(17,17,out,true);
lukeocarwright 24:c3bb1b0b2207 296 printsliders(lcd,17,17,17,17,1); //prints initialsliders
lukeocarwright 24:c3bb1b0b2207 297 pad.reset_buttons();
lukeocarwright 24:c3bb1b0b2207 298 }
lukeocarwright 24:c3bb1b0b2207 299
lukeocarwright 13:27300c533dd1 300 void Front::printsliders(N5110 &lcd, int a, int d, int s, int r, int used)
lukeocarwright 7:33cb5f2db1ee 301 {
lukeocarwright 13:27300c533dd1 302 if(used==0) {
lukeocarwright 13:27300c533dd1 303 printslider(lcd,3,a,false);
lukeocarwright 13:27300c533dd1 304 printslider(lcd,15,d,false);
lukeocarwright 13:27300c533dd1 305 printslider(lcd,27,s,false);
lukeocarwright 13:27300c533dd1 306 printslider(lcd,39,r,false);
lukeocarwright 13:27300c533dd1 307 }
lukeocarwright 13:27300c533dd1 308 if(used==1) {
lukeocarwright 13:27300c533dd1 309 printslider(lcd,3,a,true);
lukeocarwright 13:27300c533dd1 310 printslider(lcd,15,d,false);
lukeocarwright 13:27300c533dd1 311 printslider(lcd,27,s,false);
lukeocarwright 13:27300c533dd1 312 printslider(lcd,39,r,false);
lukeocarwright 13:27300c533dd1 313 }
lukeocarwright 13:27300c533dd1 314 if(used==2) {
lukeocarwright 13:27300c533dd1 315 printslider(lcd,3,a,false);
lukeocarwright 13:27300c533dd1 316 printslider(lcd,15,d,true);
lukeocarwright 13:27300c533dd1 317 printslider(lcd,27,s,false);
lukeocarwright 13:27300c533dd1 318 printslider(lcd,39,r,false);
lukeocarwright 13:27300c533dd1 319 }
lukeocarwright 13:27300c533dd1 320 if(used==3) {
lukeocarwright 13:27300c533dd1 321 printslider(lcd,3,a,false);
lukeocarwright 13:27300c533dd1 322 printslider(lcd,15,d,false);
lukeocarwright 13:27300c533dd1 323 printslider(lcd,27,s,true);
lukeocarwright 13:27300c533dd1 324 printslider(lcd,39,r,false);
lukeocarwright 13:27300c533dd1 325 }
lukeocarwright 13:27300c533dd1 326 if(used==4) {
lukeocarwright 13:27300c533dd1 327 printslider(lcd,3,a,false);
lukeocarwright 13:27300c533dd1 328 printslider(lcd,15,d,false);
lukeocarwright 13:27300c533dd1 329 printslider(lcd,27,s,false);
lukeocarwright 13:27300c533dd1 330 printslider(lcd,39,r,true);
lukeocarwright 13:27300c533dd1 331 }
lukeocarwright 25:f230af268e8b 332 if(used>=5) {
lukeocarwright 25:f230af268e8b 333 printslider(lcd,3,a,false);
lukeocarwright 25:f230af268e8b 334 printslider(lcd,15,d,false);
lukeocarwright 25:f230af268e8b 335 printslider(lcd,27,s,false);
lukeocarwright 25:f230af268e8b 336 printslider(lcd,39,r,false);
lukeocarwright 25:f230af268e8b 337 }
lukeocarwright 13:27300c533dd1 338 lcd.refresh();
lukeocarwright 7:33cb5f2db1ee 339 }
lukeocarwright 13:27300c533dd1 340
lukeocarwright 13:27300c533dd1 341 void Front::printslider(N5110 &lcd, int x_val, int y_val, bool use)
lukeocarwright 13:27300c533dd1 342 {
lukeocarwright 13:27300c533dd1 343 if (use==true) {
lukeocarwright 13:27300c533dd1 344 lcd.drawRect(x_val,37-y_val,5,2,FILL_BLACK);
lukeocarwright 13:27300c533dd1 345 }
lukeocarwright 13:27300c533dd1 346 if (use==false) {
lukeocarwright 13:27300c533dd1 347 lcd.drawRect(x_val,37-y_val,5,1,FILL_BLACK);
lukeocarwright 13:27300c533dd1 348 }
lukeocarwright 13:27300c533dd1 349 }
lukeocarwright 13:27300c533dd1 350
lukeocarwright 13:27300c533dd1 351
lukeocarwright 7:33cb5f2db1ee 352 void Front::printfader(N5110 &lcd, int x, int y)
lukeocarwright 7:33cb5f2db1ee 353 {
lukeocarwright 7:33cb5f2db1ee 354 // x origin, y origin, rows, cols, sprite
lukeocarwright 7:33cb5f2db1ee 355 lcd.drawSprite(x,y,35,5,(int *)fader);
lukeocarwright 7:33cb5f2db1ee 356 }
lukeocarwright 7:33cb5f2db1ee 357
lukeocarwright 7:33cb5f2db1ee 358 void Front::printwav(N5110 &lcd, int submenu)
lukeocarwright 7:33cb5f2db1ee 359 {
lukeocarwright 7:33cb5f2db1ee 360 if (submenu==1) {
lukeocarwright 7:33cb5f2db1ee 361 // x origin, y origin, rows, cols, sprite
lukeocarwright 7:33cb5f2db1ee 362 lcd.drawSprite(51,4,6,28,(int *)sin_wav);
lukeocarwright 7:33cb5f2db1ee 363 }
lukeocarwright 7:33cb5f2db1ee 364 if (submenu==2) {
lukeocarwright 7:33cb5f2db1ee 365 // x origin, y origin, rows, cols, sprite
lukeocarwright 7:33cb5f2db1ee 366 lcd.drawSprite(51,4,6,28,(int *)tri_wav);
lukeocarwright 7:33cb5f2db1ee 367 }
lukeocarwright 7:33cb5f2db1ee 368 if (submenu==3) {
lukeocarwright 7:33cb5f2db1ee 369 // x origin, y origin, rows, cols, sprite
lukeocarwright 7:33cb5f2db1ee 370 lcd.drawSprite(51,4,6,28,(int *)square_wav);
lukeocarwright 7:33cb5f2db1ee 371 }
lukeocarwright 13:27300c533dd1 372 }
lukeocarwright 13:27300c533dd1 373
lukeocarwright 25:f230af268e8b 374 void Front::printfilter(N5110 &lcd, int filter_type)
lukeocarwright 25:f230af268e8b 375 {
lukeocarwright 25:f230af268e8b 376 if (filter_type>=1) {
lukeocarwright 25:f230af268e8b 377 lcd.drawLine(51,32,51,12,1); //y axis
lukeocarwright 25:f230af268e8b 378 lcd.drawLine(51,32,81,32,1); //x axis
lukeocarwright 25:f230af268e8b 379 if (filter_type==1) {
lukeocarwright 25:f230af268e8b 380 lcd.drawSprite(52,13,19,29,(int *)Low_pass);
lukeocarwright 25:f230af268e8b 381 lcd.printString("L",45,2);
lukeocarwright 25:f230af268e8b 382 }
lukeocarwright 25:f230af268e8b 383 if (filter_type==2) {
lukeocarwright 25:f230af268e8b 384 lcd.drawSprite(52,13,19,29,(int *)High_pass);
lukeocarwright 25:f230af268e8b 385 lcd.printString("H",45,2);
lukeocarwright 25:f230af268e8b 386 }
lukeocarwright 25:f230af268e8b 387 if (filter_type==3) {
lukeocarwright 25:f230af268e8b 388 lcd.drawSprite(52,13,19,29,(int *)Band_pass);
lukeocarwright 25:f230af268e8b 389 lcd.printString("B",45,2);
lukeocarwright 25:f230af268e8b 390 }
lukeocarwright 25:f230af268e8b 391 }
lukeocarwright 25:f230af268e8b 392 }
lukeocarwright 25:f230af268e8b 393
lukeocarwright 25:f230af268e8b 394 int Front::parameter_manager(Gamepad &pad, int dir, int a, int d, int s, int r)
lukeocarwright 25:f230af268e8b 395 {
lukeocarwright 25:f230af268e8b 396
lukeocarwright 25:f230af268e8b 397 return(used);
lukeocarwright 25:f230af268e8b 398 }
lukeocarwright 25:f230af268e8b 399
lukeocarwright 13:27300c533dd1 400 int Front::incrament_adsr(int used, int adsr, int ud)
lukeocarwright 13:27300c533dd1 401 {
lukeocarwright 25:f230af268e8b 402 if (used<=4) {
lukeocarwright 25:f230af268e8b 403 if (ud==1) {
lukeocarwright 25:f230af268e8b 404 adsr++;
lukeocarwright 25:f230af268e8b 405 if (adsr>35) {
lukeocarwright 25:f230af268e8b 406 adsr--;
lukeocarwright 25:f230af268e8b 407 }
lukeocarwright 13:27300c533dd1 408 }
lukeocarwright 25:f230af268e8b 409 if (ud==-1) {
lukeocarwright 25:f230af268e8b 410 adsr--;
lukeocarwright 25:f230af268e8b 411 if (adsr<1) {
lukeocarwright 25:f230af268e8b 412 adsr++;
lukeocarwright 25:f230af268e8b 413 }
lukeocarwright 13:27300c533dd1 414 }
lukeocarwright 13:27300c533dd1 415 }
lukeocarwright 13:27300c533dd1 416 return(adsr);
lukeocarwright 19:08862f49cd9e 417 }
lukeocarwright 19:08862f49cd9e 418
lukeocarwright 24:c3bb1b0b2207 419 int Front::frequency_convert(Gamepad &pad)
lukeocarwright 24:c3bb1b0b2207 420 {
lukeocarwright 24:c3bb1b0b2207 421 frequency=(440+(pad.read_pot1()*440));
lukeocarwright 24:c3bb1b0b2207 422 return(frequency);
lukeocarwright 24:c3bb1b0b2207 423 }
lukeocarwright 24:c3bb1b0b2207 424
lukeocarwright 19:08862f49cd9e 425 #ifdef SLOW_TIME
lukeocarwright 19:08862f49cd9e 426 void Front::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 427 {
lukeocarwright 19:08862f49cd9e 428 //Prints all data required in SLOW_TIME
lukeocarwright 19:08862f49cd9e 429 printf("OUTPUT:%d\n",out);
lukeocarwright 19:08862f49cd9e 430 printf("NOTEON: %d\n",noteon);
lukeocarwright 19:08862f49cd9e 431 printf("A:%d,D:%d,S:%d,R:%d\n",a,d,s,r);
lukeocarwright 19:08862f49cd9e 432 printf("RelFlag=%d, SilFlag=%d\n\n",release_flag,silent_flag);
lukeocarwright 19:08862f49cd9e 433 }
lukeocarwright 19:08862f49cd9e 434 #endif