Demo of Embedded Artists LPCXpresso baseboard SD card reader and audio facilities. Updated to put wav file player in a separate library and use the high capacity SD card library provided by Klaus Bu.

Dependencies:   mbed

Committer:
tom_coxon
Date:
Sun Jul 25 17:51:19 2010 +0000
Revision:
2:affcc36a50b4

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tom_coxon 2:affcc36a50b4 1 /*
tom_coxon 2:affcc36a50b4 2 Library wave file player by Tom Coxon
tom_coxon 2:affcc36a50b4 3
tom_coxon 2:affcc36a50b4 4 Based on WAVEplayer by Vlad Cazan/Stephan Rochon modified by Tom Coxon to:
tom_coxon 2:affcc36a50b4 5
tom_coxon 2:affcc36a50b4 6 1. Run correctly on the Embedded Artists LPCXpresso baseboard.
tom_coxon 2:affcc36a50b4 7 2. To play 8 bit sample size in addition to original 16 bit
tom_coxon 2:affcc36a50b4 8 3. To be more fault tolerant when playing wav files.
tom_coxon 2:affcc36a50b4 9 */
tom_coxon 2:affcc36a50b4 10
tom_coxon 2:affcc36a50b4 11 #ifndef WAVPLAYER_H
tom_coxon 2:affcc36a50b4 12 #define WAVPLAYER_H
tom_coxon 2:affcc36a50b4 13
tom_coxon 2:affcc36a50b4 14 #include "mbed.h"
tom_coxon 2:affcc36a50b4 15
tom_coxon 2:affcc36a50b4 16 #define SAMPLE_FREQ 40000
tom_coxon 2:affcc36a50b4 17 #define BUF_SIZE (SAMPLE_FREQ/10)
tom_coxon 2:affcc36a50b4 18 #define SLICE_BUF_SIZE 1
tom_coxon 2:affcc36a50b4 19
tom_coxon 2:affcc36a50b4 20 typedef struct uFMT_STRUCT {
tom_coxon 2:affcc36a50b4 21 short comp_code;
tom_coxon 2:affcc36a50b4 22 short num_channels;
tom_coxon 2:affcc36a50b4 23 unsigned sample_rate;
tom_coxon 2:affcc36a50b4 24 unsigned avg_Bps;
tom_coxon 2:affcc36a50b4 25 short block_align;
tom_coxon 2:affcc36a50b4 26 short sig_bps;
tom_coxon 2:affcc36a50b4 27 } FMT_STRUCT;
tom_coxon 2:affcc36a50b4 28
tom_coxon 2:affcc36a50b4 29 class WavPlayer {
tom_coxon 2:affcc36a50b4 30
tom_coxon 2:affcc36a50b4 31 public:
tom_coxon 2:affcc36a50b4 32
tom_coxon 2:affcc36a50b4 33 void play_wave(char *wavname);
tom_coxon 2:affcc36a50b4 34
tom_coxon 2:affcc36a50b4 35 private:
tom_coxon 2:affcc36a50b4 36
tom_coxon 2:affcc36a50b4 37 void cleanup(char *);
tom_coxon 2:affcc36a50b4 38 void fill_adc_buf(short *, unsigned);
tom_coxon 2:affcc36a50b4 39 void swapword(unsigned *);
tom_coxon 2:affcc36a50b4 40
tom_coxon 2:affcc36a50b4 41 // a FIFO for the DAC
tom_coxon 2:affcc36a50b4 42 short DAC_fifo[256];
tom_coxon 2:affcc36a50b4 43 short DAC_wptr;
tom_coxon 2:affcc36a50b4 44 short DAC_rptr;
tom_coxon 2:affcc36a50b4 45 short DAC_on;
tom_coxon 2:affcc36a50b4 46
tom_coxon 2:affcc36a50b4 47 void dac_out();
tom_coxon 2:affcc36a50b4 48
tom_coxon 2:affcc36a50b4 49 };
tom_coxon 2:affcc36a50b4 50
tom_coxon 2:affcc36a50b4 51 #endif