Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add global cycle pos cmds and show it in gui #26

Merged
merged 1 commit into from
Jun 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/command_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ CommandMap::CommandMap()
add_global_control("use_midi_start", Event::UseMidiStart, UnitBoolean, 0.0f, 1.0f, 1.0f);
add_global_control("use_midi_stop", Event::UseMidiStop, UnitBoolean, 0.0f, 1.0f, 1.0f);
add_global_control("send_midi_start_on_trigger", Event::SendMidiStartOnTrigger, UnitBoolean, 0.0f, 1.0f, 1.0f);
add_global_control("global_cycle_len", Event::GlobalCycleLen, UnitSeconds, 0.0f, 1e6);
add_global_control("global_cycle_pos", Event::GlobalCyclePos, UnitSeconds, 0.0f, 1e6);
_str_ctrl_map.insert (_global_controls.begin(), _global_controls.end());

// reverse it
Expand Down
6 changes: 6 additions & 0 deletions src/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1542,6 +1542,12 @@ Engine::get_control_value (Event::control_t ctrl, int8_t instance)
else if (ctrl == Event::JackTimebaseMaster) {
return _jack_timebase_master ? 1.0f: 0.0f;
}
else if (ctrl == Event::GlobalCycleLen) {
return _tempo_frames / _driver->get_samplerate();
}
else if (ctrl == Event::GlobalCyclePos) {
return _tempo_counter / _driver->get_samplerate();
}

}

Expand Down
4 changes: 3 additions & 1 deletion src/event.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,9 @@ namespace SooperLooper {
// Put all new controls at the end to avoid screwing up the order of existing AU sessions (who store these numbers)
ReplaceQuantized,
SendMidiStartOnTrigger,
DiscretePreFader
DiscretePreFader,
GlobalCycleLen,
GlobalCyclePos
} Control;

int8_t Instance;
Expand Down
19 changes: 18 additions & 1 deletion src/gui/choice_box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ ChoiceBox::ChoiceBox(wxWindow * parent, wxWindowID id, bool bindable, const wxPo
_popup_menu = 0;
_data_value = 0;
_bindable = bindable;
_bar_value = 0.0f;

_bgcolor.Set(0,0,0);
_bgbrush.SetColour (_bgcolor);
Expand All @@ -69,7 +70,7 @@ ChoiceBox::ChoiceBox(wxWindow * parent, wxWindowID id, bool bindable, const wxPo
_textcolor = *wxWHITE;
_barcolor.Set(14, 50, 89);
_overbarcolor.Set(20, 40, 50);
_barbrush.SetColour(_bgcolor);
_barbrush.SetColour(_barcolor);

_bgbordercolor.Set(30,30,30);
_bordercolor.Set(67, 83, 103);
Expand Down Expand Up @@ -429,6 +430,11 @@ void ChoiceBox::draw_area(wxDC & dc)
shape[5].x = _width -1; shape[5].y = _height -1;

dc.DrawPolygon (6, shape);

if (_bar_value > 0.0f) {
dc.SetBrush(_barbrush);
dc.DrawRectangle (1, 1, (wxCoord)(_width*_bar_value-1), _height-2);
}

dc.SetPen(*wxTRANSPARENT_PEN);

Expand All @@ -443,3 +449,14 @@ void ChoiceBox::draw_area(wxDC & dc)


}

void ChoiceBox::set_bar_value(float val) {
if(val >= 0.0f && val <= 1.0f && _bar_value != val) {
_bar_value = val;
Refresh(false);
}
}

float ChoiceBox::get_bar_value() {
return _bar_value;
}
3 changes: 3 additions & 0 deletions src/gui/choice_box.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ class ChoiceBox
static void set_use_mousewheel_default (bool flag) { s_use_wheel_def = flag; }
static bool get_use_mousewheel_default () { return s_use_wheel_def; }

void set_bar_value (float val);
float get_bar_value ();

sigc::signal2<void, int, wxString> value_changed;
sigc::signal0<void> bind_request;
Expand Down Expand Up @@ -138,6 +140,7 @@ class ChoiceBox

bool _dragging;
int _last_x;
float _bar_value;

private:
// any class wishing to process wxWindows events must use this macro
Expand Down
4 changes: 4 additions & 0 deletions src/gui/loop_control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,10 +385,14 @@ LoopControl::register_global_updates(bool unreg)
if (unreg) {
lo_send(_osc_addr, "/unregister_auto_update", "siss", "in_peak_meter", 100, _our_url.c_str(), "/ctrl");
lo_send(_osc_addr, "/unregister_auto_update", "siss", "out_peak_meter", 100, _our_url.c_str(), "/ctrl");
lo_send(_osc_addr, "/unregister_auto_update", "siss", "global_cycle_len", 100, _our_url.c_str(), "/ctrl");
lo_send(_osc_addr, "/unregister_auto_update", "siss", "global_cycle_pos", 100, _our_url.c_str(), "/ctrl");
}
else {
lo_send(_osc_addr, "/register_auto_update", "siss", "in_peak_meter", 100, _our_url.c_str(), "/ctrl");
lo_send(_osc_addr, "/register_auto_update", "siss", "out_peak_meter", 100, _our_url.c_str(), "/ctrl");
lo_send(_osc_addr, "/register_auto_update", "siss", "global_cycle_len", 100, _our_url.c_str(), "/ctrl");
lo_send(_osc_addr, "/register_auto_update", "siss", "global_cycle_pos", 100, _our_url.c_str(), "/ctrl");
}
}

Expand Down
16 changes: 14 additions & 2 deletions src/gui/main_panel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ enum {
ID_MuteQuantCheck,
ID_OdubQuantCheck,
ID_SmartEighthCheck,
ID_ReplQuantCheck
ID_ReplQuantCheck,
ID_GlobalCyclePos
};


Expand Down Expand Up @@ -294,7 +295,6 @@ MainPanel::init()
_repl_quant_check->bind_request.connect (sigc::bind(mem_fun (*this, &MainPanel::on_bind_request), wxT("replace_quantized")));
rowsizer->Add (_repl_quant_check, 0, wxALL|wxEXPAND, 2);


rowsizer->Add (1, 1, 1);

wxStaticBitmap * logobit = new wxStaticBitmap(_top_panel, -1, wxBitmap(sl_logo_xpm));
Expand Down Expand Up @@ -740,6 +740,18 @@ MainPanel::update_controls()
_loop_control->get_global_value(wxT("selected_loop_num"), val);
set_curr_loop ((int) val);
}

if (_loop_control->is_global_updated(wxT("global_cycle_pos"))) {
float gclen, gcpos;
_loop_control->get_global_value(wxT("global_cycle_len"), gclen);
_loop_control->get_global_value(wxT("global_cycle_pos"), gcpos);
val = 0.0f;
// only display global cycle len if it is >= 1s to reduce visual noise
if(gclen >= 1.0f)
val = gcpos / gclen;
_quantize_choice->set_bar_value(val);
}

}

void
Expand Down