diff --git a/code/daisy-looper/button_grid.h b/code/daisy-looper/button_grid.h index 78d78ffd6ac1f69c62c494add5acf07eee452ebf..96395e3a441d14019b08c57eaf5f938a884df272 100644 --- a/code/daisy-looper/button_grid.h +++ b/code/daisy-looper/button_grid.h @@ -94,12 +94,12 @@ class ButtonGrid { for (int n=0; n<6; n++) { if (!grid_buttons_[n].is_home) { // Not a home button, display help on long hold and hide on release - grid_buttons_[n].button->onLongHold([this, n](){ - grid_buttons_[n].should_render_description = true; - }); - grid_buttons_[n].button->onReleased([this, n](){ - grid_buttons_[n].should_render_description = false; - }); + // grid_buttons_[n].button->onLongHold([this, n](){ + // grid_buttons_[n].should_render_description = true; + // }); + // grid_buttons_[n].button->onReleased([this, n](){ + // grid_buttons_[n].should_render_description = false; + // }); } } } diff --git a/code/daisy-looper/looper.h b/code/daisy-looper/looper.h index a9a0575ade1d75b4449f2a1931ef39ffd5155d66..594ae1a14efdbb6f58c40446bedd2e89cee50300 100644 --- a/code/daisy-looper/looper.h +++ b/code/daisy-looper/looper.h @@ -45,13 +45,18 @@ class Head { void deactivate(); bool isActive(); void setPosition(float value); + void reset(); void setIncrement(float value); void incrementBy(float value); + void slowDown(); + void reverse(); + void speedUp(); void update(); float read(); float increment = 1.0f; float variation = 0.0f; float variation_amount = 0.0f; + float speed_multiplier = 1.0f; private: bool active = true; float position = 0.0f; @@ -69,8 +74,11 @@ void Head::deactivate() { bool Head::isActive() { return active; } +void Head::reset() { + this->position = 0.0f; +} void Head::setPosition(float value) { - this->position = value; + this->position = value * speed_multiplier; } void Head::setIncrement(float value) { this->increment = value; @@ -78,8 +86,17 @@ void Head::setIncrement(float value) { void Head::incrementBy(float value) { this->position += value; } +void Head::slowDown() { + this->speed_multiplier = max(0.0f, this->speed_multiplier - 0.0025f); +} +void Head::reverse() { + this->speed_multiplier = -abs(this->speed_multiplier ); +} +void Head::speedUp() { + this->speed_multiplier = 1.0f; +} void Head::update() { - this->position += (this->increment + (variation * variation_amount)); + this->position += (this->increment + (variation * variation_amount)) * speed_multiplier; } float Head::read() { return this->position; @@ -118,6 +135,10 @@ class Looper { void setRecModeLoopShot(); void setPlaybackSpeed(float increment); void addToPlayhead(float value); + void slowDown(); + void reverse(); + void restart(); + void speedUp(); float loop_start_f = 0.0f; float loop_length_f = 1.0f; uint8_t grain_count = 8; @@ -402,6 +423,30 @@ void Looper::addToPlayhead(float value) { } } +void Looper::slowDown() { + for (size_t i=0; i<9; i++) { + playheads[i].slowDown(); + } +} + +void Looper::reverse() { + for (size_t i=0; i<9; i++) { + playheads[i].reverse(); + } +} + +void Looper::restart() { + for (size_t i=0; i<9; i++) { + playheads[i].reset(); + } +} + +void Looper::speedUp() { + for (size_t i=0; i<9; i++) { + playheads[i].speedUp(); + } +} + float* Looper::getBuffer() { return buffer; } diff --git a/code/daisy-looper/menu.ods b/code/daisy-looper/menu.ods index b744707a290dc99f6530d3f577376ab5774bb22e..2b8391b9cf03447b0e7b7cf66da2c734faf8ed40 100644 Binary files a/code/daisy-looper/menu.ods and b/code/daisy-looper/menu.ods differ diff --git a/code/daisy-looper/ui.h b/code/daisy-looper/ui.h index 19c4720d4839913bfe7c2d92c07bc297e8eb5bd3..3dcb82e14414cbc1350cdec79ef0360e94c5fd7b 100644 --- a/code/daisy-looper/ui.h +++ b/code/daisy-looper/ui.h @@ -114,9 +114,9 @@ class Ui { GridButton("STOP\nLOOP\nMULTI\nMIDI", &button_1, false, BUTTON_TYPE_MULTITOGGLE, 1), GridButton("PLAY\nMENU", &button_2, true), GridButton("ACTIVE\nSUM\nRING", &button_3, false, BUTTON_TYPE_MULTITOGGLE, 0), - GridButton(" ", &button_4, false), - GridButton(" ", &button_5, false), - GridButton(" ", &button_6, false), + GridButton("RE\nSTART", &button_4, false), + GridButton("SLOW\nDOWN", &button_5, false), + GridButton("REV\nERSE", &button_6, false), }), ButtonGrid((int) UI_MODE_TRIGGER_MENU, { GridButton("MIDI\nTRIG.", &button_1, false), @@ -241,6 +241,7 @@ class Ui { home_button->onReleased([this, n](){ this->setMode(UI_MODE_DEFAULT); this->button_grids[n].hideAllDescriptions(); + activeLooper()->speedUp(); }); // Return pointer to the home button @@ -375,7 +376,7 @@ class Ui { // Setup button Grid Button* home_button = setupButtonGrid(n); - // Chang the way in which buffers are summed + // Change the way in which buffers are summed button_3.onPress([this, n](){ button_grids[n].grid_buttons_[2].next(); buffer_summing_mode = (BufferSummingMode) button_grids[n].grid_buttons_[2].active; @@ -387,6 +388,26 @@ class Ui { activeLooper()->playback_state = (atoav::PlaybackState) (button_grids[n].grid_buttons_[0].active); }); + // Restart + button_4.onPress([this, n](){ + activeLooper()->restart(); + }); + + // DJ-style slow-down effect + button_5.onHold([this, n](){ + activeLooper()->slowDown(); + }); + button_5.onReleased([this, n](){ + activeLooper()->speedUp(); + }); + + button_6.onHold([this, n](){ + activeLooper()->reverse(); + }); + button_6.onReleased([this, n](){ + activeLooper()->speedUp(); + }); + // Store the last ui mode, for the check on top last_ui_mode = ui_mode; }