kevvy

Fork of wave_player by Steve Ravet

Revision:
2:f929c2145e32
Parent:
0:62c18ade9a60
--- 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) {
           }