feat(dsp): add core synthesizer oscillators, wavetable and voice engine
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
#pragma once
|
||||
|
||||
#include <JuceHeader.h>
|
||||
#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<float>& 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<LFO, kNumLfos>& getLfos() const { return lfos; }
|
||||
void setLfoShapeData (int index, const std::vector<float>& data, int steps);
|
||||
|
||||
int getActiveVoiceCount() const;
|
||||
|
||||
private:
|
||||
std::array<SynthVoice, kNumVoices> voices;
|
||||
std::array<LFO, kNumLfos> 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<float> mixBuffer;
|
||||
|
||||
SynthVoice* findFreeVoice();
|
||||
SynthVoice* stealVoice();
|
||||
|
||||
void readOscParams (juce::AudioProcessorValueTreeState& apvts, const char* prefix, OscParams& out);
|
||||
};
|
||||
|
||||
} // namespace serum
|
||||
Reference in New Issue
Block a user