mirror of
https://codeberg.org/armin/monostep.git
synced 2026-09-01 04:10:46 +02:00
MonoStep: monophonic 2-oscillator step-sequencer synth
This commit is contained in:
commit
e52e5cb161
14 changed files with 2674 additions and 0 deletions
98
Source/PluginProcessor.h
Normal file
98
Source/PluginProcessor.h
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
#pragma once
|
||||
|
||||
#include <JuceHeader.h>
|
||||
#include "dsp/SynthVoice.h"
|
||||
#include "dsp/StepSequencer.h"
|
||||
|
||||
class MonoStepAudioProcessor final : public juce::AudioProcessor
|
||||
{
|
||||
public:
|
||||
MonoStepAudioProcessor();
|
||||
~MonoStepAudioProcessor() override = default;
|
||||
|
||||
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; }
|
||||
|
||||
const juce::String getName() const override { return "MonoStep"; }
|
||||
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; }
|
||||
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);
|
||||
|
||||
juce::String getStepNoteName (int idx) const;
|
||||
|
||||
std::function<void()> onPatternChanged;
|
||||
|
||||
private:
|
||||
static juce::AudioProcessorValueTreeState::ParameterLayout createParameterLayout();
|
||||
|
||||
void updateVoiceParams();
|
||||
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;
|
||||
std::atomic<float>* detuneParam = nullptr;
|
||||
std::atomic<float>* mixParam = nullptr;
|
||||
std::atomic<float>* cutoffParam = nullptr;
|
||||
std::atomic<float>* resParam = nullptr;
|
||||
std::atomic<float>* attackParam = nullptr;
|
||||
std::atomic<float>* decayParam = nullptr;
|
||||
std::atomic<float>* sustainParam = nullptr;
|
||||
std::atomic<float>* releaseParam = nullptr;
|
||||
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;
|
||||
std::atomic<float>* seqSwingParam = nullptr;
|
||||
std::atomic<float>* seqGateLenParam = nullptr;
|
||||
|
||||
monostep::StepSequencer sequencer;
|
||||
monostep::SynthVoice voice;
|
||||
juce::AudioBuffer<float> scratch;
|
||||
|
||||
double sampleRate = 44100.0;
|
||||
|
||||
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;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue