aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2013-11-27 18:52:56 -0800
committerChris Robinson <[email protected]>2013-11-27 18:52:56 -0800
commit182b08d8bcdcadf408f03c108ed03296a34f717f (patch)
tree487236aeb4601f39d9cc33efc0f9ee1280a94bcd
parent5554b8cfc93db026812dafa695d5f7a3450a40a7 (diff)
Create and use a MidiSynth on playback devices
-rw-r--r--Alc/ALc.c25
-rw-r--r--Alc/ALu.c3
2 files changed, 28 insertions, 0 deletions
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)
{