Open cclauss opened 5 months ago
I feel a PR coming on 😁
sndhdr
unlike imghdr
seems to perform some fancier tests to test/provide better information. We can look to borrow some of this especially for #70 and #69. With the current state of PureMagic we can certainly make a good job of identifying them with decent confidence.
sndhdr
support these formats:
aifc
Compressed Audio Interchange Files: ✔️ Looks to support it, some tiding/enhancements requiredaiff
Audio Interchange Files: ✔️ Looks to support it, some tiding/enhancements requiredau
Au Files: ✔️ Looks to support it, some tiding/enhancements requiredhcom
HCOM Files: ❌ Not supportedsndt
Sndtool Sound Files: ❌ Not supportedvoc
Creative Labs Audio Files: ✔️ Supported some tiding requiredwav
Waveform Audio File Format Files: ✔️ Supported, maybe some enhancements later for V2.08svx
8-Bit Sampled Voice Files: ✔️ Supportedsb
Signed Byte Audio Data Files: ❌ Not supportedub
UB Files: ❌ Not supportedul
uLAW Audio Files: ❌ Not supportedsndr
❌ Not mentioned in the docs but there is a test for it in the .py. It's used by Sounder HCOM
is a weird possibly ancient Mac format, there seems little to no information about it aside from hereSNDT
again almost no info beyond a mention here and some sample files hereSB
and UB
Again, not much info aside from here, there is no specific test in sndhdr.py
. At a guess I'll assume these are some sort of raw stream (signed or unsigned). At present this may be beyond the scope of PureMagic as we would need to explicitly force a raw stream test somehow.UL
uLAW is a label that can be applied to a multitude of audio formats, there is no specific test in sndhdr.py
. I remember this format from later in the Amiga era being mainly for speech and comms so I'll assume that's what they are aiming for. I'll likely try and match any/all things it could be.SNDR
Sounder is some old DOS/Win program, not much info at present other than hereThis is going to be a trickier PR, realistically we can at least try to ensure PureMagic can understand the files to a basic level, but the advanced tests will be reliant on how V2.0 testing logic pans out.
Hi @cclauss, my PR #87 has been merged with updates for most of the missing sound formats from sndhdr
. Unlike imghdr
it's not a complete replacement for a few reasons mentioned in the PR. Hopefully once v2 is in progress we can look at ways to handle more esoteric formats 🙂
Awesome! I did not see that PR. I agree that when I looked into sndhdr
, I knew that making a complete replacement would be much more difficult than the relatively simple imghdr
module. I see two things that should be added.
README.rst
like https://github.com/cdgriffith/puremagic?tab=readme-ov-file#imghdr-replacement
imghdr_and_sndhdr_replacements.rst
file that goes into more detail like your commit messages in #87sndhdr
.
Like #72 but for
sndhdr
instead ofimghdr
. Given thatpuremagic.what()
is now mentioned in What's new in Python 3.13 should we do something for the sound file formats in https://docs.python.org/3/library/sndhdr.html that will also be removed in Python 3.13? Doespuremagic
have support for the twelve sound file formats thatsndhdr
supports?It might be quite helpful to have a drop-in replacement for
sndhdr.what()
. It would provide a smooth transition to Py3.13 if developers could confidently replace all instances ofsndhdr.what()
withpuremagic.what()
-- same args, same results.72
76
81
@NebularNerd