aboutsummaryrefslogtreecommitdiff
path: root/backends
diff options
context:
space:
mode:
authorMax Horn2003-12-25 17:23:49 +0000
committerMax Horn2003-12-25 17:23:49 +0000
commitc07a290d8c147b7adf649dcd3943728437379738 (patch)
tree1edc709ba103ac4f2198b5ea0a5b09ce6bab7af5 /backends
parent67dcc6e1ba9e0637bd44e8154c15902bfc907d0d (diff)
downloadscummvm-rg350-c07a290d8c147b7adf649dcd3943728437379738.tar.gz
scummvm-rg350-c07a290d8c147b7adf649dcd3943728437379738.tar.bz2
scummvm-rg350-c07a290d8c147b7adf649dcd3943728437379738.zip
disable the reverb hack for now; at hacked in sound font support (specify 'soundfont' config option with path to a .SF2 file); simplify code a bit by using OpenDefaultComponent; allow usage of any music device, not just the DLSSynth (this may or may not help people with real MIDI devices)
svn-id: r11918
Diffstat (limited to 'backends')
-rw-r--r--backends/midi/coreaudio.cpp47
1 files changed, 36 insertions, 11 deletions
diff --git a/backends/midi/coreaudio.cpp b/backends/midi/coreaudio.cpp
index e2e032a53d..1231e781d6 100644
--- a/backends/midi/coreaudio.cpp
+++ b/backends/midi/coreaudio.cpp
@@ -20,6 +20,8 @@
#ifdef MACOSX
+#include "stdafx.h"
+#include "common/config-manager.h"
#include "sound/mpu401.h"
#include <AudioUnit/AudioUnit.h>
@@ -29,7 +31,7 @@
// midi backends. For some reasons, reverb will suck away a *lot* of CPU time.
// Until we know for sure what is causing this and if there is a better way to
// fix the problem, we just disable all reverb for these backends.
-#define COREAUDIO_REVERB_HACK
+//#define COREAUDIO_REVERB_HACK
/* CoreAudio MIDI driver
@@ -54,19 +56,42 @@ int MidiDriver_CORE::open() {
if (au_output != NULL)
return MERR_ALREADY_OPEN;
- int err;
+ OSStatus err;
AudioUnitConnection auconnect;
- ComponentDescription compdesc;
- Component compid;
// Open the Music Device
- compdesc.componentType = kAudioUnitComponentType;
- compdesc.componentSubType = kAudioUnitSubType_MusicDevice;
- compdesc.componentManufacturer = kAudioUnitID_DLSSynth;
- compdesc.componentFlags = 0;
- compdesc.componentFlagsMask = 0;
- compid = FindNextComponent(NULL, &compdesc);
- au_MusicDevice = (AudioUnit) OpenComponent(compid);
+ au_MusicDevice = (AudioUnit) OpenDefaultComponent(kAudioUnitComponentType, kAudioUnitSubType_MusicDevice);
+
+ if (au_MusicDevice == 0)
+ error("Failed opening CoreAudio music device");
+
+ // Load custom soundfont, if specified
+ // FIXME: This is kind of a temporary hack. Better (IMO) would be to
+ // query QuickTime for whatever custom soundfont was set in the
+ // QuickTime Preferences, and use that automatically.
+ if (ConfMan.hasKey("soundfont")) {
+ FSRef fsref;
+ FSSpec fsSpec;
+ const char *soundfont = ConfMan.get("soundfont").c_str();
+
+ err = FSPathMakeRef ((const byte *)soundfont, &fsref, NULL);
+
+ if (err == noErr) {
+ err = FSGetCatalogInfo (&fsref, kFSCatInfoNone, NULL, NULL, &fsSpec, NULL);
+ }
+
+ if (err == noErr) {
+ err = AudioUnitSetProperty (
+ au_MusicDevice,
+ kMusicDeviceProperty_SoundBankFSSpec, kAudioUnitScope_Global,
+ 0,
+ &fsSpec, sizeof(fsSpec)
+ );
+ }
+
+ if (err != noErr)
+ warning("Failed loading custom sound font '%s' (error %d)\n", soundfont, err);
+ }
// open the output unit
au_output = (AudioUnit) OpenDefaultComponent(kAudioUnitComponentType, kAudioUnitSubType_Output);