Skip to content

Commit ed33248

Browse files
author
Amanda Butler
authored
Merge pull request #1225 from ARMmbed/AnotherButler-patch-6
Update links in Mbed_USB_WAV_Audio_Player.md
2 parents cd2572d + 7b4efd2 commit ed33248

File tree

1 file changed

+2
-48
lines changed

1 file changed

+2
-48
lines changed

docs/api/usb/Mbed_USB_WAV_Audio_Player/Mbed_USB_WAV_Audio_Player.md

Lines changed: 2 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -81,57 +81,11 @@ If USB properties of the Mbed USB WAV Audio Player are altered, such as the samp
8181

8282
## main.cpp
8383

84-
```c++ NOCI
85-
// Mbed WAV Audio Player
86-
#include "mbed.h"
87-
#include "USBAudio.h"
88-
#include "SDBlockDevice.h"
89-
#include "FATFileSystem.h"
90-
#include "AudioPlayer.h"
91-
#include "WaveAudioStream.h"
92-
93-
// Connection for SD card
94-
SDBlockDevice sd(PTE3, PTE1, PTE2, PTE4);//MOSI, MISO, SCLK, CS
95-
FATFileSystem fs("sd", &sd);
96-
97-
int main() {
98-
// Set the maximum speed so it can keep up with audio
99-
sd.frequency(25000000);
100-
// Load WAV file from SD card
101-
// WAV file must be PCM signed 16-bit little endian
102-
File file;
103-
if (file.open(&fs, "songs/Bach-minuet-in-g.wav") != 0) {
104-
error("Could not open 'songs/Bach-minuet-in-g.wav'\r\n");
105-
}
106-
WaveAudioStream song(&file);//"song" is the audio data object
107-
// Check to see if file is a valid WAV file
108-
if(song.get_valid() == 0){
109-
error("ERROR: not valid WAV file\r\n");
110-
}
111-
// WAV file must be 16-bit
112-
if(song.get_bytes_per_sample() != 2){
113-
error("ERROR: WAV file not 2 bytes per sample (16-bit)\r\n");
114-
}
115-
USBAudio audio(true, 8000, song.get_channels(), song.get_sample_rate(), song.get_channels());
116-
uint8_t buffer[1500];
117-
int num_bytes_read;
118-
printf("Playing Audio\r\n");
119-
// Reads and plays data from WAV file over USB until song is over
120-
while(1){
121-
num_bytes_read = song.read(buffer, 1500);
122-
if(num_bytes_read == -1){
123-
printf("Song Over\r\n");
124-
break;
125-
}
126-
audio.write(buffer, num_bytes_read);
127-
}
128-
song.close();//Close the WAV file
129-
}
130-
```
84+
[![View code](https://www.mbed.com/embed/?url=https://github.com/ARMmbed/mbed-os-examples-docs_only/blob/master/APIs_USB/USBAudio_wav_audio_player)](https://github.com/ARMmbed/mbed-os-examples-docs_only/blob/master/APIs_USB/USBAudio_wav_audio_player/main.cpp)
13185

13286
## Example WAV file
13387

134-
[Bach-minuet-in-g.wav](https://github.com/mrcoulter45/mbed-os-5-docs/raw/Mbed_USB_WAV_Audio_Player_Tutorial/docs/tutorials/using_apis/Mbed_USB_WAV_Audio_Player/Bach-minuet-in-g.wav)
88+
[Bach-minuet-in-g.wav](https://github.com/ARMmbed/mbed-os-examples-docs_only/blob/master/APIs_USB/USBAudio_wav_audio_player/Bach-minuet-in-g.wav)
13589

13690
## Troubleshooting
13791

0 commit comments

Comments
 (0)