From c993ade9bf6a1980e598dcc689834772248e2b66 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Tue, 22 Sep 2020 08:43:13 -0700 Subject: [PATCH] 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. --- examples/alconvolve.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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); -- 2.11.4.GIT