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.

72 lines
2.2KB

  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 2011, Alan Calvert
  6. Author: Nasca Octavian Paul
  7. This program is free software; you can redistribute it and/or modify
  8. it under the terms of version 2 of the GNU General Public License
  9. as published by the Free Software Foundation.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License (version 2 or later) for more details.
  14. You should have received a copy of the GNU General Public License (version 2)
  15. along with this program; if not, write to the Free Software Foundation,
  16. Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  17. */
  18. #include "Effect.h"
  19. #include "../Params/FilterParams.h"
  20. #include <cmath>
  21. EffectParams::EffectParams(Allocator &alloc_, bool insertion_, float *efxoutl_, float *efxoutr_,
  22. unsigned char Ppreset_, unsigned int srate_, int bufsize_, FilterParams *filterpars_)
  23. :alloc(alloc_), insertion(insertion_), efxoutl(efxoutl_), efxoutr(efxoutr_),
  24. Ppreset(Ppreset_), srate(srate_), bufsize(bufsize_), filterpars(filterpars_)
  25. {}
  26. Effect::Effect(EffectParams pars)
  27. :Ppreset(pars.Ppreset),
  28. efxoutl(pars.efxoutl),
  29. efxoutr(pars.efxoutr),
  30. filterpars(pars.filterpars),
  31. insertion(pars.insertion),
  32. memory(pars.alloc),
  33. samplerate(pars.srate),
  34. buffersize(pars.bufsize)
  35. {
  36. alias();
  37. }
  38. void Effect::out(float *const smpsl, float *const smpsr)
  39. {
  40. out(Stereo<float *>(smpsl, smpsr));
  41. }
  42. void Effect::crossover(float &a, float &b, float crossover)
  43. {
  44. float tmpa = a;
  45. float tmpb = b;
  46. a = tmpa * (1.0f - crossover) + tmpb * crossover;
  47. b = tmpb * (1.0f - crossover) + tmpa * crossover;
  48. }
  49. void Effect::setpanning(char Ppanning_)
  50. {
  51. Ppanning = Ppanning_;
  52. float t = (Ppanning > 0) ? (float)(Ppanning - 1) / 126.0f : 0.0f;
  53. pangainL = cosf(t * PI / 2.0f);
  54. pangainR = cosf((1.0f - t) * PI / 2.0f);
  55. }
  56. void Effect::setlrcross(char Plrcross_)
  57. {
  58. Plrcross = Plrcross_;
  59. lrcross = (float)Plrcross / 127.0f;
  60. }