zynaddsubfx

ZynAddSubFX open source synthesizer
Log | Files | Refs | Submodules | LICENSE

Effect.cpp (2039B)


      1 /*
      2   ZynAddSubFX - a software synthesizer
      3 
      4   Effect.cpp - this class is inherited by the all effects(Reverb, Echo, ..)
      5   Copyright (C) 2002-2005 Nasca Octavian Paul
      6   Copyright (C) 2011 Alan Calvert
      7   Copyright (C) 2015 Mark McCurry
      8   Author: Nasca Octavian Paul
      9 
     10   This program is free software; you can redistribute it and/or
     11   modify it under the terms of the GNU General Public License
     12   as published by the Free Software Foundation; either version 2
     13   of the License, or (at your option) any later version.
     14 */
     15 
     16 #include "Effect.h"
     17 #include "../Params/FilterParams.h"
     18 #include <cmath>
     19 
     20 namespace zyn {
     21 
     22 EffectParams::EffectParams(Allocator &alloc_, bool insertion_, float *efxoutl_, float *efxoutr_,
     23             unsigned char Ppreset_, unsigned int srate_, int bufsize_, FilterParams *filterpars_,
     24             bool filterprotect_, const AbsTime *time_)
     25     :alloc(alloc_), insertion(insertion_), efxoutl(efxoutl_), efxoutr(efxoutr_),
     26      Ppreset(Ppreset_), srate(srate_), bufsize(bufsize_), filterpars(filterpars_),
     27      filterprotect(filterprotect_), time(time_)
     28 {}
     29 Effect::Effect(EffectParams pars)
     30     :Ppreset(pars.Ppreset),
     31       efxoutl(pars.efxoutl),
     32       efxoutr(pars.efxoutr),
     33       filterpars(pars.filterpars),
     34       insertion(pars.insertion),
     35       memory(pars.alloc),
     36       time(pars.time),
     37       samplerate(pars.srate),
     38       buffersize(pars.bufsize)
     39 {
     40     alias();
     41 }
     42 
     43 void Effect::out(float *const smpsl, float *const smpsr)
     44 {
     45     out(Stereo<float *>(smpsl, smpsr));
     46 }
     47 
     48 void Effect::crossover(float &a, float &b, float crossover)
     49 {
     50     float tmpa = a;
     51     float tmpb = b;
     52     a = tmpa * (1.0f - crossover) + tmpb * crossover;
     53     b = tmpb * (1.0f - crossover) + tmpa * crossover;
     54 }
     55 
     56 void Effect::setpanning(char Ppanning_)
     57 {
     58     Ppanning = Ppanning_;
     59     float t = (Ppanning > 0) ? (float)(Ppanning - 1) / 126.0f : 0.0f;
     60     pangainL = cosf(t * PI / 2.0f);
     61     pangainR = cosf((1.0f - t) * PI / 2.0f);
     62 }
     63 
     64 void Effect::setlrcross(char Plrcross_)
     65 {
     66     Plrcross = Plrcross_;
     67     lrcross  = (float)Plrcross / 127.0f;
     68 }
     69 
     70 }