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.

Unison.h 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. ZynAddSubFX - a software synthesizer
  3. Unison.h - Unison effect (multivoice chorus)
  4. Copyright (C) 2002-2009 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. #ifndef UNISON_H
  18. #define UNISON_H
  19. #include "../Misc/Util.h"
  20. //how much the unison frequencies varies (always >= 1.0)
  21. #define UNISON_FREQ_SPAN 2.0f
  22. class Unison
  23. {
  24. public:
  25. Unison(int update_period_samples_, float max_delay_sec_, float srate_f);
  26. ~Unison();
  27. void setSize(int new_size);
  28. void setBaseFrequency(float freq);
  29. void setBandwidth(float bandwidth_cents);
  30. void process(int bufsize, float *inbuf, float *outbuf = NULL);
  31. private:
  32. void updateParameters(void);
  33. void updateUnisonData(void);
  34. int unison_size;
  35. float base_freq;
  36. struct UnisonVoice {
  37. float step; //base LFO
  38. float position;
  39. float realpos1; //the position regarding samples
  40. float realpos2;
  41. float relative_amplitude;
  42. float lin_fpos;
  43. float lin_ffreq;
  44. UnisonVoice() {
  45. position = RND * 1.8f - 0.9f;
  46. realpos1 = 0.0f;
  47. realpos2 = 0.0f;
  48. step = 0.0f;
  49. relative_amplitude = 1.0f;
  50. }
  51. } *uv;
  52. int update_period_samples;
  53. int update_period_sample_k;
  54. int max_delay, delay_k;
  55. bool first_time;
  56. float *delay_buffer;
  57. float unison_amplitude_samples;
  58. float unison_bandwidth_cents;
  59. // current setup
  60. float samplerate_f;
  61. };
  62. #endif