Giles Barton-Owen / WavPlayer

A library which allows the playing of Wav files using the TLV320

Dependents:   RSALB_hbridge_helloworld RSALB_lobster WavPlayer_test AudioCODEC_HelloWorld

Embed: (wiki syntax)

« Back to documentation index

WavPlayer Class Reference

WavPlayer Class Reference

A class to play WAV files from a file system, tested with USB. More...

#include <WavPlayer.h>

Public Member Functions

 WavPlayer ()
 Create a WavPlayer instance.
 WavPlayer (FILE **fpp)
 Create a WavPlayer instance.
void open (FILE **fpp)
 Set the file to read out of.
int getConfig ()
 Extract the header infomation, automatically called by open.
float play ()
 Play the entire file.
float play (float time)
 Play the file for a certain number of seconds.
float play (float start, float timefor)
 Play the file for a certain number of seconds, from a certain start point.

Detailed Description

A class to play WAV files from a file system, tested with USB.

Example (note, this has requires the USB MSC library to be imported):

 #include "mbed.h"
 #include "WavPlayer.h"
 #include "MSCFileSystem.h"
 
 MSCFileSystem msc("msc"); // Mount flash drive under the name "msc"
 WavPlayer player;
 
 int main() {
    FILE *fp = fopen("/msc/test.wav", "r");  // Open "out.txt" on the local file system for writing
     player.open(&fp);
     player.play();
     fclose(fp);
 }

Definition at line 62 of file WavPlayer.h.


Constructor & Destructor Documentation

WavPlayer (  )

Create a WavPlayer instance.

Definition at line 33 of file WavPlayer.cpp.

WavPlayer ( FILE **  fpp )

Create a WavPlayer instance.

Parameters:
fppA pointer to a file pointer to read out of

Definition at line 59 of file WavPlayer.cpp.


Member Function Documentation

int getConfig (  )

Extract the header infomation, automatically called by open.

Definition at line 144 of file WavPlayer.cpp.

void open ( FILE **  fpp )

Set the file to read out of.

Parameters:
fppA pointer to a file pointer to read out of

Definition at line 124 of file WavPlayer.cpp.

float play ( float  time )

Play the file for a certain number of seconds.

Blocking

Parameters:
timeThe number of seconds to play the file for.

Definition at line 195 of file WavPlayer.cpp.

float play (  )

Play the entire file.

Blocking

Definition at line 189 of file WavPlayer.cpp.

float play ( float  start,
float  timefor 
)

Play the file for a certain number of seconds, from a certain start point.

Blocking

Parameters:
startThe start time
timeforThe number of seconds to play the file for.

Definition at line 200 of file WavPlayer.cpp.