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.

71 lines
1.9KB

  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
  7. modify it under the terms of the GNU General Public License
  8. as published by the Free Software Foundation; either version 2
  9. of the License, or (at your option) any later version.
  10. */
  11. #ifndef UNISON_H
  12. #define UNISON_H
  13. #include "../Misc/Util.h"
  14. //how much the unison frequencies varies (always >= 1.0)
  15. #define UNISON_FREQ_SPAN 2.0f
  16. class Allocator;
  17. class Unison
  18. {
  19. public:
  20. Unison(Allocator *alloc_, int update_period_samples_, float max_delay_sec_, float srate_f);
  21. ~Unison();
  22. void setSize(int new_size);
  23. void setBaseFrequency(float freq);
  24. void setBandwidth(float bandwidth_cents);
  25. void process(int bufsize, float *inbuf, float *outbuf = NULL);
  26. private:
  27. void updateParameters(void);
  28. void updateUnisonData(void);
  29. int unison_size;
  30. float base_freq;
  31. struct UnisonVoice {
  32. float step; //base LFO
  33. float position;
  34. float realpos1; //the position regarding samples
  35. float realpos2;
  36. float relative_amplitude;
  37. float lin_fpos;
  38. float lin_ffreq;
  39. UnisonVoice() {
  40. position = RND * 1.8f - 0.9f;
  41. realpos1 = 0.0f;
  42. realpos2 = 0.0f;
  43. step = 0.0f;
  44. relative_amplitude = 1.0f;
  45. }
  46. } *uv;
  47. int update_period_samples;
  48. int update_period_sample_k;
  49. int max_delay, delay_k;
  50. bool first_time;
  51. float *delay_buffer;
  52. float unison_amplitude_samples;
  53. float unison_bandwidth_cents;
  54. // current setup
  55. float samplerate_f;
  56. Allocator &alloc;
  57. };
  58. #endif