kevvy

Fork of wave_player by Steve Ravet

Files at this revision

API Documentation at this revision

Comitter:
rproctor6
Date:
Wed Sep 30 20:09:33 2015 +0000
Parent:
1:acc3e18e77ad
Commit message:
kevins a bab;

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
--- a/wave_player.cpp	Tue Jan 18 03:57:27 2011 +0000
+++ b/wave_player.cpp	Wed Sep 30 20:09:33 2015 +0000
@@ -37,6 +37,7 @@
   verbosity=v;
 }
 
+
 //-----------------------------------------------------------------------------
 // player function.  Takes a pointer to an opened wave file.  The file needs
 // to be stored in a filesystem with enough bandwidth to feed the wave data.
@@ -44,7 +45,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, int& mode, int& vol)
 {
         unsigned chunk_id,chunk_size,channel;
         unsigned data,samp_int,i;
@@ -129,6 +130,7 @@
 // while 16 and 32 bit wave files use signed data
 //
         for (slice=0;slice<num_slices;slice+=1) {
+        if (mode==0){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,7 @@
           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;
+          DAC_fifo[DAC_wptr]=dac_data*(16-vol)>>4;
           DAC_wptr=(DAC_wptr+1) & 0xff;
           while (DAC_wptr==DAC_rptr) {
           }
--- a/wave_player.h	Tue Jan 18 03:57:27 2011 +0000
+++ b/wave_player.h	Wed Sep 30 20:09:33 2015 +0000
@@ -43,7 +43,7 @@
  *
  * @param wavefile  A pointer to an opened wave file
  */
-void play(FILE *wavefile);
+void play(FILE *wavefile, int& mode, int& vol);
 
 /** 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
@@ -61,6 +61,7 @@
 private:
 void dac_out(void);
 int verbosity;
+int mode;
 AnalogOut *wave_DAC;
 Ticker tick;
 unsigned short DAC_fifo[256];