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: main.cpp
- Revision:
- 1:9a283811050f
- Parent:
- 0:ff0b6f6ddb23
- Child:
- 3:90f8e68fa422
diff -r ff0b6f6ddb23 -r 9a283811050f main.cpp --- a/main.cpp Wed Nov 11 19:16:20 2015 +0000 +++ b/main.cpp Thu Nov 26 22:48:02 2015 +0000 @@ -15,8 +15,8 @@ #define BUFFERSIZE 30000 // Sample rate 10 Khz, 3 sec record 30*10^3 samples uint16_t ABuffer[BUFFERSIZE]={0}; // variables to store buffer position and lenght -uint32_t BufferEnd=0; -uint32_t Buffer_i=0; +int BufferEnd=0; +int Buffer_i=0; bool RecordFull=0; // Variable to store button state bool ButtonState=0; @@ -60,7 +60,7 @@ CurY=AHPF*(LastY+CurU-LastU); // Amplify, add dc offset and add to buffer; - AudioSignal=CurY*3.0f+0.5f;//*10.0f+0.5f); + AudioSignal=CurY*2.0f+0.5f;//*10.0f+0.5f); if (AudioSignal>1){ AudioSignal=1; }else if (AudioSignal<0){ @@ -94,17 +94,17 @@ }else if (ButtonState) { //Button is unpressed if (!LastButtonState){ // first sample // Re-set Ticker object - Audio_Sample_Ticker.attach_us(&Audio_Sample, 75); // create 10Khz Ticker - // Buffer_i=0; + Audio_Sample_Ticker.attach_us(&Audio_Sample, 150); // create 10Khz Ticker + Buffer_i=BufferEnd; } myled.write(0); // LED Off // Play Recorded audio RecordFull=0; - if (Buffer_i>BufferEnd){ // Replay record - Buffer_i=0; + if (Buffer_i<=0){ // Replay record + Buffer_i=BufferEnd; } AudioOut.write_u16(ABuffer[Buffer_i]); - Buffer_i++; + Buffer_i--; } } }