#include "Wave.h" using namespace Audio; #ifdef __cplusplus extern "C" { #endif int AlsaConfigure(void); int AlsaPlay(void *DataToBeWritten, int DataSizeToWrite); #ifdef __cplusplus } #endif int main(){ Wave wfile; std::string s="/home/brian/Desktop/Water_Splash.wav"; wfile.Open(s); AlsaConfigure(); unsigned int n=0; long m = wfile.GetSize()/40; char DestBuffer[m]; uint32 SizeRead=0; memset(DestBuffer, 0, m ); while (n < wfile.GetSize()){ //Get some data from the wave file. if(wfile.Read(DestBuffer, m, &SizeRead)){ if(SizeRead) //we only read some of what we wanted, write it to the device. AlsaPlay(DestBuffer, SizeRead); else //we read m bytes, write it to the device. AlsaPlay(DestBuffer, m); //increment n n += m; }else{ //Are we at the eof? if(wfile.IsEOF()) fprintf(stderr, "We are at the end of the file.\n"); //how much data did we get if(SizeRead > 0){ //we got what we were looking for so write it to the device. AlsaPlay((short*)DestBuffer, SizeRead); //increment n n += SizeRead; } } } wfile.Close(); return 0; }