From bd68cd0517c825742407fead7050f72c32b64443 Mon Sep 17 00:00:00 2001 From: Stefano Ceccherini Date: Sat, 20 Sep 2014 19:19:12 +0200 Subject: [PATCH] Midi Kit: SoftSynth: Implement reverb (patch by Pete Goodeve) Applied patch by Pete Goodeve which implements reverb in the soft synthesizer. --- src/kits/midi/SoftSynth.cpp | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/kits/midi/SoftSynth.cpp b/src/kits/midi/SoftSynth.cpp index 3d2c5831ca..f55d87eb24 100644 --- a/src/kits/midi/SoftSynth.cpp +++ b/src/kits/midi/SoftSynth.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2006, Haiku. + * Copyright 2006-2014, Haiku. * * Copyright (c) 2004-2005 Matthijs Hollemans * Copyright (c) 2003 Jerome Leveque @@ -9,6 +9,7 @@ * Jérôme Duval * Jérôme Leveque * Matthijs Hollemans + * Pete Goodeve */ #include @@ -26,6 +27,18 @@ using namespace BPrivate; const static char* kSynthFileName = "synth.sf2"; +struct ReverbSettings { + double room, damp, width, level; + } gReverbSettings[] = { + {0.0, 0.0, 0.0, 0.0}, // B_REVERB_NONE + {0.2, 0.0, 0.5, 0.9}, // B_REVERB_CLOSET + {0.5, 0.0, 0.9, 0.9}, // B_REVERB_GARAGE + {0.7, 0.25, 0.9, 0.95}, // B_REVERB_BALLROOM + {0.99, 0.3, 1.0, 1.0}, // B_REVERB_CAVERN + {1.03, 0.6, 1.0, 1.0} // B_REVERB_DUNGEON + }; + + BSoftSynth::BSoftSynth() : fInitCheck(false), fSynth(NULL), @@ -232,9 +245,15 @@ BSoftSynth::IsReverbEnabled() const void BSoftSynth::SetReverb(reverb_mode mode) { - // TODO: this function could change depending on the synth back-end. + if (mode < B_REVERB_NONE || mode > B_REVERB_DUNGEON) + return; fReverbMode = mode; + if (fSynth) { + // We access the table using "mode - 1" because B_REVERB_NONE == 1 + ReverbSettings *rvb = &gReverbSettings[mode - 1]; + fluid_synth_set_reverb(fSynth, rvb->room, rvb->damp, rvb->width, rvb->level); + } } @@ -458,6 +477,8 @@ BSoftSynth::_Init() return; } + SetReverb(fReverbMode); + media_raw_audio_format format = media_raw_audio_format::wildcard; format.channel_count = 2; format.frame_rate = fSampleRate;