Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: RSALB_hbridge_helloworld RSALB_lobster WavPlayer_test AudioCODEC_HelloWorld
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:
- 
  fpp A 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:
- 
  fpp A 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:
- 
  time The number of seconds to play the file for. 
Definition at line 195 of file WavPlayer.cpp.
| float play | ( | ) | 
| float play | ( | float | start, | 
| float | timefor | ||
| ) | 
Play the file for a certain number of seconds, from a certain start point.
Blocking
- Parameters:
- 
  start The start time timefor The number of seconds to play the file for. 
Definition at line 200 of file WavPlayer.cpp.
Generated on Tue Jul 12 2022 17:42:18 by
 1.7.2
 1.7.2