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.

64 lines
1.8KB

  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. :alloc(alloc_), insertion(insertion_), efxoutl(efxoutl_), efxoutr(efxoutr_),
  19. Ppreset(Ppreset_), srate(srate_), bufsize(bufsize_), filterpars(filterpars_)
  20. {}
  21. Effect::Effect(EffectParams pars)
  22. :Ppreset(pars.Ppreset),
  23. efxoutl(pars.efxoutl),
  24. efxoutr(pars.efxoutr),
  25. filterpars(pars.filterpars),
  26. insertion(pars.insertion),
  27. memory(pars.alloc),
  28. samplerate(pars.srate),
  29. buffersize(pars.bufsize)
  30. {
  31. alias();
  32. }
  33. void Effect::out(float *const smpsl, float *const smpsr)
  34. {
  35. out(Stereo<float *>(smpsl, smpsr));
  36. }
  37. void Effect::crossover(float &a, float &b, float crossover)
  38. {
  39. float tmpa = a;
  40. float tmpb = b;
  41. a = tmpa * (1.0f - crossover) + tmpb * crossover;
  42. b = tmpb * (1.0f - crossover) + tmpa * crossover;
  43. }
  44. void Effect::setpanning(char Ppanning_)
  45. {
  46. Ppanning = Ppanning_;
  47. float t = (Ppanning > 0) ? (float)(Ppanning - 1) / 126.0f : 0.0f;
  48. pangainL = cosf(t * PI / 2.0f);
  49. pangainR = cosf((1.0f - t) * PI / 2.0f);
  50. }
  51. void Effect::setlrcross(char Plrcross_)
  52. {
  53. Plrcross = Plrcross_;
  54. lrcross = (float)Plrcross / 127.0f;
  55. }