Skip to content

Add support for AIFF audio files#116184

Open
DeeJayLSP wants to merge 1 commit into
godotengine:masterfrom
DeeJayLSP:in-house-aiff
Open

Add support for AIFF audio files#116184
DeeJayLSP wants to merge 1 commit into
godotengine:masterfrom
DeeJayLSP:in-house-aiff

Conversation

@DeeJayLSP

@DeeJayLSP DeeJayLSP commented Feb 11, 2026

Copy link
Copy Markdown
Contributor

Enables AudioStreamWAV::load_from_buffer to recognize and support AIFF files. Also enables ResourceImporterWAV to 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:

  • Chunks are pretty much the same, 4-char ID followed by 32-bit size.
  • AIFF files are entirely big-endian, which can be simply controlled by setting FileAccess::set_big_endian(true) once we find out it's one.
  • It's pretty hard for chunks of both types to collide (WAVE has fmt and data, while AIFF has COMM and SSND, 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:

  • Standard AIFF (8, 16, 24 and 32 bit samples)
  • Little-endian AIFF (sowt ID, common in many macOS app exports)
  • 32 and 64 bit IEEE float (fl32 and fl64 IDs)

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.

@DeeJayLSP DeeJayLSP requested review from a team as code owners February 11, 2026 21:26

@Ivorforce Ivorforce left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Comment thread scene/resources/audio_stream_wav.cpp Outdated
Comment thread scene/resources/audio_stream_wav.cpp Outdated
@DeeJayLSP

DeeJayLSP commented Feb 12, 2026

Copy link
Copy Markdown
Contributor Author

This makes sense to me. In the mac world, aiff is very widespread, especially because it supports metadata (as opposed to wave)

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 LIST INFO tags, already supported in Godot)

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).

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.

@DeeJayLSP DeeJayLSP force-pushed the in-house-aiff branch 8 times, most recently from 1cb9fe5 to e6b015c Compare February 13, 2026 20:51
@DeeJayLSP

DeeJayLSP commented Feb 15, 2026

Copy link
Copy Markdown
Contributor Author

Those could come later as the objective here is to make sure basic support is present.

Additionally, I believe that would be better done after #115534 to be more organized.

Comment thread scene/resources/audio_stream_wav.cpp Outdated
@DeeJayLSP DeeJayLSP force-pushed the in-house-aiff branch 2 times, most recently from 13ef37f to c54d577 Compare February 16, 2026 14:50
@DeeJayLSP

DeeJayLSP commented Feb 17, 2026

Copy link
Copy Markdown
Contributor Author

Seems like we can just set_big_endian on the file buffer instead of BSWAP everywhere.

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.

@DeeJayLSP DeeJayLSP force-pushed the in-house-aiff branch 2 times, most recently from 43b5a76 to 852b4e0 Compare February 17, 2026 14:47
@DeeJayLSP

DeeJayLSP commented Feb 23, 2026

Copy link
Copy Markdown
Contributor Author

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 eof_reached check, so it won't be a problem). Despite that, the file is perfectly usable with no noticeable artifacts.

The rest imported with no issues.

@DeeJayLSP

DeeJayLSP commented Mar 3, 2026

Copy link
Copy Markdown
Contributor Author

In the mac world, aiff is very widespread

A quick search led me find out a good portion of AIFF files exported by macOS apps are, internally, AIFC with the sowt compression type, which doesn't compress anything but signals data is little-endian.

I didn't find any sowt files in freesound.org to test with, but I did find one file using fl32 (data stored as 32-bit IEEE float). In any case, I decided to update the PR to handle AIFC "compression" types:

  • sowt sets the FileAccess to little-endian, then back to big-endian after data is read.
  • fl32 and fl64 will perform the float condition. Whether to use get_float() or get_double() is defined by format_bits.

I have tested the fl32 case, and it works just fine. The only thing missing to be in pair with WAV parsing would be metadata.

@github-project-automation github-project-automation Bot moved this to For team assessment in Audio Issue Triage May 20, 2026
@DeeJayLSP DeeJayLSP changed the title Add basic AIFF support to AudioStreamWAV Add support for AIFF audio files Jun 29, 2026
@DeeJayLSP

Copy link
Copy Markdown
Contributor Author

Rebased on top of the changes in #120036.

Vector COW is now avoided when getting AIFF data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for AIFF audio files

4 participants