mirror of
https://github.com/AquaMorph/Droplets.git
synced 2025-04-29 17:35:33 +00:00
Adjustable sequence length
This commit is contained in:
parent
017e4f4b61
commit
f7b2552773
@ -5,8 +5,9 @@ SequencerDroplet::SequencerDroplet(DaisyPatch* m_patch,
|
||||
float sample_rate) :
|
||||
Droplet(m_patch,
|
||||
m_state) {
|
||||
SetControls();
|
||||
SetColumns();
|
||||
SetControls();
|
||||
AdjustSelected(-1);
|
||||
}
|
||||
|
||||
SequencerDroplet::~SequencerDroplet() {}
|
||||
@ -26,7 +27,16 @@ void SequencerDroplet::Control() {
|
||||
if (control_rate_count == CONTROL_RATE_LIMIT) {
|
||||
for (size_t chn = GetChannelMin(); chn < GetChannelMax(); chn++) {
|
||||
if (std::abs(control[chn].Process()-last_control_value[chn]) > CONTROL_DEADZONE) {
|
||||
sequence[chn+selected*num_columns] = control[chn].Process();
|
||||
if (!InMenu()) {
|
||||
sequence[chn+selected*num_columns] = control[chn].Process();
|
||||
} else {
|
||||
if (chn == GetChannelMin()) {
|
||||
sequence_length = std::max(1.0f,control[chn].Process()/4.9f*MAX_SEQUENCE_LENGTH);
|
||||
SetColumns();
|
||||
selected = 0;
|
||||
AdjustSelected(-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
last_control_value[chn] = control[chn].Process();
|
||||
}
|
||||
@ -48,11 +58,13 @@ void SequencerDroplet::Draw() {
|
||||
int left_padding = 4+GetScreenMin();
|
||||
|
||||
// Active Input
|
||||
DrawSolidRect(Patch(),
|
||||
GetScreenMin(),
|
||||
8+selected*8,
|
||||
GetScreenMin()+2,
|
||||
15+selected*8, true);
|
||||
if (!InMenu()) {
|
||||
DrawSolidRect(Patch(),
|
||||
GetScreenMin(),
|
||||
8+selected*8,
|
||||
GetScreenMin()+2,
|
||||
15+selected*8, true);
|
||||
}
|
||||
|
||||
// Notes
|
||||
for (int i = 0; i < num_columns*NUM_ROWS && i < sequence_length; i++) {
|
||||
@ -64,8 +76,8 @@ void SequencerDroplet::Draw() {
|
||||
}
|
||||
|
||||
// Draw info bar
|
||||
DrawSolidRect(Patch(),GetScreenMin(),56,GetScreenMax(),63, true);
|
||||
WriteString(Patch(), 2+GetScreenMin(), 56, std::to_string(step+1), false);
|
||||
DrawSolidRect(Patch(),GetScreenMin(),56,GetScreenMax(),63, InMenu());
|
||||
WriteString(Patch(), 2+GetScreenMin(), 56, std::to_string(step+1), !InMenu());
|
||||
DrawName("Sequencer");
|
||||
}
|
||||
|
||||
@ -74,14 +86,14 @@ void SequencerDroplet::UpdateStateCallback() {
|
||||
}
|
||||
|
||||
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);
|
||||
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() {
|
||||
@ -98,9 +110,13 @@ void SequencerDroplet::SetColumns() {
|
||||
} else {
|
||||
num_columns = 4;
|
||||
}
|
||||
num_rows = std::ceil((float)sequence_length/num_columns);
|
||||
}
|
||||
|
||||
void SequencerDroplet::AdjustSelected(int adj) {
|
||||
int rows = std::ceil(sequence_length/num_columns);
|
||||
selected = (rows+selected+adj) % rows;
|
||||
selected = (num_rows+selected+adj+1) % (num_rows+1);
|
||||
}
|
||||
|
||||
bool SequencerDroplet::InMenu() {
|
||||
return selected >= num_rows;
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ private:
|
||||
int selected = 0;
|
||||
int sequence_length = 16;
|
||||
int num_columns = 4;
|
||||
int num_rows = NUM_ROWS;
|
||||
int control_rate_count = 0;
|
||||
float sequence[MAX_SEQUENCE_LENGTH] = { 0.0f };
|
||||
Parameter control[4];
|
||||
@ -38,6 +39,8 @@ private:
|
||||
void SetColumns();
|
||||
|
||||
void AdjustSelected(int adj);
|
||||
|
||||
bool InMenu();
|
||||
public:
|
||||
/*
|
||||
* Constructor for a droplet.
|
||||
|
Loading…
x
Reference in New Issue
Block a user