diff options
author | Chris Robinson <[email protected]> | 2020-09-22 08:43:13 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2020-09-22 10:18:43 -0700 |
commit | c993ade9bf6a1980e598dcc689834772248e2b66 (patch) | |
tree | b9a08eed668c7440f7b47188071add938b2ff21d | |
parent | 844e6c881b55e1dac6d754a9d103e04a0d15b636 (diff) |
Support B-Format amb file IRs in alconvolve
Be aware this requires proper header data (a WAVE_FORMAT_EXTENSIBLE format with
the proper integer or float B-Format sub-format GUID). A normal 4-channel wave
file will not be recognized, since it's indistinguishable from quadrophonic.
-rw-r--r-- | examples/alconvolve.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/examples/alconvolve.c b/examples/alconvolve.c index bc6ac311..b3d6c4dd 100644 --- a/examples/alconvolve.c +++ b/examples/alconvolve.c @@ -325,11 +325,22 @@ static ALuint LoadSound(const char *filename) /* Get the sound format, and figure out the OpenAL format. Use floats since * impulse responses will usually have more than 16-bit precision. */ + format = AL_NONE; if(sfinfo.channels == 1) format = AL_FORMAT_MONO_FLOAT32; else if(sfinfo.channels == 2) format = AL_FORMAT_STEREO_FLOAT32; - else + else if(sfinfo.channels == 3) + { + if(sf_command(sndfile, SFC_WAVEX_GET_AMBISONIC, NULL, 0) == SF_AMBISONIC_B_FORMAT) + format = AL_FORMAT_BFORMAT2D_FLOAT32; + } + else if(sfinfo.channels == 4) + { + if(sf_command(sndfile, SFC_WAVEX_GET_AMBISONIC, NULL, 0) == SF_AMBISONIC_B_FORMAT) + format = AL_FORMAT_BFORMAT3D_FLOAT32; + } + if(!format) { fprintf(stderr, "Unsupported channel count: %d\n", sfinfo.channels); sf_close(sndfile); |