From ffcea81e57c5690013307ff638cfe717ed74e9b7 Mon Sep 17 00:00:00 2001 From: Christian Colglazier Date: Fri, 4 Feb 2022 21:24:02 -0500 Subject: [PATCH] Basic sequencer controls --- src/droplets/sequencer_droplet.cpp | 21 ++++++++++++++++++++- src/droplets/sequencer_droplet.h | 6 +++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/droplets/sequencer_droplet.cpp b/src/droplets/sequencer_droplet.cpp index caaf747..0b5f862 100644 --- a/src/droplets/sequencer_droplet.cpp +++ b/src/droplets/sequencer_droplet.cpp @@ -5,6 +5,7 @@ SequencerDroplet::SequencerDroplet(DaisyPatch* m_patch, float sample_rate) : Droplet(m_patch, m_state) { + SetControls(); } SequencerDroplet::~SequencerDroplet() {} @@ -16,11 +17,20 @@ void SequencerDroplet::Control() { if(Patch()->gate_input[1].Trig()) { Reset(); } + + for (size_t chn = GetChannelMin(); chn < GetChannelMax(); chn++) { + sequence[chn+selected] = control[chn].Process(); + } + } void SequencerDroplet::Process(AudioHandle::InputBuffer in, AudioHandle::OutputBuffer out, size_t size) { + for(size_t i = 0; i < size; i++) { + Patch()->seed.dac.WriteValue(DacHandle::Channel::ONE, + sequence[step] * 819.2f); + } } void SequencerDroplet::Draw() { @@ -30,7 +40,16 @@ void SequencerDroplet::Draw() { void SequencerDroplet::UpdateStateCallback() {} -void SequencerDroplet::SetControls() {} +void SequencerDroplet::SetControls() { + control[0].Init(Patch()->controls[Patch()->CTRL_1], + 0.0, 5.0f, Parameter::LINEAR); + control[1].Init(Patch()->controls[Patch()->CTRL_2], + 0.0, 5.0f, Parameter::LINEAR); + control[2].Init(Patch()->controls[Patch()->CTRL_3], + 0.0, 5.0f, Parameter::LINEAR); + control[3].Init(Patch()->controls[Patch()->CTRL_4], + 0.0, 5.0f, Parameter::LINEAR); +} void SequencerDroplet::Step() { step = (step + 1) % MAX_SEQUENCE_LENGTH; diff --git a/src/droplets/sequencer_droplet.h b/src/droplets/sequencer_droplet.h index dccb159..24e749a 100644 --- a/src/droplets/sequencer_droplet.h +++ b/src/droplets/sequencer_droplet.h @@ -10,11 +10,15 @@ #include "../util.h" #define MAX_SEQUENCE_LENGTH 32 +#define CONTROL_DEADZONE = 0.01f class SequencerDroplet: public Droplet { private: int step = 0; - float swquence[MAX_SEQUENCE_LENGTH] = { 0.0f }; + int selected = 0; + float sequence[MAX_SEQUENCE_LENGTH] = { 0.0f }; + Parameter control[4]; + float last_control_value[4] = { 0.0f }; /* * Set the sequencer to the next step.