Sequencer step and reset

This commit is contained in:
Christian Colglazier 2022-02-03 19:25:19 -05:00
parent d5f2a5521b
commit 6c335ccabb
4 changed files with 51 additions and 3 deletions

View File

@ -9,7 +9,14 @@ SequencerDroplet::SequencerDroplet(DaisyPatch* m_patch,
SequencerDroplet::~SequencerDroplet() {} SequencerDroplet::~SequencerDroplet() {}
void SequencerDroplet::Control() {} void SequencerDroplet::Control() {
if(Patch()->gate_input[0].Trig()) {
Step();
}
if(Patch()->gate_input[1].Trig()) {
Reset();
}
}
void SequencerDroplet::Process(AudioHandle::InputBuffer in, void SequencerDroplet::Process(AudioHandle::InputBuffer in,
AudioHandle::OutputBuffer out, AudioHandle::OutputBuffer out,
@ -17,9 +24,18 @@ void SequencerDroplet::Process(AudioHandle::InputBuffer in,
} }
void SequencerDroplet::Draw() { void SequencerDroplet::Draw() {
WriteString(Patch(), 0, 10, std::to_string(step));
DrawName("Sequencer"); DrawName("Sequencer");
} }
void SequencerDroplet::UpdateStateCallback() {} void SequencerDroplet::UpdateStateCallback() {}
void SequencerDroplet::SetControls() {} void SequencerDroplet::SetControls() {}
void SequencerDroplet::Step() {
step = (step + 1) % MAX_SEQUENCE_LENGTH;
}
void SequencerDroplet::Reset() {
step = 0;
}

View File

@ -9,11 +9,22 @@
#include "droplet.h" #include "droplet.h"
#include "../util.h" #include "../util.h"
#define MAX_SEQUENCE_LENGTH 32
class SequencerDroplet: public Droplet { class SequencerDroplet: public Droplet {
private: private:
int sequence_length = 32;
int step = 0; int step = 0;
float swquence[32] = { 0.0f }; float swquence[MAX_SEQUENCE_LENGTH] = { 0.0f };
/*
* Set the sequencer to the next step.
*/
void Step();
/*
* Reset the sequencers to the first step of the sequence.
*/
void Reset();
public: public:
/* /*
* Constructor for a droplet. * Constructor for a droplet.

View File

@ -29,6 +29,13 @@ void WriteString(DaisyPatch* patch,
WriteString(patch, x, y, font, text, true); WriteString(patch, x, y, font, text, true);
} }
void WriteString(DaisyPatch* patch,
int x,
int y,
std::string text) {
WriteString(patch, x, y, Font_6x8, text, true);
}
void WriteCenteredString(DaisyPatch* patch, void WriteCenteredString(DaisyPatch* patch,
int x, int x,
int y, int y,

View File

@ -63,6 +63,20 @@ void WriteString(DaisyPatch* patch,
FontDef font, FontDef font,
std::string text); std::string text);
/*
* Draws text on screen flushed left.
*
* @param patch daisy patch board
* @param x start of text x coordinate
* @param y start of text y coordinate
* @param text text to be written
*/
void WriteString(DaisyPatch* patch,
int x,
int y,
std::string text);
/* /*
* Draws text on screen centered. * Draws text on screen centered.
* *