Mike Pollock / Mbed 2 deprecated WavFileplayerForFido

Dependencies:   SDFileSystem mbed wave_player_appbd

Fork of AppBoard_Waveplayer by jim hamblen

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "wave_player.h"
00003 #include "SDFileSystem.h"
00004 
00005 //mbed Application board waveplayer demo
00006 //Plays the wave file "sample.wav" on the SD drive
00007 //Outputs to p18 analogue out to an audio amp and speaker 
00008 
00009  
00010 //Analog Out Jack
00011 AnalogOut DACout(p18);
00012 //On Board Speaker
00013 PwmOut PWMout(p26);
00014 
00015 //SD card
00016 SDFileSystem sd(p5, p6, p7, p8, "sd"); // the pinout on the mbed Cool Components workshop board
00017 
00018 DigitalOut led1(LED1);
00019 DigitalOut led2(LED2);
00020 DigitalOut led3(LED3);
00021 DigitalOut led4(LED4);
00022 
00023 wave_player waver(&DACout,&PWMout);
00024 
00025 int main()
00026 {
00027    char buffer[20];
00028     FILE *wave_file;
00029     //setup PWM hardware for a Class D style audio output
00030     PWMout.period(1.0/400000.0);
00031   while(1){
00032     led1=1;
00033     led2=0;
00034     led3=1;
00035     led4=0;
00036      
00037     for (int a=1;a<40; a++){
00038     sprintf(buffer,"/sd/voice%d.wav",a);    
00039     wave_file=fopen(buffer,"r");
00040     waver.play(wave_file);
00041     fclose(wave_file);
00042     if (a%2!=0){
00043     led1= !led1;
00044     led2= !led2;
00045     led3= !led3;
00046     led4= !led4;
00047      }
00048     }
00049     
00050   }
00051 }