8000 support wave files with 40 byte format chunk by MarshallMiller · Pull Request #10001 · adafruit/circuitpython · GitHub
[go: up one dir, main page]

Skip to content

support wave files with 40 byte format chunk #10001

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions shared-module/audiocore/WaveFile.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ struct wave_format_chunk {
uint32_t byte_rate;
uint16_t block_align;
uint16_t bits_per_sample;
uint16_t extra_params; // Assumed to be zero below.
uint16_t extra_params;
uint16_t valid_bits_per_sample;
uint32_t channel_mask;
uint16_t extended_audio_format;
uint8_t extended_guid[14];
};

void common_hal_audioio_wavefile_construct(audioio_wavefile_obj_t *self,
Expand Down Expand Up @@ -56,11 +60,14 @@ void common_hal_audioio_wavefile_construct(audioio_wavefile_obj_t *self,
if (bytes_read != format_size) {
}

if (format.audio_format != 1 ||
if ((format_size != 40 && format.audio_format != 1) ||
format.num_channels > 2 ||
format.bits_per_sample > 16 ||
(format_size == 18 &&
format.extra_params != 0)) {
(format_size == 18 && format.extra_params != 0) ||
(format_size == 40 &&
(format.audio_format != 0xfffe ||
format.extended_audio_format != 1 ||
format.valid_bits_per_sample != format.bits_per_sample))) {
mp_raise_ValueError(MP_ERROR_TEXT("Unsupported format"));
}
// Get the sample_rate
Expand Down
0