From b29e06c00624660e6a297d9516e360b9aeec3c3e Mon Sep 17 00:00:00 2001 From: Peter Veenstra Date: Thu, 21 Jul 2011 14:26:16 +0000 Subject: [PATCH] Add patch 3161987 from Jason C. Penney: Add (optional) SoundFont support to midi_coreaudio synth. Added some extra info to dosbox.conf to describe this Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3733 --- src/dosbox.cpp | 1 + src/gui/midi_coreaudio.h | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/dosbox.cpp b/src/dosbox.cpp index 79fb5db8..40be085c 100644 --- a/src/dosbox.cpp +++ b/src/dosbox.cpp @@ -491,6 +491,7 @@ void DOSBOX_Init(void) { Pstring = secprop->Add_string("midiconfig",Property::Changeable::WhenIdle,""); Pstring->Set_help("Special configuration options for the device driver. This is usually the id of the device you want to use.\n" + " or in the case of coreaudio, you can specify a soundfont here.\n" " When using a Roland MT-32 rev. 0 as midi output device, some games may require a delay in order to prevent 'buffer overflow' issues.\n" " In that case, add 'delaysysex', for example: midiconfig=2 delaysysex\n" " See the README/Manual for more details."); diff --git a/src/gui/midi_coreaudio.h b/src/gui/midi_coreaudio.h index 0ffc60f1..ee6c752f 100644 --- a/src/gui/midi_coreaudio.h +++ b/src/gui/midi_coreaudio.h @@ -32,6 +32,7 @@ class MidiHandler_coreaudio : public MidiHandler { private: AUGraph m_auGraph; AudioUnit m_synth; + const char *soundfont; public: MidiHandler_coreaudio() : m_auGraph(0), m_synth(0) {} const char * GetName(void) { return "coreaudio"; } @@ -71,6 +72,22 @@ public: // Get the music device from the graph. RequireNoErr(AUGraphGetNodeInfo(m_auGraph, synthNode, NULL, NULL, NULL, &m_synth)); + // Optionally load a soundfont + if (conf && conf[0]) { + soundfont = conf; + FSRef soundfontRef; + RequireNoErr(FSPathMakeRef((const UInt8*)soundfont, &soundfontRef, NULL)); + RequireNoErr(AudioUnitSetProperty( + m_synth, + kMusicDeviceProperty_SoundBankFSRef, + kAudioUnitScope_Global, + 0, + &soundfontRef, + sizeof(soundfontRef) + )); + LOG_MSG("MIDI:coreaudio: loaded soundfont: %s",soundfont); + } + // Finally: Start the graph! RequireNoErr(AUGraphStart(m_auGraph));