This program is for Star Board Orange. Wave file into SD card is read, and its DAC signal output.

Dependencies:   EthernetNetIf mbed HTTPServer

Committer:
y_notsu
Date:
Thu Nov 25 14:59:16 2010 +0000
Revision:
0:383bff20e783

        

Who changed what in which revision?

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