A simple example of WAV playback for the RS AudioCODEC board. Uses a USB drive to stream music.
Dependencies: FatFileSystem MSCFileSystem WavPlayer mbed
Fork of WavPlayer_test by
main.cpp@4:0e55cf186330, 2012-09-25 (annotated)
- Committer:
- p07gbar
- Date:
- Tue Sep 25 14:55:00 2012 +0000
- Revision:
- 4:0e55cf186330
- Parent:
- 3:e03854cb5cef
Wording in header changed
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
p07gbar | 4:0e55cf186330 | 1 | // This is all set up for the AudioCODEC board on the AnimatronicLAB board (RS Product Code 754-1965): Just plug a memory stick |
p07gbar | 4:0e55cf186330 | 2 | // with a wav file called test.wav on it (such as the one you can get from: https://mbed.org/media/uploads/p07gbar/test.wav) |
p07gbar | 3:e03854cb5cef | 3 | // and have a listen! Any 16bit PCM Wav files with channel*sample rate less than 48kHz should work. |
p07gbar | 0:d49f4c0f2ba7 | 4 | |
p07gbar | 0:d49f4c0f2ba7 | 5 | #include "mbed.h" |
p07gbar | 0:d49f4c0f2ba7 | 6 | #include "WavPlayer.h" |
p07gbar | 0:d49f4c0f2ba7 | 7 | #include "MSCFileSystem.h" |
p07gbar | 0:d49f4c0f2ba7 | 8 | |
p07gbar | 0:d49f4c0f2ba7 | 9 | MSCFileSystem msc("msc"); // Mount flash drive under the name "msc" |
p07gbar | 0:d49f4c0f2ba7 | 10 | WavPlayer player; |
p07gbar | 0:d49f4c0f2ba7 | 11 | |
p07gbar | 0:d49f4c0f2ba7 | 12 | int main() { |
p07gbar | 0:d49f4c0f2ba7 | 13 | FILE *fp = fopen("/msc/test.wav", "r"); // Open "out.txt" on the local file system for writing |
p07gbar | 0:d49f4c0f2ba7 | 14 | player.open(&fp); |
p07gbar | 0:d49f4c0f2ba7 | 15 | player.play(); |
p07gbar | 0:d49f4c0f2ba7 | 16 | fclose(fp); |
p07gbar | 0:d49f4c0f2ba7 | 17 | } |