Edited version of the wave player class that uses the MODDMA library to handle transfers to the DAC.

Dependencies:   MODDMA

Dependents:   WavePlayer_MODDMA wave_player_DMA_mbed

Embed: (wiki syntax)

« Back to documentation index

wave_player Class Reference

wave_player Class Reference

wave file player class. More...

#include <wave_player.h>

Public Member Functions

 wave_player (AnalogOut *_dac)
 Create a wave player using a pointer to the given AnalogOut object.
void play (FILE *wavefile)
 the player function.
void set_verbosity (int v)
 Set the printf verbosity of the wave player.

Detailed Description

wave file player class.

Example:

 #include <mbed.h>
 #include <wave_player.h>

 AnalogOut DACout(p18);
 wave_player waver(&DACout);

 int main() {
  FILE *wave_file;
  
  printf("\n\n\nHello, wave world!\n");
  wave_file=fopen("/sd/44_8_st.wav","r");
  waver.play(wave_file);
  fclose(wave_file); 
 }

Definition at line 36 of file wave_player.h.


Constructor & Destructor Documentation

wave_player ( AnalogOut *  _dac )

Create a wave player using a pointer to the given AnalogOut object.

Parameters:
_dacpointer to an AnalogOut object to which the samples are sent.

Definition at line 30 of file wave_player.cpp.


Member Function Documentation

void play ( FILE *  wavefile )

the player function.

Parameters:
wavefileA pointer to an opened wave file

Definition at line 56 of file wave_player.cpp.

void set_verbosity ( int  v )

Set the printf verbosity of the wave player.

A nonzero verbosity level will put wave_player in a mode where the complete contents of the wave file are echoed to the screen, including header values, and including all of the sample values placed into the DAC FIFO, and the sample values removed from the DAC FIFO by the ISR. The sample output frequency is fixed at 2 Hz in this mode, so it's all very slow and the DAC output isn't very useful, but it lets you see what's going on and may help for debugging wave files that don't play correctly.

Parameters:
vthe verbosity level

Definition at line 44 of file wave_player.cpp.