for alarm program
Fork of wave_player by
Revision 2:69c7fc62c0ef, committed 2014-12-02
- Comitter:
- jhawkins38
- Date:
- Tue Dec 02 15:19:55 2014 +0000
- Parent:
- 1:acc3e18e77ad
- Commit message:
- for alarm, passed pointers play and vol
Changed in this revision
wave_player.cpp | Show annotated file Show diff for this revision Revisions of this file |
wave_player.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r acc3e18e77ad -r 69c7fc62c0ef wave_player.cpp --- a/wave_player.cpp Tue Jan 18 03:57:27 2011 +0000 +++ b/wave_player.cpp Tue Dec 02 15:19:55 2014 +0000 @@ -44,7 +44,7 @@ // SDcard filesystem can be hotrodded by increasing the SPI frequency it uses // internally. //----------------------------------------------------------------------------- -void wave_player::play(FILE *wavefile) +void wave_player::play(FILE *wavefile, volatile bool *play_ptr /*, volatile int *volume_ptr //JJH*/) { unsigned chunk_id,chunk_size,channel; unsigned data,samp_int,i; @@ -67,7 +67,7 @@ fread(&chunk_id,4,1,wavefile); fread(&chunk_size,4,1,wavefile); - while (!feof(wavefile)) { + while (!feof(wavefile) && *play_ptr == true) { if (verbosity) printf("Read chunk ID 0x%x, size 0x%x\n",chunk_id,chunk_size); switch (chunk_id) { @@ -129,6 +129,8 @@ // while 16 and 32 bit wave files use signed data // for (slice=0;slice<num_slices;slice+=1) { + if(*play_ptr == false) + break; fread(slice_buf,wav_format.block_align,1,wavefile); if (feof(wavefile)) { printf("Oops -- not enough slices in the wave file\n"); @@ -173,7 +175,11 @@ dac_data=(short unsigned)slice_value; if (verbosity) printf("sample %d wptr %d slice_value %d dac_data %u\n",slice,DAC_wptr,(int)slice_value,dac_data); - DAC_fifo[DAC_wptr]=dac_data; + + // Scale data according to volume + // dac_data = (dac_data * (16 - *volume_ptr)) / 16; //JJH + DAC_fifo[DAC_wptr]= dac_data; + DAC_wptr=(DAC_wptr+1) & 0xff; while (DAC_wptr==DAC_rptr) { }
diff -r acc3e18e77ad -r 69c7fc62c0ef wave_player.h --- a/wave_player.h Tue Jan 18 03:57:27 2011 +0000 +++ b/wave_player.h Tue Dec 02 15:19:55 2014 +0000 @@ -43,7 +43,7 @@ * * @param wavefile A pointer to an opened wave file */ -void play(FILE *wavefile); +void play(FILE *wavefile, volatile bool *play_ptr /*, volatile int *volume_ptr*/); /** Set the printf verbosity of the wave player. A nonzero verbosity level * will put wave_player in a mode where the complete contents of the wave