Basic sequencer display

This commit is contained in:
Christian Colglazier 2022-02-05 20:24:15 -05:00
parent ffcea81e57
commit 2b9c18850e
5 changed files with 40 additions and 5 deletions

View File

@ -34,7 +34,17 @@ void SequencerDroplet::Process(AudioHandle::InputBuffer in,
}
void SequencerDroplet::Draw() {
WriteString(Patch(), 0, 10, std::to_string(step));
int left_padding = 4+GetScreenMin();
for (int i = 0; i < 24; i++) {
WriteString(Patch(),
GetScreenWidth()/4*(i%4)+left_padding,
8+(std::floor(i/4)*8),
FloatToString(sequence[i], 2),
i!=step);
}
DrawSolidRect(Patch(),GetScreenMin(),56,GetScreenMax(),63, true);
WriteString(Patch(), 2+GetScreenMin(), 56, std::to_string(step), false);
DrawName("Sequencer");
}

View File

@ -10,12 +10,13 @@
#include "../util.h"
#define MAX_SEQUENCE_LENGTH 32
#define CONTROL_DEADZONE = 0.01f
#define CONTROL_DEADZONE = 0.03f
class SequencerDroplet: public Droplet {
private:
int step = 0;
int selected = 0;
int sequence_length = 32;
float sequence[MAX_SEQUENCE_LENGTH] = { 0.0f };
Parameter control[4];
float last_control_value[4] = { 0.0f };

View File

@ -129,7 +129,7 @@ static void AudioThrough(AudioHandle::InputBuffer in,
Droplet* GetDroplet(DropletState state,
MenuState menu) {
switch(menu) {
default:
case MenuState::kAD:
return new ADDroplet(&patch,
state,
@ -148,7 +148,8 @@ Droplet* GetDroplet(DropletState state,
case MenuState::kNoise:
return new NoiseDroplet(&patch,
state);
case MenuState::kSequencer:
default:
case MenuState::kSequencer:
return new SequencerDroplet(&patch,
state,
sample_rate);

View File

@ -33,7 +33,15 @@ void WriteString(DaisyPatch* patch,
int x,
int y,
std::string text) {
WriteString(patch, x, y, Font_6x8, text, true);
WriteString(patch, x, y, text, true);
}
void WriteString(DaisyPatch* patch,
int x,
int y,
std::string text,
bool on) {
WriteString(patch, x, y, Font_6x8, text, on);
}
void WriteCenteredString(DaisyPatch* patch,

View File

@ -63,6 +63,21 @@ 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
* @param on draw screen on or off
*/
void WriteString(DaisyPatch* patch,
int x,
int y,
std::string text,
bool on);
/*
* Draws text on screen flushed left.
*