Christian Lerche
/
EA_DoorPlayer
EA BaseBoard, playing wav, PC see\'s SD-card through USB port.
wavplayer.h@0:fef366d2ed20, 2011-11-22 (annotated)
- Committer:
- Lerche
- Date:
- Tue Nov 22 05:45:58 2011 +0000
- Revision:
- 0:fef366d2ed20
Thanks to those who provided EA_WavPlayer and USB_MSC
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Lerche | 0:fef366d2ed20 | 1 | /* |
Lerche | 0:fef366d2ed20 | 2 | Library wave file player by Tom Coxon |
Lerche | 0:fef366d2ed20 | 3 | |
Lerche | 0:fef366d2ed20 | 4 | Based on WAVEplayer by Vlad Cazan/Stephan Rochon modified by Tom Coxon to: |
Lerche | 0:fef366d2ed20 | 5 | |
Lerche | 0:fef366d2ed20 | 6 | 1. Run correctly on the Embedded Artists LPCXpresso baseboard. |
Lerche | 0:fef366d2ed20 | 7 | 2. To play 8 bit sample size in addition to original 16 bit |
Lerche | 0:fef366d2ed20 | 8 | 3. To be more fault tolerant when playing wav files. |
Lerche | 0:fef366d2ed20 | 9 | */ |
Lerche | 0:fef366d2ed20 | 10 | |
Lerche | 0:fef366d2ed20 | 11 | #ifndef WAVPLAYER_H |
Lerche | 0:fef366d2ed20 | 12 | #define WAVPLAYER_H |
Lerche | 0:fef366d2ed20 | 13 | |
Lerche | 0:fef366d2ed20 | 14 | #include "mbed.h" |
Lerche | 0:fef366d2ed20 | 15 | |
Lerche | 0:fef366d2ed20 | 16 | #define SAMPLE_FREQ 40000 |
Lerche | 0:fef366d2ed20 | 17 | #define BUF_SIZE (SAMPLE_FREQ/10) |
Lerche | 0:fef366d2ed20 | 18 | #define SLICE_BUF_SIZE 1 |
Lerche | 0:fef366d2ed20 | 19 | |
Lerche | 0:fef366d2ed20 | 20 | typedef struct uFMT_STRUCT { |
Lerche | 0:fef366d2ed20 | 21 | short comp_code; |
Lerche | 0:fef366d2ed20 | 22 | short num_channels; |
Lerche | 0:fef366d2ed20 | 23 | unsigned sample_rate; |
Lerche | 0:fef366d2ed20 | 24 | unsigned avg_Bps; |
Lerche | 0:fef366d2ed20 | 25 | short block_align; |
Lerche | 0:fef366d2ed20 | 26 | short sig_bps; |
Lerche | 0:fef366d2ed20 | 27 | } FMT_STRUCT; |
Lerche | 0:fef366d2ed20 | 28 | |
Lerche | 0:fef366d2ed20 | 29 | class WavPlayer { |
Lerche | 0:fef366d2ed20 | 30 | |
Lerche | 0:fef366d2ed20 | 31 | public: |
Lerche | 0:fef366d2ed20 | 32 | |
Lerche | 0:fef366d2ed20 | 33 | void play_wave(char *wavname); |
Lerche | 0:fef366d2ed20 | 34 | |
Lerche | 0:fef366d2ed20 | 35 | private: |
Lerche | 0:fef366d2ed20 | 36 | |
Lerche | 0:fef366d2ed20 | 37 | void cleanup(char *); |
Lerche | 0:fef366d2ed20 | 38 | void fill_adc_buf(short *, unsigned); |
Lerche | 0:fef366d2ed20 | 39 | void swapword(unsigned *); |
Lerche | 0:fef366d2ed20 | 40 | |
Lerche | 0:fef366d2ed20 | 41 | // a FIFO for the DAC |
Lerche | 0:fef366d2ed20 | 42 | short DAC_fifo[256]; |
Lerche | 0:fef366d2ed20 | 43 | short DAC_wptr; |
Lerche | 0:fef366d2ed20 | 44 | short DAC_rptr; |
Lerche | 0:fef366d2ed20 | 45 | short DAC_on; |
Lerche | 0:fef366d2ed20 | 46 | |
Lerche | 0:fef366d2ed20 | 47 | void dac_out(); |
Lerche | 0:fef366d2ed20 | 48 | |
Lerche | 0:fef366d2ed20 | 49 | }; |
Lerche | 0:fef366d2ed20 | 50 | |
Lerche | 0:fef366d2ed20 | 51 | #endif |