From 744cdd3713e87ce7e998fcc486e7c8f4402c6ce3 Mon Sep 17 00:00:00 2001 From: Christian Colglazier Date: Tue, 1 Mar 2022 20:42:40 -0500 Subject: [PATCH] Sequencer clock divider --- src/droplets/sequencer_droplet.cpp | 17 +++++++++++++++-- src/droplets/sequencer_droplet.h | 3 +++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/droplets/sequencer_droplet.cpp b/src/droplets/sequencer_droplet.cpp index ffc3f86..b8fa502 100644 --- a/src/droplets/sequencer_droplet.cpp +++ b/src/droplets/sequencer_droplet.cpp @@ -52,10 +52,15 @@ void SequencerDroplet::Process(AudioHandle::InputBuffer in, // Set sequence length if (chn == GetChannelMin()) { sequence_length = std::max(1.0f,control[chn].Process() / - 4.9f*MAX_SEQUENCE_LENGTH); + 4.85f*MAX_SEQUENCE_LENGTH); SetDimensions(); SetInMenu(); } + // Set clock divider + if (chn == GetChannelMin()+1) { + divider = std::max(1.0f,control[chn].Process() / + 4.85f*MAX_CLOCK_DIVIDE); + } } } last_control_value[chn] = control[chn].Process(); @@ -113,6 +118,11 @@ void SequencerDroplet::Draw() { 56, length_text, !InMenu()); + WriteString(Patch(), + 36+GetScreenMin(), + 56, + std::to_string(divider), + !InMenu()); if(NeedUpdate()) { title_graph->Update(); @@ -141,7 +151,10 @@ void SequencerDroplet::SetControls() { } void SequencerDroplet::Step() { - step = (step + 1) % sequence_length; + divider_count = (divider_count + 1) % divider; + if (divider_count == 0) { + step = (step + 1) % sequence_length; + } } void SequencerDroplet::Reset() { diff --git a/src/droplets/sequencer_droplet.h b/src/droplets/sequencer_droplet.h index a4600a7..b5d344f 100644 --- a/src/droplets/sequencer_droplet.h +++ b/src/droplets/sequencer_droplet.h @@ -11,6 +11,7 @@ #include "../graphics/graph.h" #define MAX_SEQUENCE_LENGTH 32 +#define MAX_CLOCK_DIVIDE 16 #define CONTROL_DEADZONE 0.00499f #define CONTROL_RATE_LIMIT 25 #define NUM_ROWS 6 @@ -23,6 +24,8 @@ private: int num_columns = 4; int num_rows = NUM_ROWS; int control_rate_count = 0; + int divider = 0; + int divider_count = 1; float sequence[MAX_SEQUENCE_LENGTH] = { 0.0f }; Parameter control[4]; float last_control_value[4] = { 0.0f };