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.
Diff: Front/Front.cpp
- Revision:
- 28:eb0f12304a45
- Parent:
- 27:da783f414f67
- Child:
- 29:207111ffd6e6
--- a/Front/Front.cpp Sun May 24 21:13:36 2020 +0000 +++ b/Front/Front.cpp Mon May 25 10:46:02 2020 +0000 @@ -155,13 +155,14 @@ //printf("G_ISR_FLAG= %d\n",g_isr_flag); //DEBUG frontsetup(lcd, pad, submenu,0, true); //Initialises front pannel display initialise(pad,lcd,submenu); - frequency=frequency_convert(pad); + frequency=frequency_convert(pad,oct); menuflag=1; //sets up flags release_flag=silent_flag=0; used=1; //initialises vairables filter_type=envelope_in=0; a=d=s=r=17; //starting adsr values (1->35) noteon=false; + oct=3; #ifdef CSV itterator=0; //sets itterator for CSV OUTPUT #endif @@ -253,7 +254,7 @@ printf("NOTE_ON\n"); noteon=true; out=envelope.env_in(a,d,s,r,out,true); - frequency=frequency_convert(pad); + frequency=frequency_convert(pad,oct); } if ( pad.B_pressed()) { //NOTE OFF //printf("NOTE_OFF (W.release)\n"); @@ -261,12 +262,16 @@ envelope_in=envelope.release(s,r,envelope_in,true); pad.reset_buttons(); } - if ( pad.X_pressed()) { - printf("X\n"); + if ( pad.X_pressed()) { + oct--; + if (oct<0) {oct++;} + printf("OCTAVE %d\n",oct); pad.reset_buttons(); } if ( pad.Y_pressed()) { - printf("Y\n"); + oct++; + if (oct>5) {oct--;} + printf("OCTAVE %d\n",oct); pad.reset_buttons(); } @@ -453,9 +458,10 @@ return(adsr); } -int Front::frequency_convert(Gamepad &pad) -{ - frequency=(440+(pad.read_pot1()*440)); +int Front::frequency_convert(Gamepad &pad,int oct) +{ + frequency=55*(pow(2.0,oct)); + frequency=(frequency+(pad.read_pot1()*frequency)); return(frequency); }