#pragma once #include #include "Params.h" #include "Wavetable.h" #include "SynthVoice.h" #include "LFO.h" #include "FXProcessor.h" #include "ModulationMatrix.h" #include "MacroControls.h" namespace serum { // =========================================================================== // The synthesis engine: a fixed pool of voices, four global LFOs, a wavetable // library and the FX rack. Owns all per-block DSP and MIDI handling. // =========================================================================== class Engine { public: void prepare (double sampleRate, int blockSize); void reset(); void processBlock (juce::AudioBuffer& buffer, juce::MidiBuffer& midi, juce::AudioProcessorValueTreeState& apvts, juce::AudioPlayHead* playhead); // MIDI void noteOn (int noteNumber, float velocity01); void noteOff (int noteNumber); void allNotesOff(); // Modulation / DSP accessors (read-only for the GUI). ModulationMatrix& getMatrix() { return matrix; } MacroControls& getMacros() { return macros; } WavetableLibrary& getWavetables() { return wavetables; } const std::array& getLfos() const { return lfos; } void setLfoShapeData (int index, const std::vector& data, int steps); int getActiveVoiceCount() const; private: std::array voices; std::array lfos; WavetableLibrary wavetables; FXProcessor fx; ModulationMatrix matrix; MacroControls macros; double sr = 44100.0; int blockSize = 512; double bpm = 120.0; float pitchBend = 0.0f; float modWheel = 0.0f; juce::uint64 noteCounter = 0; juce::AudioBuffer mixBuffer; SynthVoice* findFreeVoice(); SynthVoice* stealVoice(); void readOscParams (juce::AudioProcessorValueTreeState& apvts, const char* prefix, OscParams& out); }; } // namespace serum