openal-soft icon indicating copy to clipboard operation
openal-soft copied to clipboard

Add `AL_FORMAT_MONO32` / `AL_FORMAT_STEREO32`

Open Splendide-Imaginarius opened this issue 7 months ago • 6 comments

Currently, OpenAL Soft supports 8-bit and 16-bit integer formats, and 32-bit float formats, but doesn't seem to support 32-bit integer formats. It would be nice if AL_FORMAT_MONO32 and AL_FORMAT_STEREO32 could be added to fill this gap. (32-bit integer formats are the native sample format of FLAC, so they show up fairly often.)

Splendide-Imaginarius avatar Nov 15 '23 01:11 Splendide-Imaginarius

This might need a bit of research. I don't think AL_FORMAT_MONO32 and AL_FORMAT_STEREO32 were ever added to headers as a public extension, but were available through alGetEnumValue calls on hardware or other drivers. It might be worth checking what values they were so OpenAL Soft can match them for compatibility.

32-bit integer formats are the native sample format of FLAC

Doesn't that depend on the encoding parameters? IIRC, FLAC provides the samples as 32-bit integers, but the actual sample depth can be less than 32 bits depending on how it was encoded. It also provides the samples uninterleaved, requiring non-mono sounds to be interleaved into a separate buffer. So it may likely still need conversion before it can be fed to an OpenAL buffer anyway.

Not that I don't see worth in supporting 32-bit int samples, but getting samples from FLAC will likely still need the app to convert to load into OpenAL.

kcat avatar Nov 15 '23 06:11 kcat

Doesn't that depend on the encoding parameters? IIRC, FLAC provides the samples as 32-bit integers, but the actual sample depth can be less than 32 bits depending on how it was encoded. It also provides the samples uninterleaved, requiring non-mono sounds to be interleaved into a separate buffer. So it may likely still need conversion before it can be fed to an OpenAL buffer anyway.

Not that I don't see worth in supporting 32-bit int samples, but getting samples from FLAC will likely still need the app to convert to load into OpenAL.

Not sure on details, but both ffmpeg and SDL_sound return FLAC samples as 32-bit ints, so any application that's using either of those libraries to decode FLAC files will wind up with 32-bit int data by default unless they instruct those libraries to convert it to something else.

Splendide-Imaginarius avatar Nov 15 '23 10:11 Splendide-Imaginarius

I don't think AL_FORMAT_MONO32 and AL_FORMAT_STEREO32 were ever added to headers as a public extension, but were available through alGetEnumValue calls on hardware or other drivers. It might be worth checking what values they were so OpenAL Soft can match them for compatibility.

Per https://github.com/dolphin-emu/dolphin/pull/3080, AL_FORMAT_STEREO32 is 0x1203 on the X-Fi Windows driver. I can't find the value of AL_FORMAT_MONO32 on any existing implementations, maybe @LAGonauta (who authored that Dolphin PR) knows where it could be found?

Splendide-Imaginarius avatar Nov 16 '23 13:11 Splendide-Imaginarius

I got that value from the hardware, so there is no header to go from. I can check whay the value is for MONO32 on the hardware, if desired.

LAGonauta avatar Nov 19 '23 11:11 LAGonauta

I can check whay the value is for MONO32 on the hardware, if desired.

That would be good if possible. To avoid taking another enum value unnecessarily and avoid wrong assumptions.

kcat avatar Nov 20 '23 06:11 kcat

Just got them all from a X-Fi Titanium HD:

AL_FORMAT_MONO32:   4610  
AL_FORMAT_STEREO32: 4611
AL_FORMAT_QUAD32:   4614  
AL_FORMAT_REAR32:   4617  
AL_FORMAT_51CHN32:  4620 
AL_FORMAT_61CHN32:  4623 
AL_FORMAT_71CHN32:  4626

Or if you prefer hex:

AL_FORMAT_MONO32:   0x1202  
AL_FORMAT_STEREO32: 0x1203
AL_FORMAT_QUAD32:   0x1206  
AL_FORMAT_REAR32:   0x1209  
AL_FORMAT_51CHN32:  0x120c 
AL_FORMAT_61CHN32:  0x120f 
AL_FORMAT_71CHN32:  0x1212

LAGonauta avatar Nov 22 '23 02:11 LAGonauta