This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Supporting extensible format(PCM) for wave.open(read-mode)
Type: enhancement Stage: patch review
Components: Library (Lib) Versions: Python 3.8
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: ZackerySpytz, acelletti, ned.deily, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2018-03-03 09:25 by acelletti, last changed 2022-04-11 14:58 by admin.

Files
File name Uploaded Description Edit
pluck-pcm24-ext.wav acelletti, 2018-03-03 09:25 PCM 24b with FORMAT_EXTENSIBLE
Pull Requests
URL Status Linked Edit
PR 9515 open ZackerySpytz, 2018-09-23 13:35
Messages (4)
msg313183 - (view) Author: Andrea Celletti (acelletti) Date: 2018-03-03 09:25
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
msg313190 - (view) Author: Andrea Celletti (acelletti) Date: 2018-03-03 18:02
I am currently working on a patch for this.

When done can I try pushing this in 3.7 rather than 3.8?

It is not much of an enhancement but rather fixing the code that raises an error for a perfectly valid PCM wave file (bugfix).
msg313191 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2018-03-03 18:09
Thanks for working on this.  Please follow the process in our Developers Guide and submit a PR against the master branch (for 3.8).  After a core developer reviews it and if it is accepted, we can then decide about backports to other release branches.  Also, if you haven't already, please make sure to read the section on licensing and sign a contributor agreement:

https://devguide.python.org/pullrequest/
msg325477 - (view) Author: Zackery Spytz (ZackerySpytz) * (Python triager) Date: 2018-09-16 10:36
Andrea, are you still working on this issue? If not, I will submit a PR.
History
Date User Action Args
2022-04-11 14:58:58adminsetgithub: 77171
2018-09-23 13:35:55ZackerySpytzsetkeywords: + patch
stage: needs patch -> patch review
pull_requests: + pull_request8921
2018-09-16 10:36:19ZackerySpytzsetnosy: + ZackerySpytz
messages: + msg325477
2018-03-03 18:09:46ned.deilysetnosy: + ned.deily

messages: + msg313191
versions: + Python 3.8
2018-03-03 18:02:23acellettisetmessages: + msg313190
versions: - Python 3.8
2018-03-03 09:37:11serhiy.storchakasetnosy: + serhiy.storchaka
stage: needs patch

versions: + Python 3.8
2018-03-03 09:25:58acelletticreate