f303k8 wav player
Dependencies: SDFileSystem mbed
wavPlayer.h@4:6e56da5068f3, 2016-12-02 (annotated)
- Committer:
- nameless129
- Date:
- Fri Dec 02 03:58:42 2016 +0000
- Revision:
- 4:6e56da5068f3
- Parent:
- 2:203d58b06b0f
open
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 | 2:203d58b06b0f | 16 | void rampUp(void); |
nameless129 | 2:203d58b06b0f | 17 | void rampDown(void); |
nameless129 | 2:203d58b06b0f | 18 | |
nameless129 | 0:1561c4efda0e | 19 | private: |
nameless129 | 1:7a3f34b2d18b | 20 | struct st_streo16bit { |
nameless129 | 1:7a3f34b2d18b | 21 | uint16_t L; |
nameless129 | 1:7a3f34b2d18b | 22 | uint16_t R; |
nameless129 | 1:7a3f34b2d18b | 23 | }; |
nameless129 | 1:7a3f34b2d18b | 24 | struct st_streo8bit { |
nameless129 | 1:7a3f34b2d18b | 25 | uint8_t L; |
nameless129 | 1:7a3f34b2d18b | 26 | uint8_t R; |
nameless129 | 1:7a3f34b2d18b | 27 | }; |
nameless129 | 1:7a3f34b2d18b | 28 | |
nameless129 | 1:7a3f34b2d18b | 29 | union { |
nameless129 | 1:7a3f34b2d18b | 30 | uint8_t raw[WAV_READ_SIZE]; |
nameless129 | 1:7a3f34b2d18b | 31 | st_streo16bit stereo16bit[WAV_READ_SIZE/4]; |
nameless129 | 1:7a3f34b2d18b | 32 | uint16_t mono16bit[WAV_READ_SIZE/2]; |
nameless129 | 1:7a3f34b2d18b | 33 | st_streo8bit stereo8bit[WAV_READ_SIZE/2]; |
nameless129 | 1:7a3f34b2d18b | 34 | uint8_t mono8bit[WAV_READ_SIZE]; |
nameless129 | 1:7a3f34b2d18b | 35 | } wavReadData; |
nameless129 | 1:7a3f34b2d18b | 36 | |
nameless129 | 1:7a3f34b2d18b | 37 | uint16_t DACData[2][WAV_READ_SIZE]; |
nameless129 | 1:7a3f34b2d18b | 38 | FIL wavfil; |
nameless129 | 1:7a3f34b2d18b | 39 | uint8_t dac_c; |
nameless129 | 1:7a3f34b2d18b | 40 | uint16_t dac_rp; |
nameless129 | 1:7a3f34b2d18b | 41 | bool dac_flag[2]; |
nameless129 | 1:7a3f34b2d18b | 42 | uint16_t dacEndReadPos; |
nameless129 | 1:7a3f34b2d18b | 43 | uint16_t dacBuffIndex_n; |
nameless129 | 1:7a3f34b2d18b | 44 | uint8_t fWavPlaying; |
nameless129 | 1:7a3f34b2d18b | 45 | bool dac_on; |
nameless129 | 1:7a3f34b2d18b | 46 | uint16_t wavBitsWidth; |
nameless129 | 1:7a3f34b2d18b | 47 | uint8_t wavChannels; |
nameless129 | 1:7a3f34b2d18b | 48 | |
nameless129 | 1:7a3f34b2d18b | 49 | RIFFHedder_s wavRIFFHedder; |
nameless129 | 1:7a3f34b2d18b | 50 | BextChunk_s wavBextChunk; |
nameless129 | 1:7a3f34b2d18b | 51 | FormatChunk_s wavFormatChunk; |
nameless129 | 1:7a3f34b2d18b | 52 | DataChunk_s wavDataChunk; |
nameless129 | 1:7a3f34b2d18b | 53 | |
nameless129 | 1:7a3f34b2d18b | 54 | AnalogOut DACout; |
nameless129 | 1:7a3f34b2d18b | 55 | |
nameless129 | 1:7a3f34b2d18b | 56 | uint8_t seaechChunk(FIL *fp,char chunk[5]); |
nameless129 | 1:7a3f34b2d18b | 57 | void storeWavDatatoBuff(uint8_t selectBufNo); |
nameless129 | 0:1561c4efda0e | 58 | }; |