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

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