From e40fc849149dd97c248866a4a1d026dda5e57b62 Mon Sep 17 00:00:00 2001 From: Robert Jonsson Date: Mon, 7 Mar 2011 19:01:11 +0000 Subject: clean3 --- .../synti/zynaddsubfx/Effects/EffectMgr.C | 292 +++++++++++++++++++++ 1 file changed, 292 insertions(+) create mode 100644 attic/muse_qt4_evolution/synti/zynaddsubfx/Effects/EffectMgr.C (limited to 'attic/muse_qt4_evolution/synti/zynaddsubfx/Effects/EffectMgr.C') diff --git a/attic/muse_qt4_evolution/synti/zynaddsubfx/Effects/EffectMgr.C b/attic/muse_qt4_evolution/synti/zynaddsubfx/Effects/EffectMgr.C new file mode 100644 index 00000000..efdb672a --- /dev/null +++ b/attic/muse_qt4_evolution/synti/zynaddsubfx/Effects/EffectMgr.C @@ -0,0 +1,292 @@ +/* + ZynAddSubFX - a software synthesizer + + EffectMgr.C - Effect manager, an interface betwen the program and effects + Copyright (C) 2002-2005 Nasca Octavian Paul + Author: Nasca Octavian Paul + + This program is free software; you can redistribute it and/or modify + it under the terms of version 2 of the GNU General Public License + as published by the Free Software Foundation. + + 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 (version 2) for more details. + + You should have received a copy of the GNU General Public License (version 2) + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*/ + +#include +#include +#include "EffectMgr.h" +#include "../Misc/Master.h" + +EffectMgr::EffectMgr(int insertion_,Master* master_){ + setpresettype("Peffect"); + efx=NULL; + nefx=0; + insertion=insertion_; + master=master_; + efxoutl=new REALTYPE[SOUND_BUFFER_SIZE]; + efxoutr=new REALTYPE[SOUND_BUFFER_SIZE];; + for (int i=0;ifilterpars; +}; + +/* + * Obtain the effect number + */ +int EffectMgr::geteffect(){ + return (nefx); +}; + +/* + * Cleanup the current effect + */ +void EffectMgr::cleanup(){ + if (efx!=NULL) efx->cleanup(); +}; + + +/* + * Get the preset of the current effect + */ + +unsigned char EffectMgr::getpreset(){ + if (efx!=NULL) return(efx->Ppreset); + else return(0); +}; + +/* + * Change the preset of the current effect + */ +void EffectMgr::changepreset_nolock(unsigned char npreset){ + if (efx!=NULL) efx->setpreset(npreset); +}; + +/* + * Change the preset of the current effect(with thread locking) + */ +void EffectMgr::changepreset(unsigned char npreset){ + master->lock(); + changepreset_nolock(npreset); + master->unlock(); +}; + + +/* + * Change a parameter of the current effect + */ +void EffectMgr::seteffectpar_nolock(int npar,unsigned char value){ + if (efx==NULL) return; + efx->changepar(npar,value); +}; + +/* + * Change a parameter of the current effect (with thread locking) + */ +void EffectMgr::seteffectpar(int npar,unsigned char value){ + master->lock(); + seteffectpar_nolock(npar,value); + master->unlock(); +}; + +/* + * Get a parameter of the current effect + */ +unsigned char EffectMgr::geteffectpar(int npar){ + if (efx==NULL) return(0); + return(efx->getpar(npar)); +}; + + +/* + * Apply the effect + */ +void EffectMgr::out(REALTYPE *smpsl,REALTYPE *smpsr){ + int i; + if (efx==NULL){ + if (insertion==0) + for (i=0;iout(smpsl,smpsr); + + REALTYPE volume=efx->volume; + + if (nefx==7){//this is need only for the EQ effect + for (i=0;ioutvolume); +}; + + +/* + * Get the EQ response + */ +REALTYPE EffectMgr::getEQfreqresponse(REALTYPE freq){ + if (nefx==7) return(efx->getfreqresponse(freq)); + else return(0.0); +}; + + +void EffectMgr::setdryonly(bool value){ + dryonly=value; +}; + +void EffectMgr::add2XML(XMLwrapper *xml){ + xml->addpar("type",geteffect()); + + if ((efx==NULL)||(geteffect()==0)) return; + xml->addpar("preset",efx->Ppreset); + + xml->beginbranch("EFFECT_PARAMETERS"); + for (int n=0;n<128;n++){ + int par=geteffectpar(n); + if (par==0) continue; + xml->beginbranch("par_no",n); + xml->addpar("par",par); + xml->endbranch(); + }; + if (filterpars!=NULL){ + xml->beginbranch("FILTER"); + filterpars->add2XML(xml); + xml->endbranch(); + }; + xml->endbranch(); +}; + +void EffectMgr::getfromXML(XMLwrapper *xml){ + changeeffect(xml->getpar127("type",geteffect())); + + if ((efx==NULL)||(geteffect()==0)) return; + + efx->Ppreset=xml->getpar127("preset",efx->Ppreset); + + if (xml->enterbranch("EFFECT_PARAMETERS")){ + for (int n=0;n<128;n++){ + seteffectpar_nolock(n,0);//erase effect parameter + if (xml->enterbranch("par_no",n)==0) continue; + + int par=geteffectpar(n); + seteffectpar_nolock(n,xml->getpar127("par",par)); + xml->exitbranch(); + }; + if (filterpars!=NULL){ + if (xml->enterbranch("FILTER")){ + filterpars->getfromXML(xml); + xml->exitbranch(); + }; + }; + xml->exitbranch(); + }; + cleanup(); +}; + + + -- cgit v1.2.3