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.

89 lines
1.6KB

  1. #pragma once
  2. #include "bogaudio.hpp"
  3. #include "dsp/oscillator.hpp"
  4. #include "dsp/signal.hpp"
  5. using namespace bogaudio::dsp;
  6. extern Model* modelLFO;
  7. namespace bogaudio {
  8. struct LFO : Module {
  9. enum ParamsIds {
  10. FREQUENCY_PARAM,
  11. SLOW_PARAM,
  12. SAMPLE_PARAM,
  13. PW_PARAM,
  14. OFFSET_PARAM,
  15. SCALE_PARAM,
  16. NUM_PARAMS
  17. };
  18. enum InputsIds {
  19. SAMPLE_INPUT,
  20. PW_INPUT,
  21. OFFSET_INPUT,
  22. SCALE_INPUT,
  23. PITCH_INPUT,
  24. RESET_INPUT,
  25. NUM_INPUTS
  26. };
  27. enum OutputsIds {
  28. RAMP_UP_OUTPUT,
  29. RAMP_DOWN_OUTPUT,
  30. SQUARE_OUTPUT,
  31. TRIANGLE_OUTPUT,
  32. SINE_OUTPUT,
  33. NUM_OUTPUTS
  34. };
  35. enum LightsIds {
  36. SLOW_LIGHT,
  37. NUM_LIGHTS
  38. };
  39. const int modulationSteps = 100;
  40. const float amplitude = 5.0f;
  41. int _modulationStep = 0;
  42. bool _slowMode = false;
  43. int _sampleSteps = 1;
  44. int _sampleStep = 0;
  45. float _offset = 0.0f;
  46. float _scale = 0.0f;
  47. PositiveZeroCrossing _resetTrigger;
  48. Phasor _phasor;
  49. SineTableOscillator _sine;
  50. TriangleOscillator _triangle;
  51. SawOscillator _ramp;
  52. SquareOscillator _square;
  53. float _sineSample = 0.0f;
  54. float _triangleSample = 0.0f;
  55. float _rampUpSample = 0.0f;
  56. float _rampDownSample = 0.0f;
  57. float _squareSample = 0.0f;
  58. bool _sineActive = false;
  59. bool _triangleActive = false;
  60. bool _rampUpActive = false;
  61. bool _rampDownActive = false;
  62. bool _squareActive = false;
  63. LFO() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS) {
  64. onReset();
  65. onSampleRateChange();
  66. }
  67. void onReset() override;
  68. void onSampleRateChange() override;
  69. void step() override;
  70. void updateOutput(Phasor& wave, bool useSample, bool invert, Output& output, float& sample, bool& active);
  71. };
  72. } // namespace bogaudio