Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Diff: Front/Front.cpp
- Revision:
- 18:204cd747b54a
- Parent:
- 15:1c67f064278e
- Child:
- 19:08862f49cd9e
--- a/Front/Front.cpp Thu May 21 12:50:43 2020 +0000 +++ b/Front/Front.cpp Thu May 21 22:59:59 2020 +0000 @@ -3,6 +3,7 @@ //Objects----------------------------------------------------------------------- Sound sound; +Envelope envelope; //Sprites----------------------------------------------------------------------- const int fader[35][5] = { @@ -67,6 +68,7 @@ { 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 }, { 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 }, }; +//Gloabal Variables volatile int g_isr_flag; //constructor/destructor @@ -79,7 +81,7 @@ //PUBLIC------------------------------------------------------------------------ void Front::frontrun(N5110 &lcd, Gamepad &pad, int submenu) -{ +{ //printf("G_ISR_FLAG= %d\n",g_isr_flag); frontsetup(lcd, pad, submenu, true); menuflag=1; @@ -89,19 +91,33 @@ s=17; r=17; out=sound.sound_main(true,submenu,440); - + out=envelope.env_in(a,d,s,r,out,true); + noteon=false; + pad.reset_buttons(); + //printf("starting while loop"); + #ifdef CSV + itterator=0; + #endif + while (menuflag==1) { - #ifdef SLOW_TIME - printf(":=:"); - #endif - if (g_isr_flag == 1) { - pad.write_u16(out); - #ifdef SLOW_TIME - printf("out= %u\n",out); - #endif - out=sound.sound_main(false,submenu,440); - g_isr_flag=0; + if (noteon==true) { + if (g_isr_flag == 1) { + pad.write_u16(out); + + envelope_in=(sound.sound_main(false,submenu,440)-32767); //value around 0 +#ifdef SLOW_TIME + printf("SPEAKER VALUE = %u\n",out); + printf("\nENVELOPE IN = %d\n",envelope_in); +#endif + //out = envelope_in+32767; //skips envelope + out=(envelope.env_in(a,d,s,r,envelope_in,false)+32767);//value around 32767 + g_isr_flag=0; +#ifdef CSV + printf("%d,%d\n",itterator,out); + itterator++; +#endif } + } dir=pad.get_direction(); if (dir!=dir_1) { printf("dir =%d\n",dir); //debug @@ -146,20 +162,33 @@ r=incrament_adsr(used,r,-1); } } - - if (pad.start_pressed()) { //go back menu - // printf("start pressed\n"); - printf("Waveforms Sub selected\n"); //debug - wait_ms(200); //debounce - menuflag=0; //sets flag - } frontsetup(lcd,pad,submenu,false); printsliders(lcd,a,d,s,r,used); - wait_ms(200); + wait_ms(50); + } //END if DIR + if ( pad.A_pressed()) { //NOTE ON + printf("NOTE_ON\n"); + //wait_ms(200); //debounce + noteon=true; + out=envelope.env_in(a,d,s,r,out,true); + } + if ( pad.B_pressed()) { //NOTE OFF + printf("NOTE_OFF\n"); + //wait_ms(200); //debounce + noteon=false; + out=envelope.env_in(a,d,s,r,out,true); + } + + if (pad.start_pressed()) { //go back menu + // printf("start pressed\n"); + printf("Waveforms Sub selected\n"); //debug + noteon=false; + //wait_ms(200); //debounce + menuflag=0; //sets flag } dir=dir_1; sleep(); - } + }//end while() } //PRIVATE----------------------------------------------------------------------- @@ -168,6 +197,7 @@ { if (initial==true) { printsliders(lcd,17,17,17,17,1); + printf("front setup complete\n\n"); } lcd.clear(); lcd.printString("A D S R",3,5);