@@ -115,6 +115,7 @@ class WAVHeader {
115
115
return len;
116
116
}
117
117
118
+ // / Reset internal stored header information and buffer
118
119
void clear () {
119
120
data_pos = 0 ;
120
121
WAVAudioInfo empty;
@@ -126,6 +127,7 @@ class WAVHeader {
126
127
buffer.reset ();
127
128
}
128
129
130
+ // / Debug helper: dumps header bytes as printable characters
129
131
void dumpHeader () {
130
132
char msg[buffer.available () + 1 ];
131
133
memset (msg, 0 , buffer.available () + 1 );
@@ -275,8 +277,6 @@ class WAVHeader {
275
277
* @copyright GPLv3
276
278
*/
277
279
class WAVDecoder : public AudioDecoder {
278
- // / Enable or disable 8-bit to 16-bit conversion
279
- void setConvert8to16 (bool enable) { convert8to16 = enable; }
280
280
281
281
public:
282
282
/* *
@@ -300,6 +300,7 @@ class WAVDecoder : public AudioDecoder {
300
300
// / Defines the output Stream
301
301
void setOutput (Print &out_stream) override { this ->p_print = &out_stream; }
302
302
303
+ // / Prepare decoder for a new WAV stream
303
304
bool begin () override {
304
305
TRACED ();
305
306
header.clear ();
@@ -311,17 +312,21 @@ class WAVDecoder : public AudioDecoder {
311
312
return true ;
312
313
}
313
314
315
+ // / Finish decoding and release temporary buffers
314
316
void end () override {
315
317
TRACED ();
316
318
byte_buffer.reset ();
317
319
buffer24.reset ();
318
320
active = false ;
319
321
}
320
322
323
+ // / Provides MIME type "audio/wav"
321
324
const char *mime () { return wav_mime; }
322
325
326
+ // / Extended WAV specific info (original header values)
323
327
WAVAudioInfo &audioInfoEx () { return header.audioInfo (); }
324
328
329
+ // / Exposed AudioInfo (may reflect conversion flags)
325
330
AudioInfo audioInfo () override {
326
331
WAVAudioInfo info = header.audioInfo ();
327
332
if (convert8to16 && info.format == AudioFormat::PCM &&
@@ -336,6 +341,7 @@ class WAVDecoder : public AudioDecoder {
336
341
return info;
337
342
}
338
343
344
+ // / Write incoming WAV data (header + PCM) into output
339
345
virtual size_t write (const uint8_t *data, size_t len) override {
340
346
TRACED ();
341
347
size_t result = 0 ;
@@ -355,14 +361,15 @@ class WAVDecoder : public AudioDecoder {
355
361
return result;
356
362
}
357
363
364
+ // / Check if the decoder is active
358
365
virtual operator bool () override { return active; }
359
366
360
- // / Convert 8 bit to 16 bit PCM data
367
+ // / Convert 8 bit to 16 bit PCM data (default: enabled)
361
368
void setConvert8Bit (bool enable) {
362
369
convert8to16 = enable;
363
370
}
364
371
365
- // / Convert 24 bit (3 byte) to 32 bit (4 byte) PCM data
372
+ // / Convert 24 bit (3 byte) to 32 bit (4 byte) PCM data (default: enabled)
366
373
void setConvert24Bit (bool enable) {
367
374
convert24 = enable;
368
375
}
@@ -521,6 +528,7 @@ class WAVEncoder : public AudioEncoder {
521
528
*/
522
529
WAVEncoder (AudioEncoderExt &enc, AudioFormat fmt) { setEncoder (enc, fmt); };
523
530
531
+ // / Associates an external encoder for non-PCM formats
524
532
void setEncoder (AudioEncoderExt &enc, AudioFormat fmt) {
525
533
TRACED ();
526
534
audioInfo.format = fmt;
@@ -536,7 +544,7 @@ class WAVEncoder : public AudioEncoder {
536
544
// / Provides "audio/wav"
537
545
const char *mime () override { return wav_mime; }
538
546
539
- // Provides the default configuration
547
+ // / Provides the default configuration
540
548
WAVAudioInfo defaultConfig () {
541
549
WAVAudioInfo info;
542
550
info.format = AudioFormat::PCM;
@@ -642,8 +650,10 @@ class WAVEncoder : public AudioEncoder {
642
650
return result;
643
651
}
644
652
653
+ // / Check if encoder is active and ready to write
645
654
operator bool () override { return is_open; }
646
655
656
+ // / Check if encoder is open
647
657
bool isOpen () { return is_open; }
648
658
649
659
// / Adds n empty bytes at the beginning of the data
0 commit comments