From acb37581da09714b63b9b23db190e0c85ba823c9 Mon Sep 17 00:00:00 2001 From: Werner Schweer Date: Tue, 19 Jun 2007 22:02:07 +0000 Subject: add missing files --- muse/synti/organ/reverb.cpp | 165 +++++++++++++++++++++++++++++++++++ muse/synti/organ/reverb.h | 208 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 373 insertions(+) create mode 100644 muse/synti/organ/reverb.cpp create mode 100644 muse/synti/organ/reverb.h diff --git a/muse/synti/organ/reverb.cpp b/muse/synti/organ/reverb.cpp new file mode 100644 index 00000000..975c8289 --- /dev/null +++ b/muse/synti/organ/reverb.cpp @@ -0,0 +1,165 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id:$ +// +// based on "freeverb" written by Jezar at Dreampoint, +// June 2000 +// +// (C) Copyright 2007 Werner Schweer (ws@seh.de) +//========================================================= + +#include "reverb.h" + +//--------------------------------------------------------- +// Reverb +//--------------------------------------------------------- + +Reverb::Reverb() + { + // Tie the components to their buffers + combL[0].setbuffer(bufcombL1,combtuningL1); + combR[0].setbuffer(bufcombR1,combtuningR1); + combL[1].setbuffer(bufcombL2,combtuningL2); + combR[1].setbuffer(bufcombR2,combtuningR2); + combL[2].setbuffer(bufcombL3,combtuningL3); + combR[2].setbuffer(bufcombR3,combtuningR3); + combL[3].setbuffer(bufcombL4,combtuningL4); + combR[3].setbuffer(bufcombR4,combtuningR4); + combL[4].setbuffer(bufcombL5,combtuningL5); + combR[4].setbuffer(bufcombR5,combtuningR5); + combL[5].setbuffer(bufcombL6,combtuningL6); + combR[5].setbuffer(bufcombR6,combtuningR6); + combL[6].setbuffer(bufcombL7,combtuningL7); + combR[6].setbuffer(bufcombR7,combtuningR7); + combL[7].setbuffer(bufcombL8,combtuningL8); + combR[7].setbuffer(bufcombR8,combtuningR8); + allpassL[0].setbuffer(bufallpassL1,allpasstuningL1); + allpassR[0].setbuffer(bufallpassR1,allpasstuningR1); + allpassL[1].setbuffer(bufallpassL2,allpasstuningL2); + allpassR[1].setbuffer(bufallpassR2,allpasstuningR2); + allpassL[2].setbuffer(bufallpassL3,allpasstuningL3); + allpassR[2].setbuffer(bufallpassR3,allpasstuningR3); + allpassL[3].setbuffer(bufallpassL4,allpasstuningL4); + allpassR[3].setbuffer(bufallpassR4,allpasstuningR4); + + // Set default values + allpassL[0].setfeedback(0.5f); + allpassR[0].setfeedback(0.5f); + allpassL[1].setfeedback(0.5f); + allpassR[1].setfeedback(0.5f); + allpassL[2].setfeedback(0.5f); + allpassR[2].setfeedback(0.5f); + allpassL[3].setfeedback(0.5f); + allpassR[3].setfeedback(0.5f); + + setRoomSize(.5); + setMix(.5); + setdamp(.5); + setwidth(initialwidth); + + // Buffer will be full of rubbish - so we MUST mute them + + for (int i = 0; i < numcombs; i++) { + combL[i].mute(); + combR[i].mute(); + } + for (int i=0;i= bufsize) + bufidx = 0; + return output; + } + void mute() { + memset(buffer, 0, sizeof(float) * bufsize); + } + void setfeedback(float val) { feedback = val; } + float getfeedback() { return feedback; } + }; + +//--------------------------------------------------------- +// comb +//--------------------------------------------------------- + +class comb + { + float feedback; + float filterstore; + float damp1; + float damp2; + float *buffer; + int bufsize; + int bufidx; + + public: + comb() { + filterstore = 0; + bufidx = 0; + } + void setbuffer(float *buf, int size) { + buffer = buf; + bufsize = size; + } + float process(float input) { + float output = buffer[bufidx]; + undenormalise(output); + filterstore = (output*damp2) + (filterstore*damp1); + undenormalise(filterstore); + buffer[bufidx] = input + (filterstore*feedback); + if (++bufidx >= bufsize) + bufidx = 0; + return output; + } + void mute() { + for (int i=0; i