f303k8 wav player
Dependencies: SDFileSystem mbed
Diff: wavPlayer.h
- Revision:
- 1:7a3f34b2d18b
- Parent:
- 0:1561c4efda0e
- Child:
- 2:203d58b06b0f
--- a/wavPlayer.h Sun Jul 31 12:13:36 2016 +0000 +++ b/wavPlayer.h Thu Aug 11 08:29:22 2016 +0000 @@ -2,28 +2,54 @@ #include "SDFileSystem.h" #include "wavChunks.h" -#define WAV_READ_SIZE (1024) +#define WAV_READ_SIZE (512) class wavPlayerOnDAC { public: - uint16_t DACData[2][WAV_READ_SIZE]; - volatile uint16_t rp; - bool dac_flag[2]; - bool dac_on; - uint8_t dac_c; - - FIL wavfil; - uint16_t wavReadData[WAV_READ_SIZE]; - uint32_t wavReadByte; - uint8_t fWavPlaying; - wavPlayerOnDAC(PinName pinDAC); void setFile(FIL* tgtFile); uint8_t readProc(void); void rewind(void); void stop(void); void DACOutProc(void); - + void setParameters(uint16_t bitsWidth,uint8_t ch); private: - AnalogOut DACout; + struct st_streo16bit { + uint16_t L; + uint16_t R; + }; + struct st_streo8bit { + uint8_t L; + uint8_t R; + }; + + union { + uint8_t raw[WAV_READ_SIZE]; + st_streo16bit stereo16bit[WAV_READ_SIZE/4]; + uint16_t mono16bit[WAV_READ_SIZE/2]; + st_streo8bit stereo8bit[WAV_READ_SIZE/2]; + uint8_t mono8bit[WAV_READ_SIZE]; + } wavReadData; + + uint16_t DACData[2][WAV_READ_SIZE]; + FIL wavfil; + uint8_t dac_c; + uint16_t dac_rp; + bool dac_flag[2]; + uint16_t dacEndReadPos; + uint16_t dacBuffIndex_n; + uint8_t fWavPlaying; + bool dac_on; + uint16_t wavBitsWidth; + uint8_t wavChannels; + + RIFFHedder_s wavRIFFHedder; + BextChunk_s wavBextChunk; + FormatChunk_s wavFormatChunk; + DataChunk_s wavDataChunk; + + AnalogOut DACout; + + uint8_t seaechChunk(FIL *fp,char chunk[5]); + void storeWavDatatoBuff(uint8_t selectBufNo); };