[issue32990] Supporting extensible format(PCM) for wave.open(read-mode)

Andrea Celletti report at bugs.python.org
Sat Mar 3 04:25:58 EST 2018


New submission from Andrea Celletti <celletti.andrea87 at gmail.com>:

The wave.Wave_read class currently supports 8, 16, 24, and 32 bit PCM files.
Wave files are only supported if the wFormatTag in the format chunk matches the flag WAVE_FORMAT_PCM, which is correct but incomplete for 24 bit files.

According to the specification the WAVE_FORMAT_EXTENSIBLE format should be used whenever the actual number of bits/sample is not equal to the container size. Based on this specification, most applications export 24 bit PCM with the WAVE_FORMAT_EXTENSIBLE flag since 24 is stored in container size 32. 
Importing these files causes wave.open to raise an exception.

The specification also explains how to detect 24PCM exported in this fashion as "The first two bytes of the GUID form the sub-code specifying the data format code, e.g. WAVE_FORMAT_PCM.". In essence, we have to look at the first two bytes of the SubFormat tag and that will tell us if this file is PCM.

Based on this premise, it appears to me that there is no reason for not adding support for both format specification as the rest of the file is exactly the same for both.

I am attaching a file that can be used to test the exception being raised.

Source: http://www-mmsp.ece.mcgill.ca/Documents/AudioFormats/WAVE/WAVE.html

----------
components: Library (Lib)
files: pluck-pcm24-ext.wav
messages: 313183
nosy: acelletti
priority: normal
severity: normal
status: open
title: Supporting extensible format(PCM) for wave.open(read-mode)
type: enhancement
Added file: https://bugs.python.org/file47467/pluck-pcm24-ext.wav

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32990>
_______________________________________


More information about the Python-bugs-list mailing list