private void InitializeFluidsynth() { if (FluidsynthInitialized) { return; } _settings = new Settings(); _settings["synth.sample-rate"].DoubleValue = 48000; _settings["player.timing-source"].StringValue = "sample"; _settings["synth.lock-memory"].IntValue = 0; _settings["synth.threadsafe-api"].IntValue = 1; _settings["synth.gain"].DoubleValue = 0.5d; _settings["audio.driver"].StringValue = "file"; _settings["midi.autoconnect"].IntValue = 1; _settings["player.reset-synth"].IntValue = 0; _settings["synth.midi-bank-select"].StringValue = "gm"; _midiThread = new Thread(ThreadUpdate); _midiThread.Start(); _soundfontLoaderCallbacks = new ResourceLoaderCallbacks(); FluidsynthInitialized = true; }
private void InitializeFluidsynth() { if (FluidsynthInitialized || _failedInitialize) { return; } try { _loggerDelegate = LoggerDelegate; _sawmill = Logger.GetSawmill("midi.fluidsynth"); NFluidsynth.Logger.SetLoggerMethod(_loggerDelegate); // Will cause a safe DllNotFoundException if not available. _settings = new Settings(); _settings["synth.sample-rate"].DoubleValue = 44100; _settings["player.timing-source"].StringValue = "sample"; _settings["synth.lock-memory"].IntValue = 0; _settings["synth.threadsafe-api"].IntValue = 1; _settings["synth.gain"].DoubleValue = 1.0d; _settings["audio.driver"].StringValue = "file"; _settings["midi.autoconnect"].IntValue = 1; _settings["player.reset-synth"].IntValue = 0; _settings["synth.midi-bank-select"].StringValue = "gm"; } catch (Exception e) { Logger.WarningS("midi", "Failed to initialize fluidsynth due to exception, disabling MIDI support:\n{0}", e); _failedInitialize = true; return; } _midiThread = new Thread(ThreadUpdate); _midiThread.Start(); _midiSawmill = IoCManager.Resolve <ILogManager>().GetSawmill("midi"); _soundfontLoaderCallbacks = new ResourceLoaderCallbacks(); FluidsynthInitialized = true; }