From 2b9c18850ef15222dfbdd5fd8b4e72ee540d5ba6 Mon Sep 17 00:00:00 2001 From: Christian Colglazier Date: Sat, 5 Feb 2022 20:24:15 -0500 Subject: [PATCH] Basic sequencer display --- src/droplets/sequencer_droplet.cpp | 12 +++++++++++- src/droplets/sequencer_droplet.h | 3 ++- src/main.cpp | 5 +++-- src/util.cpp | 10 +++++++++- src/util.h | 15 +++++++++++++++ 5 files changed, 40 insertions(+), 5 deletions(-) diff --git a/src/droplets/sequencer_droplet.cpp b/src/droplets/sequencer_droplet.cpp index 0b5f862..d48c521 100644 --- a/src/droplets/sequencer_droplet.cpp +++ b/src/droplets/sequencer_droplet.cpp @@ -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"); } diff --git a/src/droplets/sequencer_droplet.h b/src/droplets/sequencer_droplet.h index 24e749a..c860b1d 100644 --- a/src/droplets/sequencer_droplet.h +++ b/src/droplets/sequencer_droplet.h @@ -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 }; diff --git a/src/main.cpp b/src/main.cpp index cbb6ceb..2bbb006 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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); diff --git a/src/util.cpp b/src/util.cpp index 6dc5f27..f27f3b2 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -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, diff --git a/src/util.h b/src/util.h index 65bbdce..c3e67ed 100644 --- a/src/util.h +++ b/src/util.h @@ -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. *