8000 Merge pull request #10001 from MarshallMiller/support-40byte-wave-for… · adafruit/circuitpython@a4e20e0 · GitHub
[go: up one dir, main page]

Skip to content

Commit a4e20e0

Browse files
authored
Merge pull request #10001 from MarshallMiller/support-40byte-wave-format-chunk
support wave files with 40 byte format chunk
2 parents 65556b4 + 606f56a commit a4e20e0

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

shared-module/audiocore/WaveFile.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ struct wave_format_chunk {
2121
uint32_t byte_rate;
2222
uint16_t block_align;
2323
uint16_t bits_per_sample;
24-
uint16_t extra_params; // Assumed to be zero below.
24+
uint16_t extra_params;
25+
uint16_t valid_bits_per_sample;
26+
uint32_t channel_mask;
27+
uint16_t extended_audio_format;
28+
uint8_t extended_guid[14];
2529
};
2630

2731
void common_hal_audioio_wavefile_construct(audioio_wavefile_obj_t *self,
@@ -56,11 +60,14 @@ void common_hal_audioio_wavefile_construct(audioio_wavefile_obj_t *self,
5660
if (bytes_read != format_size) {
5761
}
5862

59-
if (format.audio_format != 1 ||
63+
if ((format_size != 40 && format.audio_format != 1) ||
6064
format.num_channels > 2 ||
6165
format.bits_per_sample > 16 ||
62-
(format_size == 18 &&
63-
format.extra_params != 0)) {
66+
(format_size == 18 && format.extra_params != 0) ||
67+
(format_size == 40 &&
68+
(format.audio_format != 0xfffe ||
69+
format.extended_audio_format != 1 ||
70+
format.valid_bits_per_sample != format.bits_per_sample))) {
6471
mp_raise_ValueError(MP_ERROR_TEXT("Unsupported format"));
6572
}
6673
// Get the sample_rate

0 commit comments

Comments
 (0)
0