mbed based wave player
Dependencies: wave_player mbed
Fork of SDFileSystem_HelloWorld by
main.cpp@2:ea62438661bf, 2018-07-19 (annotated)
- Committer:
- berzin11295
- Date:
- Thu Jul 19 18:02:37 2018 +0000
- Revision:
- 2:ea62438661bf
- Parent:
- 0:bdbd3d6fc5d5
mbed based wave player
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 0:bdbd3d6fc5d5 | 1 | #include "mbed.h" |
mbed_official | 0:bdbd3d6fc5d5 | 2 | #include "SDFileSystem.h" |
berzin11295 | 2:ea62438661bf | 3 | #include "WavPlayer.h" |
mbed_official | 0:bdbd3d6fc5d5 | 4 | |
berzin11295 | 2:ea62438661bf | 5 | SDFileSystem sd(PC_12,PC_11,PC_10,PD_2,"sd"); // the pinout on the mbed Cool Components workshop board |
berzin11295 | 2:ea62438661bf | 6 | |
berzin11295 | 2:ea62438661bf | 7 | AnalogOut dac(PA_5); |
berzin11295 | 2:ea62438661bf | 8 | DigitalOut enb(PA_12); |
berzin11295 | 2:ea62438661bf | 9 | WavPlayer player(&dac, &enb); |
berzin11295 | 2:ea62438661bf | 10 | |
mbed_official | 0:bdbd3d6fc5d5 | 11 | int main() { |
mbed_official | 0:bdbd3d6fc5d5 | 12 | printf("Hello World!\n"); |
mbed_official | 0:bdbd3d6fc5d5 | 13 | |
berzin11295 | 2:ea62438661bf | 14 | FILE *fp = fopen("/sd/voices/hello_0.wav", "r"); |
mbed_official | 0:bdbd3d6fc5d5 | 15 | if(fp == NULL) { |
berzin11295 | 2:ea62438661bf | 16 | error("Could not open file for read\n"); |
mbed_official | 0:bdbd3d6fc5d5 | 17 | } |
berzin11295 | 2:ea62438661bf | 18 | |
berzin11295 | 2:ea62438661bf | 19 | player.play(fp); |
berzin11295 | 2:ea62438661bf | 20 | |
berzin11295 | 2:ea62438661bf | 21 | fclose(fp); |
berzin11295 | 2:ea62438661bf | 22 | printf("Bye World!\n"); |
berzin11295 | 2:ea62438661bf | 23 | } |