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 1.9KB

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