Skip to content

Commit 1eb57d8

Browse files
committed
CodecWAV.h comments
1 parent 3e3fbd0 commit 1eb57d8

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

src/AudioTools/AudioCodecs/CodecWAV.h

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ class WAVHeader {
115115
return len;
116116
}
117117

118+
/// Reset internal stored header information and buffer
118119
void clear() {
119120
data_pos = 0;
120121
WAVAudioInfo empty;
@@ -126,6 +127,7 @@ class WAVHeader {
126127
buffer.reset();
127128
}
128129

130+
/// Debug helper: dumps header bytes as printable characters
129131
void dumpHeader() {
130132
char msg[buffer.available() + 1];
131133
memset(msg, 0, buffer.available() + 1);
@@ -275,8 +277,6 @@ class WAVHeader {
275277
* @copyright GPLv3
276278
*/
277279
class WAVDecoder : public AudioDecoder {
278-
/// Enable or disable 8-bit to 16-bit conversion
279-
void setConvert8to16(bool enable) { convert8to16 = enable; }
280280

281281
public:
282282
/**
@@ -300,6 +300,7 @@ class WAVDecoder : public AudioDecoder {
300300
/// Defines the output Stream
301301
void setOutput(Print &out_stream) override { this->p_print = &out_stream; }
302302

303+
/// Prepare decoder for a new WAV stream
303304
bool begin() override {
304305
TRACED();
305306
header.clear();
@@ -311,17 +312,21 @@ class WAVDecoder : public AudioDecoder {
311312
return true;
312313
}
313314

315+
/// Finish decoding and release temporary buffers
314316
void end() override {
315317
TRACED();
316318
byte_buffer.reset();
317319
buffer24.reset();
318320
active = false;
319321
}
320322

323+
/// Provides MIME type "audio/wav"
321324
const char *mime() { return wav_mime; }
322325

326+
/// Extended WAV specific info (original header values)
323327
WAVAudioInfo &audioInfoEx() { return header.audioInfo(); }
324328

329+
/// Exposed AudioInfo (may reflect conversion flags)
325330
AudioInfo audioInfo() override {
326331
WAVAudioInfo info = header.audioInfo();
327332
if (convert8to16 && info.format == AudioFormat::PCM &&
@@ -336,6 +341,7 @@ class WAVDecoder : public AudioDecoder {
336341
return info;
337342
}
338343

344+
/// Write incoming WAV data (header + PCM) into output
339345
virtual size_t write(const uint8_t *data, size_t len) override {
340346
TRACED();
341347
size_t result = 0;
@@ -355,14 +361,15 @@ class WAVDecoder : public AudioDecoder {
355361
return result;
356362
}
357363

364+
/// Check if the decoder is active
358365
virtual operator bool() override { return active; }
359366

360-
/// Convert 8 bit to 16 bit PCM data
367+
/// Convert 8 bit to 16 bit PCM data (default: enabled)
361368
void setConvert8Bit(bool enable) {
362369
convert8to16 = enable;
363370
}
364371

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)
366373
void setConvert24Bit(bool enable) {
367374
convert24 = enable;
368375
}
@@ -521,6 +528,7 @@ class WAVEncoder : public AudioEncoder {
521528
*/
522529
WAVEncoder(AudioEncoderExt &enc, AudioFormat fmt) { setEncoder(enc, fmt); };
523530

531+
/// Associates an external encoder for non-PCM formats
524532
void setEncoder(AudioEncoderExt &enc, AudioFormat fmt) {
525533
TRACED();
526534
audioInfo.format = fmt;
@@ -536,7 +544,7 @@ class WAVEncoder : public AudioEncoder {
536544
/// Provides "audio/wav"
537545
const char *mime() override { return wav_mime; }
538546

539-
// Provides the default configuration
547+
/// Provides the default configuration
540548
WAVAudioInfo defaultConfig() {
541549
WAVAudioInfo info;
542550
info.format = AudioFormat::PCM;
@@ -642,8 +650,10 @@ class WAVEncoder : public AudioEncoder {
642650
return result;
643651
}
644652

653+
/// Check if encoder is active and ready to write
645654
operator bool() override { return is_open; }
646655

656+
/// Check if encoder is open
647657
bool isOpen() { return is_open; }
648658

649659
/// Adds n empty bytes at the beginning of the data

0 commit comments

Comments
 (0)