2021-09-07 00:59:52 -04:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2021 Paul Davis <paul@linuxaudiosystems.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
|
|
|
|
2021-12-14 10:36:43 -05:00
|
|
|
#include <gtkmm/alignment.h>
|
2021-09-07 00:59:52 -04:00
|
|
|
#include <gtkmm/filechooserdialog.h>
|
|
|
|
#include <gtkmm/menu.h>
|
|
|
|
#include <gtkmm/menuitem.h>
|
|
|
|
#include <gtkmm/stock.h>
|
|
|
|
|
|
|
|
#include "pbd/compose.h"
|
|
|
|
#include "pbd/convert.h"
|
|
|
|
|
|
|
|
#include "ardour/region.h"
|
|
|
|
#include "ardour/triggerbox.h"
|
|
|
|
|
|
|
|
#include "gtkmm2ext/utils.h"
|
|
|
|
|
2021-12-02 00:51:18 -05:00
|
|
|
#include "audio_region_properties_box.h"
|
2021-12-15 19:08:15 -05:00
|
|
|
#include "audio_trigger_properties_box.h"
|
2021-12-02 00:51:18 -05:00
|
|
|
#include "audio_region_operations_box.h"
|
2021-12-15 19:08:15 -05:00
|
|
|
|
|
|
|
#include "midi_trigger_properties_box.h"
|
|
|
|
#include "midi_region_properties_box.h"
|
2021-12-02 00:51:18 -05:00
|
|
|
#include "midi_region_operations_box.h"
|
2021-12-15 19:08:15 -05:00
|
|
|
|
2021-12-02 00:51:18 -05:00
|
|
|
#include "slot_properties_box.h"
|
2021-12-09 21:45:25 -05:00
|
|
|
#include "midi_clip_editor.h"
|
2021-12-02 00:51:18 -05:00
|
|
|
|
2021-09-07 00:59:52 -04:00
|
|
|
#include "ardour_ui.h"
|
|
|
|
#include "gui_thread.h"
|
|
|
|
#include "trigger_ui.h"
|
|
|
|
#include "public_editor.h"
|
|
|
|
#include "ui_config.h"
|
|
|
|
#include "utils.h"
|
|
|
|
|
2021-09-27 10:28:10 -04:00
|
|
|
#include "pbd/i18n.h"
|
|
|
|
|
2021-09-07 00:59:52 -04:00
|
|
|
using namespace ARDOUR;
|
2021-09-10 15:05:19 -04:00
|
|
|
using namespace ArdourWidgets;
|
2021-09-07 00:59:52 -04:00
|
|
|
using namespace Gtkmm2ext;
|
|
|
|
using namespace PBD;
|
2021-09-29 13:20:44 -04:00
|
|
|
using namespace Temporal;
|
2021-09-07 00:59:52 -04:00
|
|
|
|
2021-09-10 15:05:19 -04:00
|
|
|
static std::vector<std::string> follow_strings;
|
|
|
|
static std::string longest_follow;
|
2021-09-29 13:20:44 -04:00
|
|
|
static std::vector<std::string> quantize_strings;
|
|
|
|
static std::string longest_quantize;
|
2021-10-01 20:38:42 -04:00
|
|
|
static std::vector<std::string> launch_strings;
|
|
|
|
static std::string longest_launch;
|
2021-09-10 15:05:19 -04:00
|
|
|
|
2021-11-30 13:14:19 -05:00
|
|
|
TriggerUI::TriggerUI () :
|
2021-12-14 11:40:25 -05:00
|
|
|
_follow_action_button (ArdourButton::led_default_elements)
|
2021-12-14 14:10:47 -05:00
|
|
|
, _velocity_adjustment(1.,0.,1.0,0.01,0.1)
|
|
|
|
, _velocity_slider (&_velocity_adjustment, boost::shared_ptr<PBD::Controllable>(), 24/*length*/, 12/*girth*/ )
|
|
|
|
, _follow_probability_adjustment(0,0,100,2,5)
|
|
|
|
, _follow_probability_slider (&_follow_probability_adjustment, boost::shared_ptr<PBD::Controllable>(), 24/*length*/, 12/*girth*/ )
|
2021-12-14 10:36:43 -05:00
|
|
|
, _follow_count_adjustment (1, 1, 128, 1, 4)
|
|
|
|
, _follow_count_spinner (_follow_count_adjustment)
|
2021-12-14 11:40:25 -05:00
|
|
|
, _legato_button (ArdourButton::led_default_elements)
|
|
|
|
|
2021-09-07 00:59:52 -04:00
|
|
|
{
|
2021-11-30 13:14:19 -05:00
|
|
|
trigger = NULL;
|
|
|
|
|
2021-09-29 20:01:19 -04:00
|
|
|
using namespace Gtk::Menu_Helpers;
|
|
|
|
|
2021-09-10 15:05:19 -04:00
|
|
|
if (follow_strings.empty()) {
|
|
|
|
follow_strings.push_back (follow_action_to_string (Trigger::Stop));
|
|
|
|
follow_strings.push_back (follow_action_to_string (Trigger::Again));
|
|
|
|
follow_strings.push_back (follow_action_to_string (Trigger::QueuedTrigger));
|
|
|
|
follow_strings.push_back (follow_action_to_string (Trigger::NextTrigger));
|
|
|
|
follow_strings.push_back (follow_action_to_string (Trigger::PrevTrigger));
|
|
|
|
follow_strings.push_back (follow_action_to_string (Trigger::FirstTrigger));
|
|
|
|
follow_strings.push_back (follow_action_to_string (Trigger::LastTrigger));
|
|
|
|
follow_strings.push_back (follow_action_to_string (Trigger::AnyTrigger));
|
|
|
|
follow_strings.push_back (follow_action_to_string (Trigger::OtherTrigger));
|
|
|
|
|
|
|
|
for (std::vector<std::string>::const_iterator i = follow_strings.begin(); i != follow_strings.end(); ++i) {
|
|
|
|
if (i->length() > longest_follow.length()) {
|
|
|
|
longest_follow = *i;
|
|
|
|
}
|
|
|
|
}
|
2021-09-29 13:20:44 -04:00
|
|
|
|
2021-10-01 20:38:42 -04:00
|
|
|
launch_strings.push_back (launch_style_to_string (Trigger::OneShot));
|
|
|
|
launch_strings.push_back (launch_style_to_string (Trigger::Gate));
|
|
|
|
launch_strings.push_back (launch_style_to_string (Trigger::Toggle));
|
|
|
|
launch_strings.push_back (launch_style_to_string (Trigger::Repeat));
|
|
|
|
|
|
|
|
for (std::vector<std::string>::const_iterator i = launch_strings.begin(); i != launch_strings.end(); ++i) {
|
|
|
|
if (i->length() > longest_launch.length()) {
|
|
|
|
longest_launch = *i;
|
|
|
|
}
|
|
|
|
}
|
2021-09-10 15:05:19 -04:00
|
|
|
}
|
|
|
|
|
2021-11-30 13:14:19 -05:00
|
|
|
set_spacings (2);
|
|
|
|
set_homogeneous (false);
|
2021-09-10 15:05:19 -04:00
|
|
|
|
2021-12-14 11:40:25 -05:00
|
|
|
_follow_action_button.set_name("FollowAction");
|
|
|
|
_follow_action_button.set_text (_("Follow Action"));
|
|
|
|
_follow_action_button.signal_event().connect (sigc::mem_fun (*this, (&TriggerUI::follow_action_button_event)));
|
2021-09-10 15:05:19 -04:00
|
|
|
|
2021-12-14 10:36:43 -05:00
|
|
|
_follow_count_spinner.set_can_focus(false);
|
|
|
|
_follow_count_spinner.signal_changed ().connect (sigc::mem_fun (*this, &TriggerUI::follow_count_event));
|
|
|
|
|
2021-12-14 14:10:47 -05:00
|
|
|
_velocity_adjustment.signal_value_changed ().connect (sigc::mem_fun (*this, &TriggerUI::velocity_adjusted));
|
2021-11-30 13:14:19 -05:00
|
|
|
|
2021-12-14 14:10:47 -05:00
|
|
|
_velocity_slider.set_name("FollowAction");
|
|
|
|
|
|
|
|
_follow_probability_adjustment.signal_value_changed ().connect (sigc::mem_fun (*this, &TriggerUI::probability_adjusted));
|
|
|
|
|
|
|
|
_follow_probability_slider.set_name("FollowAction");
|
2021-12-14 11:40:25 -05:00
|
|
|
|
|
|
|
_follow_left.set_name("FollowAction");
|
|
|
|
_follow_left.append_text_item (_("None"));
|
|
|
|
_follow_left.append_text_item (_("Repeat"));
|
|
|
|
_follow_left.append_text_item (_("Next"));
|
|
|
|
_follow_left.append_text_item (_("Previous"));
|
|
|
|
_follow_left.set_sizing_text (longest_follow);
|
|
|
|
|
|
|
|
_follow_right.set_name("FollowAction");
|
|
|
|
_follow_right.append_text_item (_("None"));
|
|
|
|
_follow_right.append_text_item (_("Repeat"));
|
|
|
|
_follow_right.append_text_item (_("Next"));
|
|
|
|
_follow_right.append_text_item (_("Previous"));
|
|
|
|
_follow_right.set_sizing_text (longest_follow);
|
|
|
|
|
|
|
|
_launch_style_button.set_name("FollowAction");
|
|
|
|
_launch_style_button.set_sizing_text (longest_launch);
|
|
|
|
_launch_style_button.AddMenuElem (MenuElem (launch_style_to_string (Trigger::OneShot), sigc::bind (sigc::mem_fun (*this, &TriggerUI::set_launch_style), Trigger::OneShot)));
|
|
|
|
_launch_style_button.AddMenuElem (MenuElem (launch_style_to_string (Trigger::Gate), sigc::bind (sigc::mem_fun (*this, &TriggerUI::set_launch_style), Trigger::Gate)));
|
|
|
|
_launch_style_button.AddMenuElem (MenuElem (launch_style_to_string (Trigger::Toggle), sigc::bind (sigc::mem_fun (*this, &TriggerUI::set_launch_style), Trigger::Toggle)));
|
|
|
|
_launch_style_button.AddMenuElem (MenuElem (launch_style_to_string (Trigger::Repeat), sigc::bind (sigc::mem_fun (*this, &TriggerUI::set_launch_style), Trigger::Repeat)));
|
|
|
|
|
|
|
|
_launch_style_button.set_name("FollowAction");
|
|
|
|
_legato_button.set_text (_("Legato"));
|
|
|
|
_legato_button.signal_event().connect (sigc::mem_fun (*this, (&TriggerUI::legato_button_event)));
|
|
|
|
|
|
|
|
#define quantize_item(b) _quantize_button.AddMenuElem (MenuElem (quantize_length_to_string (b), sigc::bind (sigc::mem_fun (*this, &TriggerUI::set_quantize), b)));
|
2021-09-29 20:01:19 -04:00
|
|
|
|
|
|
|
quantize_item (BBT_Offset (0, 0, 0));
|
|
|
|
quantize_item (BBT_Offset (0, 1, 0));
|
|
|
|
quantize_item (BBT_Offset (0, 2, 0));
|
|
|
|
quantize_item (BBT_Offset (0, 4, 0));
|
|
|
|
quantize_item (BBT_Offset (0, 0, Temporal::ticks_per_beat/2));
|
|
|
|
quantize_item (BBT_Offset (0, 0, Temporal::ticks_per_beat/4));
|
|
|
|
quantize_item (BBT_Offset (0, 0, Temporal::ticks_per_beat/8));
|
|
|
|
quantize_item (BBT_Offset (0, 0, Temporal::ticks_per_beat/16));
|
|
|
|
|
|
|
|
for (std::vector<std::string>::const_iterator i = quantize_strings.begin(); i != quantize_strings.end(); ++i) {
|
|
|
|
if (i->length() > longest_quantize.length()) {
|
|
|
|
longest_quantize = *i;
|
|
|
|
}
|
2021-09-29 13:20:44 -04:00
|
|
|
}
|
2021-12-14 11:40:25 -05:00
|
|
|
_quantize_button.set_sizing_text (longest_quantize);
|
|
|
|
_quantize_button.set_name("FollowAction");
|
2021-09-29 20:01:19 -04:00
|
|
|
|
|
|
|
#undef quantize_item
|
|
|
|
|
2021-11-30 13:14:19 -05:00
|
|
|
int row=0;
|
|
|
|
Gtk::Label *label;
|
2021-10-01 20:38:42 -04:00
|
|
|
|
2021-11-30 13:14:19 -05:00
|
|
|
label = manage(new Gtk::Label(_("Velocity Sense:"))); label->set_alignment(1.0, 0.5);
|
2021-12-13 00:49:29 -05:00
|
|
|
attach(*label, 0, 1, row, row+1, Gtk::FILL, Gtk::SHRINK );
|
2021-12-14 14:10:47 -05:00
|
|
|
attach(_velocity_slider, 1, 2, row, row+1, Gtk::FILL, Gtk::SHRINK ); row++;
|
2021-10-01 20:38:42 -04:00
|
|
|
|
2021-11-30 13:14:19 -05:00
|
|
|
label = manage(new Gtk::Label(_("Launch Style:"))); label->set_alignment(1.0, 0.5);
|
|
|
|
attach(*label, 0, 1, row, row+1, Gtk::FILL, Gtk::SHRINK );
|
2021-12-14 11:40:25 -05:00
|
|
|
attach(_launch_style_button, 1, 2, row, row+1, Gtk::FILL, Gtk::SHRINK ); row++;
|
2021-09-10 15:05:19 -04:00
|
|
|
|
2021-11-30 13:14:19 -05:00
|
|
|
label = manage(new Gtk::Label(_("Launch Quantize:"))); label->set_alignment(1.0, 0.5);
|
|
|
|
attach(*label, 0, 1, row, row+1, Gtk::FILL, Gtk::SHRINK );
|
2021-12-14 11:40:25 -05:00
|
|
|
attach(_quantize_button, 1, 2, row, row+1, Gtk::FILL, Gtk::SHRINK ); row++;
|
2021-09-29 13:20:44 -04:00
|
|
|
|
2021-11-30 13:14:19 -05:00
|
|
|
label = manage(new Gtk::Label(_("Legato Mode:"))); label->set_alignment(1.0, 0.5);
|
|
|
|
attach(*label, 0, 1, row, row+1, Gtk::FILL, Gtk::SHRINK );
|
2021-12-14 11:40:25 -05:00
|
|
|
attach(_legato_button, 1, 2, row, row+1, Gtk::FILL, Gtk::SHRINK ); row++;
|
2021-10-01 20:38:42 -04:00
|
|
|
|
2021-12-14 11:40:25 -05:00
|
|
|
attach(_follow_action_button, 0, 2, row, row+1, Gtk::FILL, Gtk::SHRINK ); row++;
|
2021-12-14 10:36:43 -05:00
|
|
|
|
|
|
|
label = manage(new Gtk::Label(_("Follow Count:"))); label->set_alignment(1.0, 0.5);
|
|
|
|
attach(*label, 0, 1, row, row+1, Gtk::FILL, Gtk::SHRINK );
|
|
|
|
Gtk::Alignment *align = manage (new Gtk::Alignment (0, .5, 0, 0));
|
|
|
|
align->add (_follow_count_spinner);
|
|
|
|
attach(*align, 1, 2, row, row+1, Gtk::FILL, Gtk::SHRINK, 0, 0 ); row++;
|
|
|
|
|
2021-12-14 14:10:47 -05:00
|
|
|
Gtkmm2ext::set_size_request_to_display_given_text (_left_probability_label, "100% Left ", 12, 0);
|
|
|
|
_left_probability_label.set_alignment(0.0, 0.5);
|
|
|
|
Gtkmm2ext::set_size_request_to_display_given_text (_right_probability_label, "100% Right", 12, 0);
|
|
|
|
_right_probability_label.set_alignment(1.0, 0.5);
|
|
|
|
|
|
|
|
Gtk::Table *prob_table = manage(new Gtk::Table());
|
|
|
|
prob_table->set_spacings(2);
|
|
|
|
prob_table->attach(_follow_probability_slider, 0, 2, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::SHRINK );
|
|
|
|
prob_table->attach(_left_probability_label, 0, 1, 1, 2, Gtk::FILL, Gtk::SHRINK );
|
|
|
|
prob_table->attach(_right_probability_label, 1, 2, 1, 2, Gtk::FILL, Gtk::SHRINK );
|
|
|
|
|
|
|
|
attach( *prob_table, 0, 2, row, row+1, Gtk::FILL|Gtk::EXPAND, Gtk::SHRINK ); row++;
|
|
|
|
attach(_follow_left, 0, 1, row, row+1, Gtk::FILL, Gtk::SHRINK );
|
|
|
|
attach(_follow_right, 1, 2, row, row+1, Gtk::FILL, Gtk::SHRINK ); row++;
|
2021-11-29 20:21:04 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
TriggerUI::~TriggerUI ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TriggerUI::set_trigger (ARDOUR::Trigger* t)
|
|
|
|
{
|
|
|
|
trigger = t;
|
2021-09-14 23:38:48 -04:00
|
|
|
|
2021-09-28 19:45:58 -04:00
|
|
|
PropertyChange pc;
|
|
|
|
|
|
|
|
pc.add (Properties::use_follow);
|
|
|
|
pc.add (Properties::legato);
|
2021-09-29 20:01:19 -04:00
|
|
|
pc.add (Properties::quantization);
|
2021-10-01 20:38:42 -04:00
|
|
|
pc.add (Properties::launch_style);
|
2021-12-14 10:36:43 -05:00
|
|
|
pc.add (Properties::follow_count);
|
2021-10-01 20:38:42 -04:00
|
|
|
pc.add (Properties::follow_action0);
|
|
|
|
pc.add (Properties::follow_action1);
|
2021-12-14 14:10:47 -05:00
|
|
|
pc.add (Properties::velocity_effect);
|
|
|
|
pc.add (Properties::follow_action_probability);
|
2021-09-28 19:45:58 -04:00
|
|
|
|
|
|
|
trigger_changed (pc);
|
|
|
|
|
2021-11-29 20:21:04 -05:00
|
|
|
trigger->PropertyChanged.connect (trigger_connections, invalidator (*this), boost::bind (&TriggerUI::trigger_changed, this, _1), gui_context());
|
2021-09-10 15:05:19 -04:00
|
|
|
}
|
2021-09-07 01:21:22 -04:00
|
|
|
|
|
|
|
|
2021-09-29 20:01:19 -04:00
|
|
|
void
|
|
|
|
TriggerUI::set_quantize (BBT_Offset bbo)
|
|
|
|
{
|
|
|
|
if (bbo == BBT_Offset (0, 0, 0)) {
|
|
|
|
/* use grid */
|
|
|
|
bbo = BBT_Offset (1, 2, 3); /* XXX get grid from editor */
|
|
|
|
}
|
|
|
|
|
2021-11-29 20:21:04 -05:00
|
|
|
trigger->set_quantization (bbo);
|
2021-09-29 20:01:19 -04:00
|
|
|
}
|
|
|
|
|
2021-12-14 10:36:43 -05:00
|
|
|
void
|
|
|
|
TriggerUI::follow_count_event ()
|
|
|
|
{
|
|
|
|
trigger->set_follow_count ((int) _follow_count_adjustment.get_value());
|
|
|
|
}
|
|
|
|
|
2021-12-14 14:10:47 -05:00
|
|
|
void
|
|
|
|
TriggerUI::velocity_adjusted ()
|
|
|
|
{
|
|
|
|
trigger->set_midi_velocity_effect (_velocity_adjustment.get_value());
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TriggerUI::probability_adjusted ()
|
|
|
|
{
|
|
|
|
trigger->set_follow_action_probability ((int) _follow_probability_adjustment.get_value());
|
|
|
|
}
|
|
|
|
|
2021-09-28 19:45:58 -04:00
|
|
|
bool
|
|
|
|
TriggerUI::follow_action_button_event (GdkEvent* ev)
|
|
|
|
{
|
|
|
|
switch (ev->type) {
|
|
|
|
case GDK_BUTTON_PRESS:
|
2021-11-29 20:21:04 -05:00
|
|
|
trigger->set_use_follow (!trigger->use_follow());
|
2021-09-28 19:45:58 -04:00
|
|
|
return true;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-10-02 20:36:14 -04:00
|
|
|
bool
|
|
|
|
TriggerUI::legato_button_event (GdkEvent* ev)
|
|
|
|
{
|
|
|
|
switch (ev->type) {
|
|
|
|
case GDK_BUTTON_PRESS:
|
2021-11-29 20:21:04 -05:00
|
|
|
trigger->set_legato (!trigger->legato());
|
2021-10-02 20:36:14 -04:00
|
|
|
return true;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-10-01 20:38:42 -04:00
|
|
|
void
|
|
|
|
TriggerUI::set_launch_style (Trigger::LaunchStyle ls)
|
|
|
|
{
|
2021-11-29 20:21:04 -05:00
|
|
|
trigger->set_launch_style (ls);
|
2021-10-01 20:38:42 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string
|
|
|
|
TriggerUI::launch_style_to_string (Trigger::LaunchStyle ls)
|
|
|
|
{
|
|
|
|
switch (ls) {
|
|
|
|
case Trigger::OneShot:
|
|
|
|
return _("One Shot");
|
|
|
|
case Trigger::Gate:
|
|
|
|
return _("Gate");
|
|
|
|
case Trigger::Toggle:
|
|
|
|
return _("Toggle");
|
|
|
|
case Trigger::Repeat:
|
|
|
|
return _("Repeat");
|
|
|
|
}
|
|
|
|
/*NOTREACHED*/
|
|
|
|
return std::string();
|
|
|
|
}
|
|
|
|
|
2021-09-29 13:20:44 -04:00
|
|
|
std::string
|
2021-09-29 20:01:19 -04:00
|
|
|
TriggerUI::quantize_length_to_string (BBT_Offset const & ql)
|
2021-09-29 13:20:44 -04:00
|
|
|
{
|
2021-09-29 20:01:19 -04:00
|
|
|
if (ql == BBT_Offset (0, 1, 0)) {
|
2021-09-29 13:20:44 -04:00
|
|
|
return _("1/4");
|
2021-09-29 20:01:19 -04:00
|
|
|
} else if (ql == BBT_Offset (0, 2, 0)) {
|
2021-09-29 13:20:44 -04:00
|
|
|
return _("1/2");
|
2021-09-29 20:01:19 -04:00
|
|
|
} else if (ql == BBT_Offset (0, 4, 0)) {
|
2021-09-29 13:20:44 -04:00
|
|
|
return _("Whole");
|
2021-09-29 20:01:19 -04:00
|
|
|
} else if (ql == BBT_Offset (0, 0,Temporal::ticks_per_beat/2)) {
|
2021-09-29 13:20:44 -04:00
|
|
|
return _("1/8");
|
2021-09-29 20:01:19 -04:00
|
|
|
} else if (ql == BBT_Offset (0, 0,Temporal::ticks_per_beat/4)) {
|
2021-09-29 13:20:44 -04:00
|
|
|
return _("1/16");
|
2021-09-29 20:01:19 -04:00
|
|
|
} else if (ql == BBT_Offset (0, 0,Temporal::ticks_per_beat/8)) {
|
2021-09-29 13:20:44 -04:00
|
|
|
return _("1/32");
|
2021-09-29 20:01:19 -04:00
|
|
|
} else if (ql == BBT_Offset (0, 0,Temporal::ticks_per_beat/16)) {
|
2021-09-29 13:20:44 -04:00
|
|
|
return _("1/64");
|
|
|
|
} else {
|
|
|
|
return "???";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-10 15:05:19 -04:00
|
|
|
std::string
|
|
|
|
TriggerUI::follow_action_to_string (Trigger::FollowAction fa)
|
|
|
|
{
|
|
|
|
switch (fa) {
|
2021-12-05 11:56:42 -05:00
|
|
|
case Trigger::None:
|
|
|
|
return _("None");
|
2021-09-10 15:05:19 -04:00
|
|
|
case Trigger::Stop:
|
|
|
|
return _("Stop");
|
|
|
|
case Trigger::Again:
|
|
|
|
return _("Again");
|
|
|
|
case Trigger::QueuedTrigger:
|
|
|
|
return _("Queued");
|
|
|
|
case Trigger::NextTrigger:
|
|
|
|
return _("Next");
|
|
|
|
case Trigger::PrevTrigger:
|
|
|
|
return _("Prev");
|
|
|
|
case Trigger::FirstTrigger:
|
|
|
|
return _("First");
|
|
|
|
case Trigger::LastTrigger:
|
|
|
|
return _("Last");
|
|
|
|
case Trigger::AnyTrigger:
|
|
|
|
return _("Any");
|
|
|
|
case Trigger::OtherTrigger:
|
|
|
|
return _("Other");
|
|
|
|
}
|
|
|
|
/*NOTREACHED*/
|
|
|
|
return std::string();
|
2021-09-07 00:59:52 -04:00
|
|
|
}
|
|
|
|
|
2021-09-10 15:05:19 -04:00
|
|
|
void
|
2021-09-28 19:45:58 -04:00
|
|
|
TriggerUI::trigger_changed (PropertyChange pc)
|
2021-09-07 00:59:52 -04:00
|
|
|
{
|
2021-09-29 20:01:19 -04:00
|
|
|
if (pc.contains (Properties::quantization)) {
|
2021-11-29 20:21:04 -05:00
|
|
|
BBT_Offset bbo (trigger->quantization());
|
2021-12-14 11:40:25 -05:00
|
|
|
_quantize_button.set_active (quantize_length_to_string (bbo));
|
2021-10-01 20:38:42 -04:00
|
|
|
std::cerr << "\n\n !!! quantize is " << quantize_length_to_string (bbo) << std::endl << std::endl;
|
2021-09-29 20:01:19 -04:00
|
|
|
}
|
|
|
|
|
2021-09-28 19:45:58 -04:00
|
|
|
if (pc.contains (Properties::use_follow)) {
|
2021-12-14 11:40:25 -05:00
|
|
|
_follow_action_button.set_active_state (trigger->use_follow() ? Gtkmm2ext::ExplicitActive : Gtkmm2ext::Off);
|
2021-09-28 19:45:58 -04:00
|
|
|
}
|
2021-10-01 20:38:42 -04:00
|
|
|
|
2021-12-14 10:36:43 -05:00
|
|
|
if (pc.contains (Properties::follow_count)) {
|
|
|
|
_follow_count_adjustment.set_value (trigger->follow_count());
|
|
|
|
}
|
|
|
|
|
2021-10-02 20:36:14 -04:00
|
|
|
if (pc.contains (Properties::legato)) {
|
2021-12-14 11:40:25 -05:00
|
|
|
_legato_button.set_active_state (trigger->legato() ? Gtkmm2ext::ExplicitActive : Gtkmm2ext::Off);
|
2021-10-02 20:36:14 -04:00
|
|
|
}
|
|
|
|
|
2021-10-01 20:38:42 -04:00
|
|
|
if (pc.contains (Properties::launch_style)) {
|
2021-12-14 11:40:25 -05:00
|
|
|
_launch_style_button.set_active (launch_style_to_string (trigger->launch_style()));
|
2021-10-01 20:38:42 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (pc.contains (Properties::follow_action0)) {
|
2021-12-14 11:40:25 -05:00
|
|
|
_follow_right.set_text (follow_action_to_string (trigger->follow_action (0)));
|
2021-10-01 20:38:42 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (pc.contains (Properties::follow_action1)) {
|
2021-12-14 11:40:25 -05:00
|
|
|
_follow_left.set_text (follow_action_to_string (trigger->follow_action (1)));
|
2021-10-01 20:38:42 -04:00
|
|
|
}
|
2021-12-14 10:51:03 -05:00
|
|
|
|
2021-12-14 14:10:47 -05:00
|
|
|
if (pc.contains (Properties::velocity_effect)) {
|
|
|
|
_velocity_adjustment.set_value (trigger->midi_velocity_effect());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pc.contains (Properties::follow_action_probability)) {
|
|
|
|
int pval = trigger->follow_action_probability();
|
|
|
|
_follow_probability_adjustment.set_value (pval);
|
|
|
|
_left_probability_label.set_text (string_compose(_("%1%% Left"), pval));
|
|
|
|
_right_probability_label.set_text (string_compose(_("%1%% Right"), 100-pval));
|
|
|
|
}
|
|
|
|
|
2021-12-14 10:51:03 -05:00
|
|
|
if (trigger->use_follow()) {
|
2021-12-14 11:40:25 -05:00
|
|
|
_follow_left.set_sensitive(true);
|
|
|
|
_follow_right.set_sensitive(true);
|
2021-12-14 10:51:03 -05:00
|
|
|
_follow_count_spinner.set_sensitive(true);
|
2021-12-14 14:10:47 -05:00
|
|
|
_follow_probability_slider.set_sensitive(true);
|
|
|
|
_left_probability_label.set_sensitive(true);
|
|
|
|
_right_probability_label.set_sensitive(true);
|
2021-12-14 10:51:03 -05:00
|
|
|
} else {
|
2021-12-14 11:40:25 -05:00
|
|
|
_follow_left.set_sensitive(false);
|
|
|
|
_follow_right.set_sensitive(false);
|
2021-12-14 10:51:03 -05:00
|
|
|
_follow_count_spinner.set_sensitive(false);
|
2021-12-14 14:10:47 -05:00
|
|
|
_follow_probability_slider.set_sensitive(false);
|
|
|
|
_left_probability_label.set_sensitive(false);
|
|
|
|
_right_probability_label.set_sensitive(false);
|
2021-12-14 10:51:03 -05:00
|
|
|
}
|
2021-09-07 00:59:52 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------ */
|
|
|
|
|
2021-11-29 20:21:04 -05:00
|
|
|
TriggerWidget::TriggerWidget ()
|
2021-09-07 00:59:52 -04:00
|
|
|
{
|
2021-11-30 13:14:19 -05:00
|
|
|
ui = new TriggerUI ();
|
|
|
|
pack_start(*ui);
|
|
|
|
ui->show();
|
|
|
|
// set_background_color (UIConfiguration::instance().color (X_("theme:bg")));
|
2021-09-07 00:59:52 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------ */
|
|
|
|
|
2021-11-30 13:14:19 -05:00
|
|
|
TriggerWindow::TriggerWindow (Trigger* slot)
|
2021-09-07 00:59:52 -04:00
|
|
|
{
|
2021-11-30 13:14:19 -05:00
|
|
|
set_title (string_compose (_("Trigger: %1"), slot->name()));
|
|
|
|
|
2021-12-02 00:51:18 -05:00
|
|
|
SlotPropertiesBox* slot_prop_box = manage (new SlotPropertiesBox ());
|
|
|
|
slot_prop_box->set_slot(slot);
|
|
|
|
|
|
|
|
|
|
|
|
Gtk::Table* table = manage (new Gtk::Table);
|
|
|
|
table->set_homogeneous (false);
|
|
|
|
table->set_spacings (16);
|
|
|
|
table->set_border_width (8);
|
|
|
|
|
|
|
|
int col = 0;
|
|
|
|
table->attach(*slot_prop_box, col, col+1, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND ); col++;
|
|
|
|
|
|
|
|
if (slot->region()) {
|
2021-12-02 11:50:19 -05:00
|
|
|
if (slot->region()->data_type() == DataType::AUDIO) {
|
2021-12-15 19:08:15 -05:00
|
|
|
_trig_box = manage(new AudioTriggerPropertiesBox ());
|
2021-12-02 11:50:19 -05:00
|
|
|
_ops_box = manage(new AudioRegionOperationsBox ());
|
2021-12-09 21:45:25 -05:00
|
|
|
_trim_box = manage(new AudioClipEditorBox ());
|
2021-12-15 19:08:15 -05:00
|
|
|
|
|
|
|
_trig_box->set_trigger(slot);
|
2021-12-02 11:50:19 -05:00
|
|
|
} else {
|
2021-12-15 19:08:15 -05:00
|
|
|
_trig_box = manage(new MidiTriggerPropertiesBox ());
|
2021-12-02 11:50:19 -05:00
|
|
|
_ops_box = manage(new MidiRegionOperationsBox ());
|
2021-12-09 21:45:25 -05:00
|
|
|
_trim_box = manage(new MidiClipEditorBox ());
|
2021-12-15 19:08:15 -05:00
|
|
|
|
|
|
|
_trig_box->set_trigger(slot);
|
2021-12-02 11:50:19 -05:00
|
|
|
}
|
2021-12-13 00:49:29 -05:00
|
|
|
|
|
|
|
_trim_box->set_region(slot->region(), slot);
|
2021-12-02 11:50:19 -05:00
|
|
|
_ops_box->set_session(&slot->region()->session());
|
|
|
|
|
2021-12-15 19:08:15 -05:00
|
|
|
table->attach(*_trig_box, col, col+1, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND ); col++;
|
2021-12-02 11:50:19 -05:00
|
|
|
table->attach(*_trim_box, col, col+1, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND ); col++;
|
|
|
|
table->attach(*_ops_box, col, col+1, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND ); col++;
|
2021-12-02 00:51:18 -05:00
|
|
|
}
|
2021-12-02 11:50:19 -05:00
|
|
|
|
|
|
|
add (*table);
|
|
|
|
table->show_all();
|
2021-09-07 00:59:52 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
TriggerWindow::on_key_press_event (GdkEventKey* ev)
|
|
|
|
{
|
|
|
|
Gtk::Window& main_window (ARDOUR_UI::instance()->main_window());
|
|
|
|
return ARDOUR_UI_UTILS::relay_key_press (ev, &main_window);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
TriggerWindow::on_key_release_event (GdkEventKey* ev)
|
|
|
|
{
|
|
|
|
Gtk::Window& main_window (ARDOUR_UI::instance()->main_window());
|
|
|
|
return ARDOUR_UI_UTILS::relay_key_press (ev, &main_window);
|
|
|
|
}
|