Skip to content

Commit ec32040

Browse files
committed
Using the right top-level include: Arduino_AdvancedAnalog.
1 parent bdbc4f8 commit ec32040

File tree

3 files changed

+31
-19
lines changed

3 files changed

+31
-19
lines changed

examples/Beginner/Audio_Playback/Audio_Playback.ino

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
* In order for this sketch to work you need to rename 'USB_DRIVE' to the name of your USB stick drive.
55
*/
66

7-
#include <USBHostMbed5.h>
7+
#include <Arduino_AdvancedAnalog.h>
88
#include <DigitalOut.h>
9+
#include <USBHostMbed5.h>
910
#include <FATFileSystem.h>
1011

1112
// AdvancedDAC library is included inside wav_seeker library

examples/Beginner/Audio_Playback/wav_seeker.cpp

+26-15
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ typedef struct uFMT_STRUCT {
2020
short sig_bps;
2121
} FMT_STRUCT;
2222

23-
void wav_play_rl(FILE *wavefile, AdvancedDAC &dac_out, bool verbosity){
23+
void wav_play_rl(FILE * wavefile, AdvancedDAC & dac_out, bool const verbosity)
24+
{
2425
unsigned chunk_id,chunk_size,channel;
2526
unsigned data,samp_int,i;
2627
short unsigned dac_data;
@@ -46,11 +47,12 @@ void wav_play_rl(FILE *wavefile, AdvancedDAC &dac_out, bool verbosity){
4647
fread(&chunk_size,4,1,wavefile);
4748

4849
while (!feof(wavefile)) {
49-
if (verbosity)
50+
if (verbosity) {
5051
Serial.print(F("Read chunk ID ="));
5152
Serial.println(chunk_id);
5253
Serial.print(F("Read chunk size ="));
5354
Serial.println(chunk_size);
55+
}
5456

5557
switch (chunk_id) {
5658
case 0x46464952:
@@ -131,27 +133,30 @@ void wav_play_rl(FILE *wavefile, AdvancedDAC &dac_out, bool verbosity){
131133
for (channel=0;channel<wav_format.num_channels;channel++) {
132134
switch (wav_format.sig_bps) {
133135
case 16:
134-
if (verbosity)
136+
if (verbosity) {
135137
Serial.print(F("16 bit channel ="));
136138
Serial.println(channel);
137139
Serial.print(F(" data = "));
138140
Serial.println(data_sptr[channel]);
141+
}
139142
slice_value+=data_sptr[channel];
140143
break;
141144
case 32:
142-
if (verbosity)
145+
if (verbosity) {
143146
Serial.print(F("32 bit channel ="));
144147
Serial.println(channel);
145148
Serial.print(F(" data = "));
146149
Serial.println(data_wptr[channel]);
150+
}
147151
slice_value+=data_wptr[channel];
148152
break;
149153
case 8:
150-
if (verbosity)
154+
if (verbosity) {
151155
Serial.print(F("8 bit channel ="));
152156
Serial.println(channel);
153157
Serial.print(F(" data = "));
154158
Serial.println((int)data_bptr[channel]);
159+
}
155160
slice_value+=data_bptr[channel];
156161
break;
157162
}
@@ -171,7 +176,7 @@ void wav_play_rl(FILE *wavefile, AdvancedDAC &dac_out, bool verbosity){
171176
break;
172177
}
173178
dac_data=(short unsigned)slice_value;
174-
if (verbosity)
179+
if (verbosity) {
175180
Serial.print(F("DAC-Data >>>>>>>>>>>>>>"));
176181
Serial.print(F("sample ="));
177182
Serial.println(slice);
@@ -181,6 +186,7 @@ void wav_play_rl(FILE *wavefile, AdvancedDAC &dac_out, bool verbosity){
181186
Serial.println((int)slice_value);
182187
Serial.print(F("dac_data ="));
183188
Serial.println(dac_data);
189+
}
184190
DAC_fifo[DAC_wptr]=dac_data;
185191

186192
// Custom_mode begin
@@ -189,8 +195,8 @@ void wav_play_rl(FILE *wavefile, AdvancedDAC &dac_out, bool verbosity){
189195
// Conditional addition to switch between channels - FOR STEREO
190196
if (DAC_wptr >= 255){
191197
static size_t lut_offs = 0;
192-
193-
Serial.println(F("Proceeding DAC ..."));
198+
if (verbosity)
199+
Serial.println(F("Proceeding DAC ..."));
194200
// Get a free buffer for writing.
195201
SampleBuffer buf = dac_out.dequeue();
196202
// Write data to buffer.
@@ -199,12 +205,14 @@ void wav_play_rl(FILE *wavefile, AdvancedDAC &dac_out, bool verbosity){
199205
}
200206

201207
// Writethe buffer to DAC.
202-
Serial.println(F("Writing to DAC ..."));
208+
if (verbosity)
209+
Serial.println(F("Writing to DAC ..."));
203210
dac_out.write(buf);
204211

205212
DAC_wptr = 0;
206213
} else {
207-
Serial.println(F("Slicing"));
214+
if(verbosity)
215+
Serial.println(F("Slicing"));
208216
}
209217
// Custom_mode end
210218
}
@@ -213,16 +221,19 @@ void wav_play_rl(FILE *wavefile, AdvancedDAC &dac_out, bool verbosity){
213221
free(slice_buf);
214222
break;
215223
case 0x5453494c:
216-
if (verbosity)
224+
if (verbosity) {
217225
Serial.print(F("INFO chunk, size"));
218226
Serial.println(chunk_size);
227+
}
219228
fseek(wavefile,chunk_size,SEEK_CUR);
220229
break;
221230
default:
222-
Serial.print(F("unknown chunk type ="));
223-
Serial.println(chunk_id);
224-
Serial.print(F("chunk size ="));
225-
Serial.println(chunk_size);
231+
if (verbosity) {
232+
Serial.print(F("unknown chunk type ="));
233+
Serial.println(chunk_id);
234+
Serial.print(F("chunk size ="));
235+
Serial.println(chunk_size);
236+
}
226237
data=fseek(wavefile,chunk_size,SEEK_CUR);
227238
break;
228239
}
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

2-
#include "AdvancedDAC.h"
2+
#include <stdlib.h>
33

4-
struct adc_descr_t;
4+
#include <Arduino_AdvancedAnalog.h>
55

6-
void wav_play_rl(FILE *wavefile, AdvancedDAC &dac_out, bool verbosity);
6+
void wav_play_rl(FILE * wavefile, AdvancedDAC & dac_out, bool const verbosity);

0 commit comments

Comments
 (0)