aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/backends/wave.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2014-11-25 22:20:00 -0800
committerChris Robinson <[email protected]>2014-11-25 22:20:00 -0800
commitbdbf6613ef4d57f15f5e7e3cbc31211a0c57e575 (patch)
tree298b76ea7a08d4625deca17ec41db90635dae956 /Alc/backends/wave.c
parentbe476b372993647376de5d6133bd37e7fa77df17 (diff)
Support B-Format output with the wave file writer
Diffstat (limited to 'Alc/backends/wave.c')
-rw-r--r--Alc/backends/wave.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/Alc/backends/wave.c b/Alc/backends/wave.c
index 6999f0cb..bfe0e2cf 100644
--- a/Alc/backends/wave.c
+++ b/Alc/backends/wave.c
@@ -44,6 +44,15 @@ static const ALubyte SUBTYPE_FLOAT[] = {
0x00, 0x38, 0x9b, 0x71
};
+static const ALubyte SUBTYPE_BFORMAT_PCM[] = {
+ 0x01, 0x00, 0x00, 0x00, 0x21, 0x07, 0xd3, 0x11, 0x86, 0x44, 0xc8, 0xc1,
+ 0xca, 0x00, 0x00, 0x00
+};
+
+static const ALubyte SUBTYPE_BFORMAT_FLOAT[] = {
+ 0x03, 0x00, 0x00, 0x00, 0x21, 0x07, 0xd3, 0x11, 0x86, 0x44, 0xc8, 0xc1,
+ 0xca, 0x00, 0x00, 0x00
+};
static void fwrite16le(ALushort val, FILE *f)
{
@@ -233,11 +242,15 @@ static ALCboolean ALCwaveBackend_reset(ALCwaveBackend *self)
{
ALCdevice *device = STATIC_CAST(ALCbackend, self)->mDevice;
ALuint channels=0, bits=0, chanmask=0;
+ int isbformat = 0;
size_t val;
fseek(self->mFile, 0, SEEK_SET);
clearerr(self->mFile);
+ if(GetConfigValueBool("wave", "bformat", 0))
+ device->FmtChans = DevFmtBFormat3D;
+
switch(device->FmtType)
{
case DevFmtByte:
@@ -264,6 +277,10 @@ static ALCboolean ALCwaveBackend_reset(ALCwaveBackend *self)
case DevFmtX51Rear: chanmask = 0x01 | 0x02 | 0x04 | 0x08 | 0x010 | 0x020; break;
case DevFmtX61: chanmask = 0x01 | 0x02 | 0x04 | 0x08 | 0x100 | 0x200 | 0x400; break;
case DevFmtX71: chanmask = 0x01 | 0x02 | 0x04 | 0x08 | 0x010 | 0x020 | 0x200 | 0x400; break;
+ case DevFmtBFormat3D:
+ isbformat = 1;
+ chanmask = 0;
+ break;
}
bits = BytesFromDevFmt(device->FmtType) * 8;
channels = ChannelsFromDevFmt(device->FmtChans);
@@ -295,7 +312,8 @@ static ALCboolean ALCwaveBackend_reset(ALCwaveBackend *self)
// 32-bit val, channel mask
fwrite32le(chanmask, self->mFile);
// 16 byte GUID, sub-type format
- val = fwrite(((bits==32) ? SUBTYPE_FLOAT : SUBTYPE_PCM), 1, 16, self->mFile);
+ val = fwrite(((bits==32) ? (isbformat ? SUBTYPE_BFORMAT_FLOAT : SUBTYPE_FLOAT) :
+ (isbformat ? SUBTYPE_BFORMAT_PCM : SUBTYPE_PCM)), 1, 16, self->mFile);
(void)val;
fprintf(self->mFile, "data");