From 182b08d8bcdcadf408f03c108ed03296a34f717f Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Wed, 27 Nov 2013 18:52:56 -0800 Subject: Create and use a MidiSynth on playback devices --- Alc/ALc.c | 25 +++++++++++++++++++++++++ Alc/ALu.c | 3 +++ 2 files changed, 28 insertions(+) diff --git a/Alc/ALc.c b/Alc/ALc.c index a4e2e95e..cc528052 100644 --- a/Alc/ALc.c +++ b/Alc/ALc.c @@ -30,6 +30,7 @@ #include "alMain.h" #include "alSource.h" #include "alListener.h" +#include "alMidi.h" #include "alThunk.h" #include "alSource.h" #include "alBuffer.h" @@ -1773,6 +1774,8 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) device->PendingClicks[i] = 0.0f; } + V(device->Synth,update)(device); + device->Hrtf = NULL; if(device->Type != Loopback && ConfigValueExists(NULL, "hrtf")) { @@ -1899,6 +1902,9 @@ static ALCvoid FreeDevice(ALCdevice *device) DELETE_OBJ(device->Backend); device->Backend = NULL; + DELETE_OBJ(device->Synth); + device->Synth = NULL; + if(device->DefaultSlot) { ALeffectState *state = device->DefaultSlot->EffectState; @@ -3024,9 +3030,19 @@ ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *deviceName) device->NumStereoSources = 1; device->NumMonoSources = device->MaxNoOfSources - device->NumStereoSources; + device->Synth = SynthCreate(device); + if(!device->Synth) + { + DELETE_OBJ(device->Backend); + al_free(device); + alcSetError(NULL, ALC_OUT_OF_MEMORY); + return NULL; + } + // Find a playback device to open if((err=V(device->Backend,open)(deviceName)) != ALC_NO_ERROR) { + DELETE_OBJ(device->Synth); DELETE_OBJ(device->Backend); al_free(device); alcSetError(NULL, err); @@ -3344,6 +3360,15 @@ ALC_API ALCdevice* ALC_APIENTRY alcLoopbackOpenDeviceSOFT(const ALCchar *deviceN device->NumStereoSources = 1; device->NumMonoSources = device->MaxNoOfSources - device->NumStereoSources; + device->Synth = SynthCreate(device); + if(!device->Synth) + { + DELETE_OBJ(device->Backend); + al_free(device); + alcSetError(NULL, ALC_OUT_OF_MEMORY); + return NULL; + } + // Open the "backend" V(device->Backend,open)("Loopback"); do { diff --git a/Alc/ALu.c b/Alc/ALu.c index e7a3c035..4ac7250b 100644 --- a/Alc/ALu.c +++ b/Alc/ALu.c @@ -31,6 +31,7 @@ #include "alBuffer.h" #include "alListener.h" #include "alAuxEffectSlot.h" +#include "alMidi.h" #include "alu.h" #include "bs2b.h" @@ -1028,6 +1029,8 @@ ALvoid aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size) memset(device->DryBuffer[c], 0, SamplesToDo*sizeof(ALfloat)); ALCdevice_Lock(device); + V(device->Synth,process)(SamplesToDo, device->DryBuffer); + ctx = device->ContextList; while(ctx) { -- cgit v1.2.3