From a9bbec922afced82c9c7f53bf2ced8b1008c2ff9 Mon Sep 17 00:00:00 2001 From: Harry van Haaren Date: Thu, 25 Jul 2013 14:54:53 +0100 Subject: [PATCH] -Loop duration can be specified in the UI --- src/avtk/avtk_clip_selector.h | 37 ++++++++++++++++++++++++++++++----- src/looper.cxx | 2 +- 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/src/avtk/avtk_clip_selector.h b/src/avtk/avtk_clip_selector.h index 80fe955..fc91104 100644 --- a/src/avtk/avtk_clip_selector.h +++ b/src/avtk/avtk_clip_selector.h @@ -247,7 +247,15 @@ class ClipSelector : public Fl_Button Fl_Menu_Item rclick_menu[] = { { "Load" }, - { "Duration" }, + { "Bars", 0, 0, 0, FL_SUBMENU }, + {"1"}, + {"2"}, + {"4"}, + {"8"}, + {"16"}, + {"32"}, + {0}, + { "Record" }, { 0 } }; Fl_Menu_Item *m = (Fl_Menu_Item*) rclick_menu->popup(Fl::event_x(), Fl::event_y(), 0, 0, 0); @@ -260,11 +268,30 @@ class ClipSelector : public Fl_Button clipSelectorLoad( 0 ); clips[clipNum].state = ClipState::CLIP_LOADED; } - else if ( strcmp(m->label(), "Duration") == 0 ) + else if ( strcmp(m->label(), "1") == 0 ) { + EventLooperLoopLength e = EventLooperLoopLength(0, 1); + writeToDspRingbuffer( &e ); + } else if ( strcmp(m->label(), "2") == 0 ) { + EventLooperLoopLength e = EventLooperLoopLength(0, 2); + writeToDspRingbuffer( &e ); + } else if ( strcmp(m->label(), "4") == 0 ) { + EventLooperLoopLength e = EventLooperLoopLength(0, 4); + writeToDspRingbuffer( &e ); + } else if ( strcmp(m->label(), "8") == 0 ) { + EventLooperLoopLength e = EventLooperLoopLength(0, 8); + writeToDspRingbuffer( &e ); + } else if ( strcmp(m->label(), "16") == 0 ) { + EventLooperLoopLength e = EventLooperLoopLength(0, 16); + writeToDspRingbuffer( &e ); + } else if ( strcmp(m->label(), "32") == 0 ) { + EventLooperLoopLength e = EventLooperLoopLength(0, 32); + writeToDspRingbuffer( &e ); + } + else if ( strcmp(m->label(), "Record") == 0 ) { - - //clips[clipNum].name = "title"; - clips[clipNum].state = ClipState::CLIP_QUEUED; + clips[clipNum].state = ClipState::CLIP_RECORDING; + EventLooperState e = EventLooperState( 0, Looper::STATE_RECORD_QUEUED); + writeToDspRingbuffer( &e ); } } else diff --git a/src/looper.cxx b/src/looper.cxx index a4424f3..390a909 100644 --- a/src/looper.cxx +++ b/src/looper.cxx @@ -248,7 +248,7 @@ void Looper::beat() void Looper::setLoopLength(float l) { - numBeats *= l; + numBeats = l * 4; // smallest loop = 4 beats if ( numBeats < 4 )