The example below uses a public domain WAV file called "Bach-minuet-in-g.wav" (attached below for download) that is inside a "songs" directory on the SD card. For example, in the example below, line 10 sets up SPI for the SDBlockDevice for the NXP K64F Mbed board.
Make sure the SPI pins for the SDBlockDevice object are updated and correct for your board.
Wav file players code#
The following steps demonstrate the setup and use of the Mbed WAV audio player:Īdd the sd-driver and AudioPlayer libraries to the new Mbed project directory:Įnsure that SD component is available for your device in targets.json or mbed_app.json.Ĭopy and paste the example code into main.cpp.
Wav file players install#
Please install Mbed CLI to complete the tutorial.
The Mbed board acts as the computer's USB microphone. You can then play the WAV file from the board on a host computer over USB. You will load a WAV file onto an SD card connected to an Mbed board.
Wav file players how to#
This tutorial explains how to put together a USB WAV audio player with Mbed OS. USB WAV audio player USB WAV audio player