Philips Philips
/
microphonetospeaker
Read samples from analog input ADC and outputs to DAC,outputs to speaker, like a karaoke machine lol
Revision 0:32b3a9352bd2, committed 2011-05-28
- Comitter:
- mbed2f
- Date:
- Sat May 28 01:08:01 2011 +0000
- Commit message:
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r 32b3a9352bd2 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sat May 28 01:08:01 2011 +0000 @@ -0,0 +1,22 @@ +#include "mbed.h" + +/* ADC for the microphone/input, DAC for the speaker/output */ +AnalogIn mic(p19); +AnalogOut speaker(p18); + +#define NUM_SAMPLES 15000 +unsigned short buffer[NUM_SAMPLES]; + +int main() +{ + int i; + for (i = 0; ; ) // infinite loop + { + /* read mike */ + buffer[i] = mic.read_u16(); + /* Write to speaker */ + speaker.write_u16(buffer[i]); + /* Increment index and wrap around */ + i = (i+1) % NUM_SAMPLES; + } +} \ No newline at end of file
diff -r 000000000000 -r 32b3a9352bd2 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sat May 28 01:08:01 2011 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/e2ac27c8e93e