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.

Effect.cpp 2.0KB

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