mirror of
https://github.com/AquaMorph/Droplets.git
synced 2025-04-29 17:35:33 +00:00
Sequencer step and reset
This commit is contained in:
parent
d5f2a5521b
commit
6c335ccabb
@ -9,7 +9,14 @@ SequencerDroplet::SequencerDroplet(DaisyPatch* m_patch,
|
||||
|
||||
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,
|
||||
AudioHandle::OutputBuffer out,
|
||||
@ -17,9 +24,18 @@ void SequencerDroplet::Process(AudioHandle::InputBuffer in,
|
||||
}
|
||||
|
||||
void SequencerDroplet::Draw() {
|
||||
WriteString(Patch(), 0, 10, std::to_string(step));
|
||||
DrawName("Sequencer");
|
||||
}
|
||||
|
||||
void SequencerDroplet::UpdateStateCallback() {}
|
||||
|
||||
void SequencerDroplet::SetControls() {}
|
||||
|
||||
void SequencerDroplet::Step() {
|
||||
step = (step + 1) % MAX_SEQUENCE_LENGTH;
|
||||
}
|
||||
|
||||
void SequencerDroplet::Reset() {
|
||||
step = 0;
|
||||
}
|
||||
|
@ -9,11 +9,22 @@
|
||||
#include "droplet.h"
|
||||
#include "../util.h"
|
||||
|
||||
#define MAX_SEQUENCE_LENGTH 32
|
||||
|
||||
class SequencerDroplet: public Droplet {
|
||||
private:
|
||||
int sequence_length = 32;
|
||||
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:
|
||||
/*
|
||||
* Constructor for a droplet.
|
||||
|
@ -29,6 +29,13 @@ void WriteString(DaisyPatch* patch,
|
||||
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,
|
||||
int x,
|
||||
int y,
|
||||
|
14
src/util.h
14
src/util.h
@ -63,6 +63,20 @@ void WriteString(DaisyPatch* patch,
|
||||
FontDef font,
|
||||
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.
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user