mirror of
https://github.com/AquaMorph/Droplets.git
synced 2025-04-29 17:35:33 +00:00
Sequencer length
This commit is contained in:
parent
2b9c18850e
commit
c6b401dc8e
@ -6,6 +6,7 @@ SequencerDroplet::SequencerDroplet(DaisyPatch* m_patch,
|
|||||||
Droplet(m_patch,
|
Droplet(m_patch,
|
||||||
m_state) {
|
m_state) {
|
||||||
SetControls();
|
SetControls();
|
||||||
|
SetColumns();
|
||||||
}
|
}
|
||||||
|
|
||||||
SequencerDroplet::~SequencerDroplet() {}
|
SequencerDroplet::~SequencerDroplet() {}
|
||||||
@ -36,19 +37,23 @@ void SequencerDroplet::Process(AudioHandle::InputBuffer in,
|
|||||||
void SequencerDroplet::Draw() {
|
void SequencerDroplet::Draw() {
|
||||||
int left_padding = 4+GetScreenMin();
|
int left_padding = 4+GetScreenMin();
|
||||||
|
|
||||||
for (int i = 0; i < 24; i++) {
|
for (int i = 0; i < num_columns*NUM_ROWS && i < sequence_length; i++) {
|
||||||
WriteString(Patch(),
|
WriteString(Patch(),
|
||||||
GetScreenWidth()/4*(i%4)+left_padding,
|
GetScreenWidth()/num_columns*(i%num_columns)+left_padding,
|
||||||
8+(std::floor(i/4)*8),
|
8+(std::floor(i/num_columns)*8),
|
||||||
FloatToString(sequence[i], 2),
|
FloatToString(sequence[i], 2),
|
||||||
i!=step);
|
i!=step);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Draw info bar
|
||||||
DrawSolidRect(Patch(),GetScreenMin(),56,GetScreenMax(),63, true);
|
DrawSolidRect(Patch(),GetScreenMin(),56,GetScreenMax(),63, true);
|
||||||
WriteString(Patch(), 2+GetScreenMin(), 56, std::to_string(step), false);
|
WriteString(Patch(), 2+GetScreenMin(), 56, std::to_string(step+1), false);
|
||||||
DrawName("Sequencer");
|
DrawName("Sequencer");
|
||||||
}
|
}
|
||||||
|
|
||||||
void SequencerDroplet::UpdateStateCallback() {}
|
void SequencerDroplet::UpdateStateCallback() {
|
||||||
|
SetColumns();
|
||||||
|
}
|
||||||
|
|
||||||
void SequencerDroplet::SetControls() {
|
void SequencerDroplet::SetControls() {
|
||||||
control[0].Init(Patch()->controls[Patch()->CTRL_1],
|
control[0].Init(Patch()->controls[Patch()->CTRL_1],
|
||||||
@ -62,9 +67,17 @@ void SequencerDroplet::SetControls() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SequencerDroplet::Step() {
|
void SequencerDroplet::Step() {
|
||||||
step = (step + 1) % MAX_SEQUENCE_LENGTH;
|
step = (step + 1) % sequence_length;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SequencerDroplet::Reset() {
|
void SequencerDroplet::Reset() {
|
||||||
step = 0;
|
step = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SequencerDroplet::SetColumns() {
|
||||||
|
if (GetState() != DropletState::kFull) {
|
||||||
|
num_columns = 2;
|
||||||
|
} else {
|
||||||
|
num_columns = 4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -10,13 +10,15 @@
|
|||||||
#include "../util.h"
|
#include "../util.h"
|
||||||
|
|
||||||
#define MAX_SEQUENCE_LENGTH 32
|
#define MAX_SEQUENCE_LENGTH 32
|
||||||
#define CONTROL_DEADZONE = 0.03f
|
#define CONTROL_DEADZONE 0.03f
|
||||||
|
#define NUM_ROWS 6
|
||||||
|
|
||||||
class SequencerDroplet: public Droplet {
|
class SequencerDroplet: public Droplet {
|
||||||
private:
|
private:
|
||||||
int step = 0;
|
int step = 0;
|
||||||
int selected = 0;
|
int selected = 0;
|
||||||
int sequence_length = 32;
|
int sequence_length = 16;
|
||||||
|
int num_columns = 4;
|
||||||
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 };
|
||||||
@ -30,6 +32,8 @@ private:
|
|||||||
* Reset the sequencers to the first step of the sequence.
|
* Reset the sequencers to the first step of the sequence.
|
||||||
*/
|
*/
|
||||||
void Reset();
|
void Reset();
|
||||||
|
|
||||||
|
void SetColumns();
|
||||||
public:
|
public:
|
||||||
/*
|
/*
|
||||||
* Constructor for a droplet.
|
* Constructor for a droplet.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user