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.

79 lines
2.3KB

  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 Allocator;
  23. class Unison
  24. {
  25. public:
  26. Unison(Allocator *alloc_, int update_period_samples_, float max_delay_sec_, float srate_f);
  27. ~Unison();
  28. void setSize(int new_size);
  29. void setBaseFrequency(float freq);
  30. void setBandwidth(float bandwidth_cents);
  31. void process(int bufsize, float *inbuf, float *outbuf = NULL);
  32. private:
  33. void updateParameters(void);
  34. void updateUnisonData(void);
  35. int unison_size;
  36. float base_freq;
  37. struct UnisonVoice {
  38. float step; //base LFO
  39. float position;
  40. float realpos1; //the position regarding samples
  41. float realpos2;
  42. float relative_amplitude;
  43. float lin_fpos;
  44. float lin_ffreq;
  45. UnisonVoice() {
  46. position = RND * 1.8f - 0.9f;
  47. realpos1 = 0.0f;
  48. realpos2 = 0.0f;
  49. step = 0.0f;
  50. relative_amplitude = 1.0f;
  51. }
  52. } *uv;
  53. int update_period_samples;
  54. int update_period_sample_k;
  55. int max_delay, delay_k;
  56. bool first_time;
  57. float *delay_buffer;
  58. float unison_amplitude_samples;
  59. float unison_bandwidth_cents;
  60. // current setup
  61. float samplerate_f;
  62. Allocator &alloc;
  63. };
  64. #endif