Sequencer clock divider

This commit is contained in:
Christian Colglazier 2022-03-01 20:42:40 -05:00
parent eebafd5890
commit 744cdd3713
2 changed files with 18 additions and 2 deletions

View File

@ -52,10 +52,15 @@ void SequencerDroplet::Process(AudioHandle::InputBuffer in,
// Set sequence length // Set sequence length
if (chn == GetChannelMin()) { if (chn == GetChannelMin()) {
sequence_length = std::max(1.0f,control[chn].Process() / sequence_length = std::max(1.0f,control[chn].Process() /
4.9f*MAX_SEQUENCE_LENGTH); 4.85f*MAX_SEQUENCE_LENGTH);
SetDimensions(); SetDimensions();
SetInMenu(); 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(); last_control_value[chn] = control[chn].Process();
@ -113,6 +118,11 @@ void SequencerDroplet::Draw() {
56, 56,
length_text, length_text,
!InMenu()); !InMenu());
WriteString(Patch(),
36+GetScreenMin(),
56,
std::to_string(divider),
!InMenu());
if(NeedUpdate()) { if(NeedUpdate()) {
title_graph->Update(); title_graph->Update();
@ -141,7 +151,10 @@ void SequencerDroplet::SetControls() {
} }
void SequencerDroplet::Step() { 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() { void SequencerDroplet::Reset() {

View File

@ -11,6 +11,7 @@
#include "../graphics/graph.h" #include "../graphics/graph.h"
#define MAX_SEQUENCE_LENGTH 32 #define MAX_SEQUENCE_LENGTH 32
#define MAX_CLOCK_DIVIDE 16
#define CONTROL_DEADZONE 0.00499f #define CONTROL_DEADZONE 0.00499f
#define CONTROL_RATE_LIMIT 25 #define CONTROL_RATE_LIMIT 25
#define NUM_ROWS 6 #define NUM_ROWS 6
@ -23,6 +24,8 @@ private:
int num_columns = 4; int num_columns = 4;
int num_rows = NUM_ROWS; int num_rows = NUM_ROWS;
int control_rate_count = 0; int control_rate_count = 0;
int divider = 0;
int divider_count = 1;
float sequence[MAX_SEQUENCE_LENGTH] = { 0.0f }; float sequence[MAX_SEQUENCE_LENGTH] = { 0.0f };
Parameter control[4]; Parameter control[4];
float last_control_value[4] = { 0.0f }; float last_control_value[4] = { 0.0f };