Add support for AIFF audio files#116184
Conversation
Ivorforce
left a comment
There was a problem hiding this comment.
This makes sense to me. In the mac world, aiff is very widespread, especially because it supports metadata (as opposed to wave), which makes it useful as an all-purpose high quality audio storage.
Supporting it with ~40 LOC seems like a great trade-off to me.
I've only superficially checked the code so far. Will need to do another pass, and we need someone to test a few aiff files (ideally exported by different sources such that they are as different as possible).
Note that this is a basic implementation, which doesn't parse anything but strictly required chunks (pretty much what WAV support looked in early 3.0). Those could come later as the objective here is to make sure basic support is present. (and technically, WAV does support metadata through
On my own tests, importing AIFF files with Signed 8/16/24/32-bit PCM exported by Audacity work just fine. The issue comes when you use any option other than those four (like Unsigned 8-bit PCM), which turns the AIFF file into an AIFC internally. Anyway, if that's the case, parsing will fail very early and the user will be informed it's not supported. |
1cb9fe5 to
e6b015c
Compare
Additionally, I believe that would be better done after #115534 to be more organized. |
13ef37f to
c54d577
Compare
|
Seems like we can just It leads to cleaner code and a significantly smaller diff as it won't be moving parts around, so I'll go with it. Edit: it also has no binary size penalty. |
43b5a76 to
852b4e0
Compare
|
Tested with the 30 most downloaded AIFF sounds from freesound.org (first two pages). This one emits a seek error (past the end of file) during import. By analyzing the file itself, it seems the SSND chunk size goes beyond the end of the file (if anything, the parser has an The rest imported with no issues. |
7f8e953 to
18d1c62
Compare
A quick search led me find out a good portion of AIFF files exported by macOS apps are, internally, AIFC with the I didn't find any
I have tested the |
AudioStreamWAV|
Rebased on top of the changes in #120036. Vector COW is now avoided when getting AIFF data. |
Enables
AudioStreamWAV::load_from_bufferto recognize and support AIFF files. Also enablesResourceImporterWAVto import AIFF files.The parser is written using the AIFF 1.3 specification and AIFC specification as reference. It integrates nicely with the existing WAV parser:
FileAccess::set_big_endian(true)once we find out it's one.fmtanddata, while AIFF hasCOMMandSSND, not counting special types which wouldn't collide anyway), so you don't need to separate checks for each.The supported types are the following:
sowtID, common in many macOS app exports)fl32andfl64IDs)Also, there is no standardized way to use loop points in AIFF, so detection only works for WAV for now.
Supersedes #96545, which was made with the same purpose but relies on an external library and has a size penalty (45KiB).
Closes godotengine/godot-proposals#14325
Note: This PR doesn't implement metadata reading support (the only thing keeping this PR "basic"), as I'm waiting for #115534 to make it simpler.