From 030e155eeb7f82dc89315dbefa43e09a411c6110 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Thu, 9 Feb 2012 11:20:45 +0200 Subject: MT32: Update MT-32 emulator to latest Munt code Several changes against original code were made. They were intentionally kept to the minimum --- audio/softsynth/mt32/freeverb.cpp | 357 ++++++++++++++++++++------------------ 1 file changed, 187 insertions(+), 170 deletions(-) (limited to 'audio/softsynth/mt32/freeverb.cpp') diff --git a/audio/softsynth/mt32/freeverb.cpp b/audio/softsynth/mt32/freeverb.cpp index 67f065c20e..de8f2632cb 100644 --- a/audio/softsynth/mt32/freeverb.cpp +++ b/audio/softsynth/mt32/freeverb.cpp @@ -1,245 +1,245 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -// Comb filter implementation +// Allpass filter implementation // -// Written by +// Written by Jezar at Dreampoint, June 2000 // http://www.dreampoint.co.uk // This code is public domain -#include "audio/softsynth/mt32/freeverb.h" +#include "freeverb.h" -comb::comb() { - filterstore = 0; +allpass::allpass() +{ bufidx = 0; } -void comb::setbuffer(float *buf, int size) { +void allpass::setbuffer(float *buf, int size) +{ buffer = buf; bufsize = size; } -void comb::mute() { - for (int i = 0; i < bufsize; i++) - buffer[i] = 0; -} - -void comb::setdamp(float val) { - damp1 = val; - damp2 = 1 - val; -} - -float comb::getdamp() { - return damp1; +void allpass::mute() +{ + for (int i=0; i= freezemode) return; - for (i = 0; i < numcombs; i++) { + for (i=0;i 0) { - int i; - - outL = outR = 0; - input = (*inputL + *inputR) * gain; - - // Accumulate comb filters in parallel - for (i = 0; i < numcombs; i++) { - outL += combL[i].process(input); - outR += combR[i].process(input); - } - // Feed through allpasses in series - for (i = 0; i < numallpasses; i++) { - outL = allpassL[i].process(outL); - outR = allpassR[i].process(outR); - } - - // Calculate output REPLACING anything already there - *outputL = outL * wet1 + outR * wet2 + *inputL * dry; - *outputR = outR * wet1 + outL * wet2 + *inputR * dry; - - // Increment sample pointers, allowing for interleave (if any) - inputL += skip; - inputR += skip; - outputL += skip; - outputR += skip; - } + // Init LPF history + filtprev1 = 0; + filtprev2 = 0; } -void revmodel::processmix(float *inputL, float *inputR, float *outputL, float *outputR, long numsamples, int skip) { - float outL, outR, input; +void revmodel::process(const float *inputL, const float *inputR, float *outputL, float *outputR, long numsamples) +{ + float outL,outR,input; - while (numsamples-- > 0) { + while (numsamples-- > 0) + { int i; outL = outR = 0; input = (*inputL + *inputR) * gain; + // Implementation of 2-stage IIR single-pole low-pass filter + // found at the entrance of reverb processing on real devices + filtprev1 += (input - filtprev1) * filtval; + filtprev2 += (filtprev1 - filtprev2) * filtval; + input = filtprev2; + + int s = -1; // Accumulate comb filters in parallel - for (i = 0; i < numcombs; i++) { - outL += combL[i].process(input); - outR += combR[i].process(input); + for (i=0; i= freezemode) { + if (mode >= freezemode) + { roomsize1 = 1; damp1 = 0; gain = muted; - } else { + } + else + { roomsize1 = roomsize; damp1 = damp; gain = fixedgain; } - for (i = 0; i < numcombs; i++) { + for (i=0; i= freezemode) return 1; else return 0; } + +void revmodel::setfiltval(float value) +{ + filtval = value; +} -- cgit v1.2.3