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.

LFOParams.cpp 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*
  2. ZynAddSubFX - a software synthesizer
  3. LFOParams.cpp - Parameters for LFO
  4. Copyright (C) 2002-2005 Nasca Octavian Paul
  5. Author: Nasca Octavian Paul
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of version 2 of the GNU General Public License
  8. as published by the Free Software Foundation.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License (version 2 or later) for more details.
  13. You should have received a copy of the GNU General Public License (version 2)
  14. along with this program; if not, write to the Free Software Foundation,
  15. Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  16. */
  17. #include <math.h>
  18. #include <stdio.h>
  19. #include "../globals.h"
  20. #include "LFOParams.h"
  21. int LFOParams::time;
  22. LFOParams::LFOParams(char Pfreq_,
  23. char Pintensity_,
  24. char Pstartphase_,
  25. char PLFOtype_,
  26. char Prandomness_,
  27. char Pdelay_,
  28. char Pcontinous_,
  29. char fel_):Presets()
  30. {
  31. switch(fel_) {
  32. case 0:
  33. setpresettype("Plfofrequency");
  34. break;
  35. case 1:
  36. setpresettype("Plfoamplitude");
  37. break;
  38. case 2:
  39. setpresettype("Plfofilter");
  40. break;
  41. }
  42. Dfreq = Pfreq_;
  43. Dintensity = Pintensity_;
  44. Dstartphase = Pstartphase_;
  45. DLFOtype = PLFOtype_;
  46. Drandomness = Prandomness_;
  47. Ddelay = Pdelay_;
  48. Dcontinous = Pcontinous_;
  49. fel = fel_;
  50. time = 0;
  51. defaults();
  52. }
  53. LFOParams::~LFOParams()
  54. {}
  55. void LFOParams::defaults()
  56. {
  57. Pfreq = Dfreq / 127.0f;
  58. Pintensity = Dintensity;
  59. Pstartphase = Dstartphase;
  60. PLFOtype = DLFOtype;
  61. Prandomness = Drandomness;
  62. Pdelay = Ddelay;
  63. Pcontinous = Dcontinous;
  64. Pfreqrand = 0;
  65. Pstretch = 64;
  66. }
  67. void LFOParams::add2XML(XMLwrapper *xml)
  68. {
  69. xml->addparreal("freq", Pfreq);
  70. xml->addpar("intensity", Pintensity);
  71. xml->addpar("start_phase", Pstartphase);
  72. xml->addpar("lfo_type", PLFOtype);
  73. xml->addpar("randomness_amplitude", Prandomness);
  74. xml->addpar("randomness_frequency", Pfreqrand);
  75. xml->addpar("delay", Pdelay);
  76. xml->addpar("stretch", Pstretch);
  77. xml->addparbool("continous", Pcontinous);
  78. }
  79. void LFOParams::getfromXML(XMLwrapper *xml)
  80. {
  81. Pfreq = xml->getparreal("freq", Pfreq, 0.0f, 1.0f);
  82. Pintensity = xml->getpar127("intensity", Pintensity);
  83. Pstartphase = xml->getpar127("start_phase", Pstartphase);
  84. PLFOtype = xml->getpar127("lfo_type", PLFOtype);
  85. Prandomness = xml->getpar127("randomness_amplitude", Prandomness);
  86. Pfreqrand = xml->getpar127("randomness_frequency", Pfreqrand);
  87. Pdelay = xml->getpar127("delay", Pdelay);
  88. Pstretch = xml->getpar127("stretch", Pstretch);
  89. Pcontinous = xml->getparbool("continous", Pcontinous);
  90. }