Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
1.9KB

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