Support B-Format sounds in the examples

This commit is contained in:
Chris Robinson
2020-09-22 11:36:43 -07:00
parent d2970443dd
commit 04fd50bcdf
7 changed files with 86 additions and 7 deletions
+12 -1
View File
@@ -159,13 +159,24 @@ static int OpenPlayerFile(StreamPlayer *player, const char *filename)
return 0;
}
player->format = AL_NONE;
if(player->sfinfo.channels == 1)
player->format = AL_FORMAT_MONO_FLOAT32;
else if(player->sfinfo.channels == 2)
player->format = AL_FORMAT_STEREO_FLOAT32;
else if(player->sfinfo.channels == 6)
player->format = AL_FORMAT_51CHN32;
else
else if(player->sfinfo.channels == 3)
{
if(sf_command(player->sndfile, SFC_WAVEX_GET_AMBISONIC, NULL, 0) == SF_AMBISONIC_B_FORMAT)
player->format = AL_FORMAT_BFORMAT2D_FLOAT32;
}
else if(player->sfinfo.channels == 4)
{
if(sf_command(player->sndfile, SFC_WAVEX_GET_AMBISONIC, NULL, 0) == SF_AMBISONIC_B_FORMAT)
player->format = AL_FORMAT_BFORMAT3D_FLOAT32;
}
if(!player->format)
{
fprintf(stderr, "Unsupported channel count: %d\n", player->sfinfo.channels);
sf_close(player->sndfile);
+12 -1
View File
@@ -76,11 +76,22 @@ static ALuint LoadSound(const char *filename)
}
/* Get the sound format, and figure out the OpenAL format */
format = AL_NONE;
if(sfinfo.channels == 1)
format = AL_FORMAT_MONO16;
else if(sfinfo.channels == 2)
format = AL_FORMAT_STEREO16;
else
else if(sfinfo.channels == 3)
{
if(sf_command(sndfile, SFC_WAVEX_GET_AMBISONIC, NULL, 0) == SF_AMBISONIC_B_FORMAT)
format = AL_FORMAT_BFORMAT2D_16;
}
else if(sfinfo.channels == 4)
{
if(sf_command(sndfile, SFC_WAVEX_GET_AMBISONIC, NULL, 0) == SF_AMBISONIC_B_FORMAT)
format = AL_FORMAT_BFORMAT3D_16;
}
if(!format)
{
fprintf(stderr, "Unsupported channel count: %d\n", sfinfo.channels);
sf_close(sndfile);
+12 -1
View File
@@ -79,11 +79,22 @@ static ALuint LoadSound(const char *filename)
}
/* Get the sound format, and figure out the OpenAL format */
format = AL_NONE;
if(sfinfo.channels == 1)
format = AL_FORMAT_MONO16;
else if(sfinfo.channels == 2)
format = AL_FORMAT_STEREO16;
else
else if(sfinfo.channels == 3)
{
if(sf_command(sndfile, SFC_WAVEX_GET_AMBISONIC, NULL, 0) == SF_AMBISONIC_B_FORMAT)
format = AL_FORMAT_BFORMAT2D_16;
}
else if(sfinfo.channels == 4)
{
if(sf_command(sndfile, SFC_WAVEX_GET_AMBISONIC, NULL, 0) == SF_AMBISONIC_B_FORMAT)
format = AL_FORMAT_BFORMAT3D_16;
}
if(!format)
{
fprintf(stderr, "Unsupported channel count: %d\n", sfinfo.channels);
sf_close(sndfile);
+13 -1
View File
@@ -33,6 +33,7 @@
#include "sndfile.h"
#include "AL/al.h"
#include "AL/alext.h"
#include "common/alhelpers.h"
@@ -65,11 +66,22 @@ static ALuint LoadSound(const char *filename)
}
/* Get the sound format, and figure out the OpenAL format */
format = AL_NONE;
if(sfinfo.channels == 1)
format = AL_FORMAT_MONO16;
else if(sfinfo.channels == 2)
format = AL_FORMAT_STEREO16;
else
else if(sfinfo.channels == 3)
{
if(sf_command(sndfile, SFC_WAVEX_GET_AMBISONIC, NULL, 0) == SF_AMBISONIC_B_FORMAT)
format = AL_FORMAT_BFORMAT2D_16;
}
else if(sfinfo.channels == 4)
{
if(sf_command(sndfile, SFC_WAVEX_GET_AMBISONIC, NULL, 0) == SF_AMBISONIC_B_FORMAT)
format = AL_FORMAT_BFORMAT3D_16;
}
if(!format)
{
fprintf(stderr, "Unsupported channel count: %d\n", sfinfo.channels);
sf_close(sndfile);
+13 -1
View File
@@ -34,6 +34,7 @@
#include "AL/al.h"
#include "AL/alc.h"
#include "AL/alext.h"
#include "AL/efx.h"
#include "AL/efx-presets.h"
@@ -173,11 +174,22 @@ static ALuint LoadSound(const char *filename)
}
/* Get the sound format, and figure out the OpenAL format */
format = AL_NONE;
if(sfinfo.channels == 1)
format = AL_FORMAT_MONO16;
else if(sfinfo.channels == 2)
format = AL_FORMAT_STEREO16;
else
else if(sfinfo.channels == 3)
{
if(sf_command(sndfile, SFC_WAVEX_GET_AMBISONIC, NULL, 0) == SF_AMBISONIC_B_FORMAT)
format = AL_FORMAT_BFORMAT2D_16;
}
else if(sfinfo.channels == 4)
{
if(sf_command(sndfile, SFC_WAVEX_GET_AMBISONIC, NULL, 0) == SF_AMBISONIC_B_FORMAT)
format = AL_FORMAT_BFORMAT3D_16;
}
if(!format)
{
fprintf(stderr, "Unsupported channel count: %d\n", sfinfo.channels);
sf_close(sndfile);
+12 -1
View File
@@ -33,6 +33,7 @@
#include "sndfile.h"
#include "AL/al.h"
#include "AL/alext.h"
#include "common/alhelpers.h"
@@ -128,7 +129,17 @@ static int OpenPlayerFile(StreamPlayer *player, const char *filename)
player->format = AL_FORMAT_MONO16;
else if(player->sfinfo.channels == 2)
player->format = AL_FORMAT_STEREO16;
else
else if(player->sfinfo.channels == 3)
{
if(sf_command(player->sndfile, SFC_WAVEX_GET_AMBISONIC, NULL, 0) == SF_AMBISONIC_B_FORMAT)
player->format = AL_FORMAT_BFORMAT2D_16;
}
else if(player->sfinfo.channels == 4)
{
if(sf_command(player->sndfile, SFC_WAVEX_GET_AMBISONIC, NULL, 0) == SF_AMBISONIC_B_FORMAT)
player->format = AL_FORMAT_BFORMAT3D_16;
}
if(!player->format)
{
fprintf(stderr, "Unsupported channel count: %d\n", player->sfinfo.channels);
sf_close(player->sndfile);
+12 -1
View File
@@ -40,6 +40,7 @@
#include "AL/al.h"
#include "AL/alc.h"
#include "AL/alext.h"
#include "common/alhelpers.h"
@@ -132,7 +133,17 @@ struct StreamPlayer {
mFormat = AL_FORMAT_MONO16;
else if(mSfInfo.channels == 2)
mFormat = AL_FORMAT_STEREO16;
else
else if(mSfInfo.channels == 3)
{
if(sf_command(mSndfile, SFC_WAVEX_GET_AMBISONIC, NULL, 0) == SF_AMBISONIC_B_FORMAT)
mFormat = AL_FORMAT_BFORMAT2D_16;
}
else if(mSfInfo.channels == 4)
{
if(sf_command(mSndfile, SFC_WAVEX_GET_AMBISONIC, NULL, 0) == SF_AMBISONIC_B_FORMAT)
mFormat = AL_FORMAT_BFORMAT3D_16;
}
if(!mFormat)
{
fprintf(stderr, "Unsupported channel count: %d\n", mSfInfo.channels);
sf_close(mSndfile);