2026-08-05 19:55:57 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <JuceHeader.h>
|
|
|
|
|
#include "dsp/SynthVoice.h"
|
|
|
|
|
#include "dsp/StepSequencer.h"
|
|
|
|
|
|
2026-08-05 23:12:17 +02:00
|
|
|
class MonostepAudioProcessor final : public juce::AudioProcessor
|
2026-08-05 19:55:57 +02:00
|
|
|
{
|
|
|
|
|
public:
|
2026-08-05 23:12:17 +02:00
|
|
|
MonostepAudioProcessor();
|
|
|
|
|
~MonostepAudioProcessor() override = default;
|
2026-08-05 19:55:57 +02:00
|
|
|
|
|
|
|
|
void prepareToPlay (double sampleRate, int samplesPerBlock) override;
|
|
|
|
|
void releaseResources() override;
|
|
|
|
|
void processBlock (juce::AudioBuffer<float>&, juce::MidiBuffer&) override;
|
|
|
|
|
|
|
|
|
|
juce::AudioProcessorEditor* createEditor() override;
|
|
|
|
|
bool hasEditor() const override { return true; }
|
|
|
|
|
|
2026-08-05 23:12:17 +02:00
|
|
|
const juce::String getName() const override { return "Monostep"; }
|
2026-08-05 19:55:57 +02:00
|
|
|
bool acceptsMidi() const override { return true; }
|
|
|
|
|
bool producesMidi() const override { return false; }
|
|
|
|
|
double getTailLengthSeconds() const override { return 0.0; }
|
|
|
|
|
|
|
|
|
|
int getNumPrograms() override { return 1; }
|
|
|
|
|
int getCurrentProgram() override { return 0; }
|
|
|
|
|
void setCurrentProgram (int) override {}
|
|
|
|
|
const juce::String getProgramName (int) override { return {}; }
|
|
|
|
|
void changeProgramName (int, const juce::String&) override {}
|
|
|
|
|
|
|
|
|
|
void getStateInformation (juce::MemoryBlock&) override;
|
|
|
|
|
void setStateInformation (const void*, int) override;
|
|
|
|
|
|
|
|
|
|
juce::AudioProcessorValueTreeState& getAPVTS() { return apvts; }
|
2026-08-06 15:51:56 +02:00
|
|
|
void setZoomIndex (int index) { zoomIndex = juce::jlimit (0, 4, index); }
|
|
|
|
|
int getZoomIndex() const { return zoomIndex; }
|
2026-08-05 19:55:57 +02:00
|
|
|
monostep::StepSequencer& getSequencer() { return sequencer; }
|
|
|
|
|
const monostep::StepSequencer& getSequencer() const { return sequencer; }
|
|
|
|
|
|
|
|
|
|
int getNumSteps() const { return monostep::numSteps; }
|
|
|
|
|
int getPatternLength() const { return juce::roundToInt (seqLenParam->load()); }
|
|
|
|
|
int getCurrentStep() const { return playStep.load(); }
|
|
|
|
|
|
|
|
|
|
void setStepGate (int idx, bool gate);
|
|
|
|
|
void setStepNote (int idx, int semitone);
|
|
|
|
|
void setStepCents (int idx, float cents);
|
|
|
|
|
void setStepSlide (int idx, bool slide);
|
2026-08-05 23:12:17 +02:00
|
|
|
void setStepAccent (int idx, bool accent);
|
|
|
|
|
void shiftPattern (int dir);
|
|
|
|
|
|
|
|
|
|
int getNumPresets() const;
|
|
|
|
|
const char* getPresetName (int index) const;
|
|
|
|
|
void applyPreset (int index);
|
|
|
|
|
void randomizePattern();
|
|
|
|
|
void randomizeParams();
|
|
|
|
|
void randomizeOsc();
|
|
|
|
|
void randomizeFilter();
|
|
|
|
|
void randomizeEnv();
|
|
|
|
|
void randomizeSeqSettings();
|
|
|
|
|
void randomizeFx();
|
2026-08-05 19:55:57 +02:00
|
|
|
|
|
|
|
|
juce::String getStepNoteName (int idx) const;
|
|
|
|
|
|
|
|
|
|
std::function<void()> onPatternChanged;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
static juce::AudioProcessorValueTreeState::ParameterLayout createParameterLayout();
|
|
|
|
|
|
|
|
|
|
void updateVoiceParams();
|
2026-08-05 23:12:17 +02:00
|
|
|
void applyParamValue (const juce::String& id, float value);
|
2026-08-05 19:55:57 +02:00
|
|
|
float midiToFreq (float note) const;
|
|
|
|
|
void storeSequence (juce::ValueTree& seq) const;
|
|
|
|
|
void loadSequence (const juce::ValueTree& seq);
|
|
|
|
|
void setDefaultPattern();
|
|
|
|
|
|
|
|
|
|
juce::AudioProcessorValueTreeState apvts;
|
|
|
|
|
|
|
|
|
|
std::atomic<float>* osc1WaveParam = nullptr;
|
|
|
|
|
std::atomic<float>* osc2WaveParam = nullptr;
|
2026-08-05 23:12:17 +02:00
|
|
|
std::atomic<float>* osc1CoarseParam = nullptr;
|
|
|
|
|
std::atomic<float>* osc2CoarseParam = nullptr;
|
2026-08-05 19:55:57 +02:00
|
|
|
std::atomic<float>* detuneParam = nullptr;
|
|
|
|
|
std::atomic<float>* mixParam = nullptr;
|
2026-08-05 23:12:17 +02:00
|
|
|
std::atomic<float>* osc1PhaseParam = nullptr;
|
2026-08-05 19:55:57 +02:00
|
|
|
std::atomic<float>* cutoffParam = nullptr;
|
|
|
|
|
std::atomic<float>* resParam = nullptr;
|
2026-08-06 15:51:56 +02:00
|
|
|
std::atomic<float>* filterTypeParam = nullptr;
|
2026-08-05 19:55:57 +02:00
|
|
|
std::atomic<float>* attackParam = nullptr;
|
|
|
|
|
std::atomic<float>* decayParam = nullptr;
|
|
|
|
|
std::atomic<float>* sustainParam = nullptr;
|
|
|
|
|
std::atomic<float>* releaseParam = nullptr;
|
2026-08-06 15:51:56 +02:00
|
|
|
std::atomic<float>* filterAttackParam = nullptr;
|
|
|
|
|
std::atomic<float>* filterDecayParam = nullptr;
|
|
|
|
|
std::atomic<float>* filterSustainParam = nullptr;
|
|
|
|
|
std::atomic<float>* filterReleaseParam = nullptr;
|
|
|
|
|
std::atomic<float>* filterEnvAmtParam = nullptr;
|
2026-08-05 19:55:57 +02:00
|
|
|
std::atomic<float>* glideParam = nullptr;
|
|
|
|
|
std::atomic<float>* masterParam = nullptr;
|
|
|
|
|
std::atomic<float>* seqLenParam = nullptr;
|
|
|
|
|
std::atomic<float>* seqRateParam = nullptr;
|
|
|
|
|
std::atomic<float>* seqRootParam = nullptr;
|
|
|
|
|
std::atomic<float>* seqOctaveParam = nullptr;
|
2026-08-05 23:12:17 +02:00
|
|
|
std::atomic<float>* seqSwingParam = nullptr;
|
2026-08-05 19:55:57 +02:00
|
|
|
std::atomic<float>* seqGateLenParam = nullptr;
|
2026-08-05 23:12:17 +02:00
|
|
|
std::atomic<float>* driveParam = nullptr;
|
|
|
|
|
std::atomic<float>* ringModParam = nullptr;
|
|
|
|
|
std::atomic<float>* accentParam = nullptr;
|
2026-08-06 15:51:56 +02:00
|
|
|
std::atomic<float>* seqRetrigParam = nullptr;
|
2026-08-05 19:55:57 +02:00
|
|
|
|
|
|
|
|
monostep::StepSequencer sequencer;
|
|
|
|
|
monostep::SynthVoice voice;
|
|
|
|
|
juce::AudioBuffer<float> scratch;
|
2026-08-05 23:12:17 +02:00
|
|
|
juce::Random random;
|
2026-08-05 19:55:57 +02:00
|
|
|
|
|
|
|
|
double sampleRate = 44100.0;
|
|
|
|
|
|
2026-08-06 15:51:56 +02:00
|
|
|
int zoomIndex = 0;
|
|
|
|
|
|
2026-08-05 19:55:57 +02:00
|
|
|
int lastStep = -1;
|
|
|
|
|
std::atomic<int> playStep { -1 };
|
|
|
|
|
bool lastGateApplied = false;
|
|
|
|
|
float lastFreqApplied = -1.0f;
|
|
|
|
|
|
|
|
|
|
bool midiHeld = false;
|
|
|
|
|
int lastMidiNote = -1;
|
|
|
|
|
|
|
|
|
|
bool wasPlaying = false;
|
|
|
|
|
double lastHostPpq = -1.0;
|
|
|
|
|
double freePpq = 0.0;
|
2026-08-06 15:57:58 +02:00
|
|
|
double retrigPpq = 0.0;
|
2026-08-05 19:55:57 +02:00
|
|
|
};
|