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.

110 lines
2.0KB

  1. #pragma once
  2. #include "bogaudio.hpp"
  3. #include "dsp/oscillator.hpp"
  4. #include "dsp/pitch.hpp"
  5. #include "dsp/signal.hpp"
  6. using namespace bogaudio::dsp;
  7. extern Model* modelAdditator;
  8. namespace bogaudio {
  9. struct Additator : Module {
  10. enum ParamsIds {
  11. FREQUENCY_PARAM,
  12. PARTIALS_PARAM,
  13. WIDTH_PARAM,
  14. ODD_SKEW_PARAM,
  15. EVEN_SKEW_PARAM,
  16. GAIN_PARAM,
  17. DECAY_PARAM,
  18. BALANCE_PARAM,
  19. FILTER_PARAM,
  20. PHASE_PARAM,
  21. FINE_PARAM,
  22. NUM_PARAMS
  23. };
  24. enum InputsIds {
  25. PITCH_INPUT,
  26. SYNC_INPUT,
  27. PARTIALS_INPUT,
  28. WIDTH_INPUT,
  29. ODD_SKEW_INPUT,
  30. EVEN_SKEW_INPUT,
  31. GAIN_INPUT,
  32. DECAY_INPUT,
  33. BALANCE_INPUT,
  34. FILTER_INPUT,
  35. NUM_INPUTS
  36. };
  37. enum OutputsIds {
  38. AUDIO_OUTPUT,
  39. NUM_OUTPUTS
  40. };
  41. enum LightsIds {
  42. SINE_LIGHT,
  43. COSINE_LIGHT,
  44. NUM_LIGHTS
  45. };
  46. enum Phase {
  47. PHASE_RESET,
  48. PHASE_SINE,
  49. PHASE_COSINE
  50. };
  51. const int modulationSteps = 100;
  52. const int maxPartials = 100;
  53. const float maxWidth = 2.0f;
  54. const float maxSkew = 0.99f;
  55. const float minAmplitudeNormalization = 1.0f;
  56. const float maxAmplitudeNormalization = 5.0f;
  57. const float minDecay = -1.0f;
  58. const float maxDecay = 3.0f;
  59. const float minFilter = 0.1;
  60. const float maxFilter = 1.9;
  61. const float slewLimitTime = 1.0f;
  62. int _steps = 0;
  63. int _partials = 0;
  64. float _width = 0.0f;
  65. float _oddSkew = 0.0f;
  66. float _evenSkew = 0.0f;
  67. float _amplitudeNormalization = 0.0f;
  68. float _decay = 0.0f;
  69. float _balance = 0.0f;
  70. float _filter = 0.0f;
  71. Phase _phase = PHASE_RESET;
  72. float _maxFrequency = 0.0f;
  73. int _activePartials = 1;
  74. SineBankOscillator _oscillator;
  75. PositiveZeroCrossing _syncTrigger;
  76. SlewLimiter _widthSL;
  77. SlewLimiter _oddSkewSL;
  78. SlewLimiter _evenSkewSL;
  79. SlewLimiter _amplitudeNormalizationSL;
  80. SlewLimiter _decaySL;
  81. SlewLimiter _balanceSL;
  82. SlewLimiter _filterSL;
  83. Additator()
  84. : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS)
  85. , _oscillator(1000.0f, 100.0f, maxPartials)
  86. {
  87. onReset();
  88. onSampleRateChange();
  89. }
  90. void onReset() override;
  91. void onSampleRateChange() override;
  92. float cvValue(Input& cv, bool dc = false);
  93. void step() override;
  94. };
  95. } // namespace bogaudio