f303k8 wav player
Dependencies: SDFileSystem mbed
wavPlayer.h@1:7a3f34b2d18b, 2016-08-11 (annotated)
- Committer:
- nameless129
- Date:
- Thu Aug 11 08:29:22 2016 +0000
- Revision:
- 1:7a3f34b2d18b
- Parent:
- 0:1561c4efda0e
- Child:
- 2:203d58b06b0f
16bit??????,8bit????????
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
nameless129 | 0:1561c4efda0e | 1 | #include <stdio.h> |
nameless129 | 0:1561c4efda0e | 2 | #include "SDFileSystem.h" |
nameless129 | 0:1561c4efda0e | 3 | #include "wavChunks.h" |
nameless129 | 0:1561c4efda0e | 4 | |
nameless129 | 1:7a3f34b2d18b | 5 | #define WAV_READ_SIZE (512) |
nameless129 | 0:1561c4efda0e | 6 | |
nameless129 | 0:1561c4efda0e | 7 | class wavPlayerOnDAC { |
nameless129 | 0:1561c4efda0e | 8 | public: |
nameless129 | 0:1561c4efda0e | 9 | wavPlayerOnDAC(PinName pinDAC); |
nameless129 | 0:1561c4efda0e | 10 | void setFile(FIL* tgtFile); |
nameless129 | 0:1561c4efda0e | 11 | uint8_t readProc(void); |
nameless129 | 0:1561c4efda0e | 12 | void rewind(void); |
nameless129 | 0:1561c4efda0e | 13 | void stop(void); |
nameless129 | 0:1561c4efda0e | 14 | void DACOutProc(void); |
nameless129 | 1:7a3f34b2d18b | 15 | void setParameters(uint16_t bitsWidth,uint8_t ch); |
nameless129 | 0:1561c4efda0e | 16 | private: |
nameless129 | 1:7a3f34b2d18b | 17 | struct st_streo16bit { |
nameless129 | 1:7a3f34b2d18b | 18 | uint16_t L; |
nameless129 | 1:7a3f34b2d18b | 19 | uint16_t R; |
nameless129 | 1:7a3f34b2d18b | 20 | }; |
nameless129 | 1:7a3f34b2d18b | 21 | struct st_streo8bit { |
nameless129 | 1:7a3f34b2d18b | 22 | uint8_t L; |
nameless129 | 1:7a3f34b2d18b | 23 | uint8_t R; |
nameless129 | 1:7a3f34b2d18b | 24 | }; |
nameless129 | 1:7a3f34b2d18b | 25 | |
nameless129 | 1:7a3f34b2d18b | 26 | union { |
nameless129 | 1:7a3f34b2d18b | 27 | uint8_t raw[WAV_READ_SIZE]; |
nameless129 | 1:7a3f34b2d18b | 28 | st_streo16bit stereo16bit[WAV_READ_SIZE/4]; |
nameless129 | 1:7a3f34b2d18b | 29 | uint16_t mono16bit[WAV_READ_SIZE/2]; |
nameless129 | 1:7a3f34b2d18b | 30 | st_streo8bit stereo8bit[WAV_READ_SIZE/2]; |
nameless129 | 1:7a3f34b2d18b | 31 | uint8_t mono8bit[WAV_READ_SIZE]; |
nameless129 | 1:7a3f34b2d18b | 32 | } wavReadData; |
nameless129 | 1:7a3f34b2d18b | 33 | |
nameless129 | 1:7a3f34b2d18b | 34 | uint16_t DACData[2][WAV_READ_SIZE]; |
nameless129 | 1:7a3f34b2d18b | 35 | FIL wavfil; |
nameless129 | 1:7a3f34b2d18b | 36 | uint8_t dac_c; |
nameless129 | 1:7a3f34b2d18b | 37 | uint16_t dac_rp; |
nameless129 | 1:7a3f34b2d18b | 38 | bool dac_flag[2]; |
nameless129 | 1:7a3f34b2d18b | 39 | uint16_t dacEndReadPos; |
nameless129 | 1:7a3f34b2d18b | 40 | uint16_t dacBuffIndex_n; |
nameless129 | 1:7a3f34b2d18b | 41 | uint8_t fWavPlaying; |
nameless129 | 1:7a3f34b2d18b | 42 | bool dac_on; |
nameless129 | 1:7a3f34b2d18b | 43 | uint16_t wavBitsWidth; |
nameless129 | 1:7a3f34b2d18b | 44 | uint8_t wavChannels; |
nameless129 | 1:7a3f34b2d18b | 45 | |
nameless129 | 1:7a3f34b2d18b | 46 | RIFFHedder_s wavRIFFHedder; |
nameless129 | 1:7a3f34b2d18b | 47 | BextChunk_s wavBextChunk; |
nameless129 | 1:7a3f34b2d18b | 48 | FormatChunk_s wavFormatChunk; |
nameless129 | 1:7a3f34b2d18b | 49 | DataChunk_s wavDataChunk; |
nameless129 | 1:7a3f34b2d18b | 50 | |
nameless129 | 1:7a3f34b2d18b | 51 | AnalogOut DACout; |
nameless129 | 1:7a3f34b2d18b | 52 | |
nameless129 | 1:7a3f34b2d18b | 53 | uint8_t seaechChunk(FIL *fp,char chunk[5]); |
nameless129 | 1:7a3f34b2d18b | 54 | void storeWavDatatoBuff(uint8_t selectBufNo); |
nameless129 | 0:1561c4efda0e | 55 | }; |