ELEC2645 (2019/20) / Mbed 2 deprecated el18loc_final

Dependencies:   mbed

Committer:
lukeocarwright
Date:
Thu May 21 22:59:59 2020 +0000
Revision:
18:204cd747b54a
Parent:
15:1c67f064278e
Child:
19:08862f49cd9e
Got attack working with hardware glitch (slew rate issue and distortion likely due to loading and amp module). Generates CSV file to check output with envelope.

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 14:9cfe0041cc4e 7
lukeocarwright 14:9cfe0041cc4e 8 //Sprites-----------------------------------------------------------------------
lukeocarwright 7:33cb5f2db1ee 9 const int fader[35][5] = {
lukeocarwright 7:33cb5f2db1ee 10 { 1,1,1,1,1 },
lukeocarwright 7:33cb5f2db1ee 11 { 0,0,1,0,0 },
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 { 1,1,1,0,0 },
lukeocarwright 7:33cb5f2db1ee 16 { 0,0,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 { 1,1,1,0,0 },
lukeocarwright 7:33cb5f2db1ee 21 { 0,0,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 { 1,1,1,0,0 },
lukeocarwright 7:33cb5f2db1ee 26 { 0,0,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 { 1,1,1,0,0 },
lukeocarwright 7:33cb5f2db1ee 31 { 0,0,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 { 1,1,1,0,0 },
lukeocarwright 7:33cb5f2db1ee 36 { 0,0,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 { 1,1,1,0,0 },
lukeocarwright 7:33cb5f2db1ee 41 { 0,0,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 { 1,1,1,1,1 },
lukeocarwright 7:33cb5f2db1ee 45 };
lukeocarwright 7:33cb5f2db1ee 46
lukeocarwright 14:9cfe0041cc4e 47 const int sin_wav[6][28] = {//sub 1 sin sprite
lukeocarwright 7:33cb5f2db1ee 48 { 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 49 { 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 50 { 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 51 { 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 52 { 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 53 { 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 54 };
lukeocarwright 14:9cfe0041cc4e 55 const int tri_wav[6][28] = {//sub 2 tri sprite
lukeocarwright 7:33cb5f2db1ee 56 { 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 57 { 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 58 { 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 59 { 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 60 { 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 61 { 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 62 };
lukeocarwright 14:9cfe0041cc4e 63 const int square_wav[6][28] = {//sub 3 sqr sprite
lukeocarwright 7:33cb5f2db1ee 64 { 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 65 { 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 66 { 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 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,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 69 { 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 70 };
lukeocarwright 18:204cd747b54a 71 //Gloabal Variables
lukeocarwright 14:9cfe0041cc4e 72 volatile int g_isr_flag;
lukeocarwright 14:9cfe0041cc4e 73
lukeocarwright 7:33cb5f2db1ee 74 //constructor/destructor
lukeocarwright 7:33cb5f2db1ee 75 Front::Front()
lukeocarwright 7:33cb5f2db1ee 76 {
lukeocarwright 7:33cb5f2db1ee 77 }
lukeocarwright 7:33cb5f2db1ee 78 Front::~Front()
lukeocarwright 7:33cb5f2db1ee 79 {
lukeocarwright 7:33cb5f2db1ee 80 }
lukeocarwright 7:33cb5f2db1ee 81 //PUBLIC------------------------------------------------------------------------
lukeocarwright 8:f305ea78b2b1 82
lukeocarwright 8:f305ea78b2b1 83 void Front::frontrun(N5110 &lcd, Gamepad &pad, int submenu)
lukeocarwright 18:204cd747b54a 84 {
lukeocarwright 14:9cfe0041cc4e 85 //printf("G_ISR_FLAG= %d\n",g_isr_flag);
lukeocarwright 13:27300c533dd1 86 frontsetup(lcd, pad, submenu, true);
lukeocarwright 8:f305ea78b2b1 87 menuflag=1;
lukeocarwright 13:27300c533dd1 88 used=1;
lukeocarwright 13:27300c533dd1 89 a=17;
lukeocarwright 13:27300c533dd1 90 d=17;
lukeocarwright 13:27300c533dd1 91 s=17;
lukeocarwright 13:27300c533dd1 92 r=17;
lukeocarwright 14:9cfe0041cc4e 93 out=sound.sound_main(true,submenu,440);
lukeocarwright 18:204cd747b54a 94 out=envelope.env_in(a,d,s,r,out,true);
lukeocarwright 18:204cd747b54a 95 noteon=false;
lukeocarwright 18:204cd747b54a 96 pad.reset_buttons();
lukeocarwright 18:204cd747b54a 97 //printf("starting while loop");
lukeocarwright 18:204cd747b54a 98 #ifdef CSV
lukeocarwright 18:204cd747b54a 99 itterator=0;
lukeocarwright 18:204cd747b54a 100 #endif
lukeocarwright 18:204cd747b54a 101
lukeocarwright 8:f305ea78b2b1 102 while (menuflag==1) {
lukeocarwright 18:204cd747b54a 103 if (noteon==true) {
lukeocarwright 18:204cd747b54a 104 if (g_isr_flag == 1) {
lukeocarwright 18:204cd747b54a 105 pad.write_u16(out);
lukeocarwright 18:204cd747b54a 106
lukeocarwright 18:204cd747b54a 107 envelope_in=(sound.sound_main(false,submenu,440)-32767); //value around 0
lukeocarwright 18:204cd747b54a 108 #ifdef SLOW_TIME
lukeocarwright 18:204cd747b54a 109 printf("SPEAKER VALUE = %u\n",out);
lukeocarwright 18:204cd747b54a 110 printf("\nENVELOPE IN = %d\n",envelope_in);
lukeocarwright 18:204cd747b54a 111 #endif
lukeocarwright 18:204cd747b54a 112 //out = envelope_in+32767; //skips envelope
lukeocarwright 18:204cd747b54a 113 out=(envelope.env_in(a,d,s,r,envelope_in,false)+32767);//value around 32767
lukeocarwright 18:204cd747b54a 114 g_isr_flag=0;
lukeocarwright 18:204cd747b54a 115 #ifdef CSV
lukeocarwright 18:204cd747b54a 116 printf("%d,%d\n",itterator,out);
lukeocarwright 18:204cd747b54a 117 itterator++;
lukeocarwright 18:204cd747b54a 118 #endif
lukeocarwright 14:9cfe0041cc4e 119 }
lukeocarwright 18:204cd747b54a 120 }
lukeocarwright 13:27300c533dd1 121 dir=pad.get_direction();
lukeocarwright 13:27300c533dd1 122 if (dir!=dir_1) {
lukeocarwright 13:27300c533dd1 123 printf("dir =%d\n",dir); //debug
lukeocarwright 13:27300c533dd1 124 if(dir==3) {
lukeocarwright 13:27300c533dd1 125 used++;
lukeocarwright 13:27300c533dd1 126 if (used>4) {
lukeocarwright 13:27300c533dd1 127 used=4;
lukeocarwright 13:27300c533dd1 128 }
lukeocarwright 13:27300c533dd1 129 }
lukeocarwright 13:27300c533dd1 130 if (dir==7) {
lukeocarwright 13:27300c533dd1 131 used--;
lukeocarwright 13:27300c533dd1 132 if(used<1) {
lukeocarwright 13:27300c533dd1 133 used=1;
lukeocarwright 13:27300c533dd1 134 }
lukeocarwright 13:27300c533dd1 135 }
lukeocarwright 13:27300c533dd1 136 if (dir==1) {
lukeocarwright 13:27300c533dd1 137 if (used==1) {
lukeocarwright 13:27300c533dd1 138 a=incrament_adsr(used,a,1);
lukeocarwright 13:27300c533dd1 139 }
lukeocarwright 13:27300c533dd1 140 if (used==2) {
lukeocarwright 13:27300c533dd1 141 d=incrament_adsr(used,d,1);
lukeocarwright 13:27300c533dd1 142 }
lukeocarwright 13:27300c533dd1 143 if (used==3) {
lukeocarwright 13:27300c533dd1 144 s=incrament_adsr(used,s,1);
lukeocarwright 13:27300c533dd1 145 }
lukeocarwright 13:27300c533dd1 146 if (used==4) {
lukeocarwright 13:27300c533dd1 147 r=incrament_adsr(used,r,1);
lukeocarwright 13:27300c533dd1 148 }
lukeocarwright 13:27300c533dd1 149 }
lukeocarwright 13:27300c533dd1 150
lukeocarwright 13:27300c533dd1 151 if (dir==5) {
lukeocarwright 13:27300c533dd1 152 if (used==1) {
lukeocarwright 13:27300c533dd1 153 a=incrament_adsr(used,a,-1);
lukeocarwright 13:27300c533dd1 154 }
lukeocarwright 13:27300c533dd1 155 if (used==2) {
lukeocarwright 13:27300c533dd1 156 d=incrament_adsr(used,d,-1);
lukeocarwright 13:27300c533dd1 157 }
lukeocarwright 13:27300c533dd1 158 if (used==3) {
lukeocarwright 13:27300c533dd1 159 s=incrament_adsr(used,s,-1);
lukeocarwright 13:27300c533dd1 160 }
lukeocarwright 13:27300c533dd1 161 if (used==4) {
lukeocarwright 13:27300c533dd1 162 r=incrament_adsr(used,r,-1);
lukeocarwright 13:27300c533dd1 163 }
lukeocarwright 13:27300c533dd1 164 }
lukeocarwright 13:27300c533dd1 165 frontsetup(lcd,pad,submenu,false);
lukeocarwright 13:27300c533dd1 166 printsliders(lcd,a,d,s,r,used);
lukeocarwright 18:204cd747b54a 167 wait_ms(50);
lukeocarwright 18:204cd747b54a 168 } //END if DIR
lukeocarwright 18:204cd747b54a 169 if ( pad.A_pressed()) { //NOTE ON
lukeocarwright 18:204cd747b54a 170 printf("NOTE_ON\n");
lukeocarwright 18:204cd747b54a 171 //wait_ms(200); //debounce
lukeocarwright 18:204cd747b54a 172 noteon=true;
lukeocarwright 18:204cd747b54a 173 out=envelope.env_in(a,d,s,r,out,true);
lukeocarwright 18:204cd747b54a 174 }
lukeocarwright 18:204cd747b54a 175 if ( pad.B_pressed()) { //NOTE OFF
lukeocarwright 18:204cd747b54a 176 printf("NOTE_OFF\n");
lukeocarwright 18:204cd747b54a 177 //wait_ms(200); //debounce
lukeocarwright 18:204cd747b54a 178 noteon=false;
lukeocarwright 18:204cd747b54a 179 out=envelope.env_in(a,d,s,r,out,true);
lukeocarwright 18:204cd747b54a 180 }
lukeocarwright 18:204cd747b54a 181
lukeocarwright 18:204cd747b54a 182 if (pad.start_pressed()) { //go back menu
lukeocarwright 18:204cd747b54a 183 // printf("start pressed\n");
lukeocarwright 18:204cd747b54a 184 printf("Waveforms Sub selected\n"); //debug
lukeocarwright 18:204cd747b54a 185 noteon=false;
lukeocarwright 18:204cd747b54a 186 //wait_ms(200); //debounce
lukeocarwright 18:204cd747b54a 187 menuflag=0; //sets flag
lukeocarwright 8:f305ea78b2b1 188 }
lukeocarwright 13:27300c533dd1 189 dir=dir_1;
lukeocarwright 14:9cfe0041cc4e 190 sleep();
lukeocarwright 18:204cd747b54a 191 }//end while()
lukeocarwright 8:f305ea78b2b1 192 }
lukeocarwright 8:f305ea78b2b1 193
lukeocarwright 8:f305ea78b2b1 194 //PRIVATE-----------------------------------------------------------------------
lukeocarwright 8:f305ea78b2b1 195
lukeocarwright 13:27300c533dd1 196 void Front::frontsetup(N5110 &lcd, Gamepad &pad, int submenu, bool initial)
lukeocarwright 7:33cb5f2db1ee 197 {
lukeocarwright 13:27300c533dd1 198 if (initial==true) {
lukeocarwright 13:27300c533dd1 199 printsliders(lcd,17,17,17,17,1);
lukeocarwright 18:204cd747b54a 200 printf("front setup complete\n\n");
lukeocarwright 13:27300c533dd1 201 }
lukeocarwright 7:33cb5f2db1ee 202 lcd.clear();
lukeocarwright 7:33cb5f2db1ee 203 lcd.printString("A D S R",3,5);
lukeocarwright 7:33cb5f2db1ee 204 printfader(lcd,3,3);
lukeocarwright 7:33cb5f2db1ee 205 printfader(lcd,15,3);
lukeocarwright 7:33cb5f2db1ee 206 printfader(lcd,27,3);
lukeocarwright 7:33cb5f2db1ee 207 printfader(lcd,39,3);
lukeocarwright 7:33cb5f2db1ee 208 lcd.drawRect(50,3,30,8,FILL_TRANSPARENT);
lukeocarwright 7:33cb5f2db1ee 209 printwav(lcd,submenu);
lukeocarwright 7:33cb5f2db1ee 210 lcd.refresh();
lukeocarwright 15:1c67f064278e 211 }
lukeocarwright 13:27300c533dd1 212
lukeocarwright 13:27300c533dd1 213 void Front::printsliders(N5110 &lcd, int a, int d, int s, int r, int used)
lukeocarwright 7:33cb5f2db1ee 214 {
lukeocarwright 13:27300c533dd1 215 if(used==0) {
lukeocarwright 13:27300c533dd1 216 printslider(lcd,3,a,false);
lukeocarwright 13:27300c533dd1 217 printslider(lcd,15,d,false);
lukeocarwright 13:27300c533dd1 218 printslider(lcd,27,s,false);
lukeocarwright 13:27300c533dd1 219 printslider(lcd,39,r,false);
lukeocarwright 13:27300c533dd1 220 }
lukeocarwright 13:27300c533dd1 221 if(used==1) {
lukeocarwright 13:27300c533dd1 222 printslider(lcd,3,a,true);
lukeocarwright 13:27300c533dd1 223 printslider(lcd,15,d,false);
lukeocarwright 13:27300c533dd1 224 printslider(lcd,27,s,false);
lukeocarwright 13:27300c533dd1 225 printslider(lcd,39,r,false);
lukeocarwright 13:27300c533dd1 226 }
lukeocarwright 13:27300c533dd1 227 if(used==2) {
lukeocarwright 13:27300c533dd1 228 printslider(lcd,3,a,false);
lukeocarwright 13:27300c533dd1 229 printslider(lcd,15,d,true);
lukeocarwright 13:27300c533dd1 230 printslider(lcd,27,s,false);
lukeocarwright 13:27300c533dd1 231 printslider(lcd,39,r,false);
lukeocarwright 13:27300c533dd1 232 }
lukeocarwright 13:27300c533dd1 233 if(used==3) {
lukeocarwright 13:27300c533dd1 234 printslider(lcd,3,a,false);
lukeocarwright 13:27300c533dd1 235 printslider(lcd,15,d,false);
lukeocarwright 13:27300c533dd1 236 printslider(lcd,27,s,true);
lukeocarwright 13:27300c533dd1 237 printslider(lcd,39,r,false);
lukeocarwright 13:27300c533dd1 238 }
lukeocarwright 13:27300c533dd1 239 if(used==4) {
lukeocarwright 13:27300c533dd1 240 printslider(lcd,3,a,false);
lukeocarwright 13:27300c533dd1 241 printslider(lcd,15,d,false);
lukeocarwright 13:27300c533dd1 242 printslider(lcd,27,s,false);
lukeocarwright 13:27300c533dd1 243 printslider(lcd,39,r,true);
lukeocarwright 13:27300c533dd1 244 }
lukeocarwright 13:27300c533dd1 245 lcd.refresh();
lukeocarwright 7:33cb5f2db1ee 246 }
lukeocarwright 13:27300c533dd1 247
lukeocarwright 13:27300c533dd1 248 void Front::printslider(N5110 &lcd, int x_val, int y_val, bool use)
lukeocarwright 13:27300c533dd1 249 {
lukeocarwright 13:27300c533dd1 250 if (use==true) {
lukeocarwright 13:27300c533dd1 251 lcd.drawRect(x_val,37-y_val,5,2,FILL_BLACK);
lukeocarwright 13:27300c533dd1 252 }
lukeocarwright 13:27300c533dd1 253 if (use==false) {
lukeocarwright 13:27300c533dd1 254 lcd.drawRect(x_val,37-y_val,5,1,FILL_BLACK);
lukeocarwright 13:27300c533dd1 255 }
lukeocarwright 13:27300c533dd1 256 }
lukeocarwright 13:27300c533dd1 257
lukeocarwright 13:27300c533dd1 258
lukeocarwright 7:33cb5f2db1ee 259 void Front::printfader(N5110 &lcd, int x, int y)
lukeocarwright 7:33cb5f2db1ee 260 {
lukeocarwright 7:33cb5f2db1ee 261 // x origin, y origin, rows, cols, sprite
lukeocarwright 7:33cb5f2db1ee 262 lcd.drawSprite(x,y,35,5,(int *)fader);
lukeocarwright 7:33cb5f2db1ee 263 }
lukeocarwright 7:33cb5f2db1ee 264
lukeocarwright 7:33cb5f2db1ee 265 void Front::printwav(N5110 &lcd, int submenu)
lukeocarwright 7:33cb5f2db1ee 266 {
lukeocarwright 7:33cb5f2db1ee 267 if (submenu==1) {
lukeocarwright 7:33cb5f2db1ee 268 // x origin, y origin, rows, cols, sprite
lukeocarwright 7:33cb5f2db1ee 269 lcd.drawSprite(51,4,6,28,(int *)sin_wav);
lukeocarwright 7:33cb5f2db1ee 270 }
lukeocarwright 7:33cb5f2db1ee 271 if (submenu==2) {
lukeocarwright 7:33cb5f2db1ee 272 // x origin, y origin, rows, cols, sprite
lukeocarwright 7:33cb5f2db1ee 273 lcd.drawSprite(51,4,6,28,(int *)tri_wav);
lukeocarwright 7:33cb5f2db1ee 274 }
lukeocarwright 7:33cb5f2db1ee 275 if (submenu==3) {
lukeocarwright 7:33cb5f2db1ee 276 // x origin, y origin, rows, cols, sprite
lukeocarwright 7:33cb5f2db1ee 277 lcd.drawSprite(51,4,6,28,(int *)square_wav);
lukeocarwright 7:33cb5f2db1ee 278 }
lukeocarwright 13:27300c533dd1 279 }
lukeocarwright 13:27300c533dd1 280
lukeocarwright 13:27300c533dd1 281 int Front::incrament_adsr(int used, int adsr, int ud)
lukeocarwright 13:27300c533dd1 282 {
lukeocarwright 13:27300c533dd1 283 if (ud==1) {
lukeocarwright 13:27300c533dd1 284 adsr++;
lukeocarwright 13:27300c533dd1 285 if (adsr>35) {
lukeocarwright 13:27300c533dd1 286 adsr--;
lukeocarwright 13:27300c533dd1 287 }
lukeocarwright 13:27300c533dd1 288 }
lukeocarwright 13:27300c533dd1 289 if (ud==-1) {
lukeocarwright 13:27300c533dd1 290 adsr--;
lukeocarwright 13:27300c533dd1 291 if (adsr<1) {
lukeocarwright 13:27300c533dd1 292 adsr++;
lukeocarwright 13:27300c533dd1 293 }
lukeocarwright 13:27300c533dd1 294 }
lukeocarwright 13:27300c533dd1 295 return(adsr);
lukeocarwright 7:33cb5f2db1ee 296 }