2006-07-23 08:03:19 -04:00
|
|
|
/*
|
2019-08-02 17:26:43 -04:00
|
|
|
* Copyright (C) 2006-2015 David Robillard <d@drobilla.net>
|
|
|
|
* Copyright (C) 2008-2012 Hans Baier <hansfbaier@googlemail.com>
|
|
|
|
* Copyright (C) 2008-2017 Paul Davis <paul@linuxaudiosystems.com>
|
|
|
|
* Copyright (C) 2009-2012 Carl Hetherington <carl@carlh.net>
|
|
|
|
* Copyright (C) 2013-2014 John Emmas <john@creativepost.co.uk>
|
|
|
|
* Copyright (C) 2013-2016 Tim Mayberry <mojofunk@gmail.com>
|
|
|
|
* Copyright (C) 2013-2019 Robin Gareus <robin@gareus.org>
|
|
|
|
* Copyright (C) 2014-2017 Ben Loftis <ben@harrisonconsoles.com>
|
|
|
|
* Copyright (C) 2015-2017 Nick Mainsbridge <mainsbridge@gmail.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.
|
|
|
|
*/
|
2006-07-23 08:03:19 -04:00
|
|
|
|
|
|
|
#include <cstdlib>
|
|
|
|
#include <cmath>
|
|
|
|
|
|
|
|
#include <algorithm>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include <sigc++/bind.h>
|
|
|
|
|
2017-07-16 21:48:18 -04:00
|
|
|
#include <gtkmm/separator.h>
|
|
|
|
#include <gtkmm/stock.h>
|
|
|
|
|
2009-02-25 13:26:51 -05:00
|
|
|
#include "pbd/error.h"
|
2013-07-17 06:03:34 -04:00
|
|
|
#include "pbd/ffs.h"
|
2009-02-25 13:26:51 -05:00
|
|
|
#include "pbd/stl_delete.h"
|
|
|
|
#include "pbd/whitespace.h"
|
2009-09-03 08:39:50 -04:00
|
|
|
#include "pbd/basename.h"
|
2009-02-25 13:26:51 -05:00
|
|
|
#include "pbd/enumwriter.h"
|
2009-09-03 08:39:50 -04:00
|
|
|
#include "pbd/memento_command.h"
|
2010-03-02 13:05:26 -05:00
|
|
|
#include "pbd/stateful_diff_command.h"
|
2006-07-23 08:03:19 -04:00
|
|
|
|
2010-07-16 10:55:11 -04:00
|
|
|
#include "gtkmm2ext/gtk_ui.h"
|
|
|
|
#include "gtkmm2ext/utils.h"
|
2006-07-23 08:03:19 -04:00
|
|
|
|
2017-07-15 11:38:28 -04:00
|
|
|
#include "widgets/tooltips.h"
|
|
|
|
|
2012-05-24 02:09:29 -04:00
|
|
|
#include "ardour/event_type_map.h"
|
2009-02-25 13:26:51 -05:00
|
|
|
#include "ardour/midi_patch_manager.h"
|
2011-10-19 17:53:09 -04:00
|
|
|
#include "ardour/midi_playlist.h"
|
|
|
|
#include "ardour/midi_region.h"
|
2009-09-03 08:39:50 -04:00
|
|
|
#include "ardour/midi_source.h"
|
2012-05-24 02:09:29 -04:00
|
|
|
#include "ardour/midi_track.h"
|
2011-10-19 17:53:09 -04:00
|
|
|
#include "ardour/operations.h"
|
2014-01-15 05:30:54 -05:00
|
|
|
#include "ardour/pannable.h"
|
|
|
|
#include "ardour/panner.h"
|
|
|
|
#include "ardour/panner_shell.h"
|
2009-02-25 13:26:51 -05:00
|
|
|
#include "ardour/playlist.h"
|
2016-10-29 13:28:18 -04:00
|
|
|
#include "ardour/plugin_insert.h"
|
2014-08-31 10:15:52 -04:00
|
|
|
#include "ardour/profile.h"
|
2012-05-24 02:09:29 -04:00
|
|
|
#include "ardour/region.h"
|
2009-09-03 08:39:50 -04:00
|
|
|
#include "ardour/region_factory.h"
|
2012-05-24 02:09:29 -04:00
|
|
|
#include "ardour/route.h"
|
2009-02-25 13:26:51 -05:00
|
|
|
#include "ardour/session.h"
|
2012-05-24 02:09:29 -04:00
|
|
|
#include "ardour/session_object.h"
|
|
|
|
#include "ardour/source.h"
|
|
|
|
#include "ardour/track.h"
|
|
|
|
#include "ardour/types.h"
|
2006-07-23 08:03:19 -04:00
|
|
|
|
2007-06-30 14:41:50 -04:00
|
|
|
#include "automation_line.h"
|
2009-09-03 08:39:50 -04:00
|
|
|
#include "automation_time_axis.h"
|
|
|
|
#include "editor.h"
|
2006-07-23 08:03:19 -04:00
|
|
|
#include "enums.h"
|
2009-09-03 08:39:50 -04:00
|
|
|
#include "ghostregion.h"
|
2006-07-23 08:03:19 -04:00
|
|
|
#include "gui_thread.h"
|
|
|
|
#include "keyboard.h"
|
2013-03-27 21:50:18 -04:00
|
|
|
#include "midi_channel_selector.h"
|
2009-09-03 08:39:50 -04:00
|
|
|
#include "midi_scroomer.h"
|
|
|
|
#include "midi_streamview.h"
|
|
|
|
#include "midi_region_view.h"
|
|
|
|
#include "midi_time_axis.h"
|
2017-03-29 17:41:10 -04:00
|
|
|
#include "patch_change_dialog.h"
|
2017-09-07 18:30:55 -04:00
|
|
|
#include "patch_change_widget.h"
|
2009-09-03 08:39:50 -04:00
|
|
|
#include "piano_roll_header.h"
|
2006-07-23 08:03:19 -04:00
|
|
|
#include "playlist_selector.h"
|
|
|
|
#include "plugin_selector.h"
|
|
|
|
#include "plugin_ui.h"
|
|
|
|
#include "point_selection.h"
|
2006-08-01 13:19:38 -04:00
|
|
|
#include "region_view.h"
|
2006-07-23 08:03:19 -04:00
|
|
|
#include "rgb_macros.h"
|
|
|
|
#include "selection.h"
|
2010-08-15 12:39:51 -04:00
|
|
|
#include "step_editor.h"
|
2006-07-23 08:03:19 -04:00
|
|
|
#include "utils.h"
|
2013-04-04 00:32:52 -04:00
|
|
|
#include "note_base.h"
|
2006-07-23 08:03:19 -04:00
|
|
|
|
2009-02-25 13:26:51 -05:00
|
|
|
#include "ardour/midi_track.h"
|
2006-07-23 08:03:19 -04:00
|
|
|
|
2016-07-14 14:44:52 -04:00
|
|
|
#include "pbd/i18n.h"
|
2006-07-23 08:03:19 -04:00
|
|
|
|
|
|
|
using namespace ARDOUR;
|
|
|
|
using namespace PBD;
|
|
|
|
using namespace Gtk;
|
2010-01-08 21:36:47 -05:00
|
|
|
using namespace Gtkmm2ext;
|
2006-07-23 08:03:19 -04:00
|
|
|
using namespace Editing;
|
2014-11-30 18:27:04 -05:00
|
|
|
using namespace std;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-10-04 22:32:05 -04:00
|
|
|
// Minimum height at which a control is displayed
|
2014-08-31 01:12:41 -04:00
|
|
|
static const uint32_t MIDI_CONTROLS_BOX_MIN_HEIGHT = 160;
|
2013-03-27 21:50:18 -04:00
|
|
|
static const uint32_t KEYBOARD_MIN_HEIGHT = 130;
|
2006-07-23 08:03:19 -04:00
|
|
|
|
2020-02-11 15:41:44 -05:00
|
|
|
#define DEFAULT_MIDNAM_MODEL (X_("Generic"))
|
|
|
|
|
2013-04-04 00:32:52 -04:00
|
|
|
MidiTimeAxisView::MidiTimeAxisView (PublicEditor& ed, Session* sess, ArdourCanvas::Canvas& canvas)
|
2016-06-05 16:07:22 -04:00
|
|
|
: SessionHandlePtr (sess)
|
|
|
|
, RouteTimeAxisView (ed, sess, canvas)
|
2009-10-14 12:10:01 -04:00
|
|
|
, _ignore_signals(false)
|
2008-01-13 12:45:17 -05:00
|
|
|
, _range_scroomer(0)
|
|
|
|
, _piano_roll_header(0)
|
2007-08-17 13:25:20 -04:00
|
|
|
, _note_mode(Sustained)
|
2008-12-23 20:24:49 -05:00
|
|
|
, _note_mode_item(0)
|
|
|
|
, _percussion_mode_item(0)
|
|
|
|
, _color_mode(MeterColors)
|
|
|
|
, _meter_color_mode_item(0)
|
|
|
|
, _channel_color_mode_item(0)
|
|
|
|
, _track_color_mode_item(0)
|
2013-03-27 21:50:18 -04:00
|
|
|
, _channel_selector (0)
|
2009-09-25 15:00:34 -04:00
|
|
|
, _step_edit_item (0)
|
2010-01-08 21:36:47 -05:00
|
|
|
, controller_menu (0)
|
2016-08-24 17:38:25 -04:00
|
|
|
, poly_pressure_menu (0)
|
2013-01-19 00:54:44 -05:00
|
|
|
, _step_editor (0)
|
2006-07-23 08:03:19 -04:00
|
|
|
{
|
2015-10-10 19:32:13 -04:00
|
|
|
_midnam_model_selector.disable_scrolling();
|
|
|
|
_midnam_custom_device_mode_selector.disable_scrolling();
|
2011-07-06 20:37:13 -04:00
|
|
|
}
|
|
|
|
|
2015-08-14 21:08:55 -04:00
|
|
|
void
|
|
|
|
MidiTimeAxisView::set_note_highlight (uint8_t note) {
|
|
|
|
_piano_roll_header->set_note_highlight (note);
|
|
|
|
}
|
|
|
|
|
2011-07-06 20:37:13 -04:00
|
|
|
void
|
|
|
|
MidiTimeAxisView::set_route (boost::shared_ptr<Route> rt)
|
|
|
|
{
|
2011-11-27 08:44:45 -05:00
|
|
|
_route = rt;
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2011-11-27 08:44:45 -05:00
|
|
|
_view = new MidiStreamView (*this);
|
2012-06-13 16:37:34 -04:00
|
|
|
|
2011-11-27 08:44:45 -05:00
|
|
|
if (is_track ()) {
|
|
|
|
_piano_roll_header = new PianoRollHeader(*midi_view());
|
|
|
|
_range_scroomer = new MidiScroomer(midi_view()->note_range_adjustment);
|
2013-01-19 00:54:44 -05:00
|
|
|
_range_scroomer->DoubleClicked.connect (
|
|
|
|
sigc::bind (sigc::mem_fun(*this, &MidiTimeAxisView::set_note_range),
|
|
|
|
MidiStreamView::ContentsRange, false));
|
2011-11-27 08:44:45 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/* This next call will result in our height being set up, so it must come after
|
|
|
|
the creation of the piano roll / range scroomer as their visibility is set up
|
|
|
|
when our height is.
|
|
|
|
*/
|
2011-07-06 20:37:13 -04:00
|
|
|
RouteTimeAxisView::set_route (rt);
|
|
|
|
|
2017-07-15 11:38:28 -04:00
|
|
|
_view->apply_color (ARDOUR_UI_UTILS::gdk_color_to_rgba (color()), StreamView::RegionColor);
|
2011-12-26 20:42:49 -05:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
subplugin_menu.set_name ("ArdourContextMenu");
|
|
|
|
|
2019-07-14 12:39:50 -04:00
|
|
|
_note_range_changed_connection.disconnect();
|
|
|
|
|
2011-08-14 14:40:57 -04:00
|
|
|
if (!gui_property ("note-range-min").empty ()) {
|
2013-01-19 00:54:44 -05:00
|
|
|
midi_view()->apply_note_range (atoi (gui_property ("note-range-min").c_str()),
|
|
|
|
atoi (gui_property ("note-range-max").c_str()),
|
|
|
|
true);
|
2011-08-14 14:40:57 -04:00
|
|
|
}
|
2013-01-19 14:06:21 -05:00
|
|
|
|
2013-01-19 00:54:44 -05:00
|
|
|
_view->ContentsHeightChanged.connect (
|
|
|
|
sigc::mem_fun (*this, &MidiTimeAxisView::contents_height_changed));
|
2006-07-23 08:03:19 -04:00
|
|
|
|
|
|
|
ignore_toggle = false;
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2007-07-06 23:19:04 -04:00
|
|
|
if (is_midi_track()) {
|
|
|
|
_note_mode = midi_track()->note_mode();
|
|
|
|
}
|
2006-07-23 08:03:19 -04:00
|
|
|
|
2014-01-15 05:30:54 -05:00
|
|
|
/* if set_state above didn't create a gain automation child, we need to make one */
|
|
|
|
if (automation_child (GainAutomation) == 0) {
|
|
|
|
create_automation_child (GainAutomation, false);
|
|
|
|
}
|
|
|
|
|
2014-07-01 14:36:58 -04:00
|
|
|
/* if set_state above didn't create a mute automation child, we need to make one */
|
|
|
|
if (automation_child (MuteAutomation) == 0) {
|
|
|
|
create_automation_child (MuteAutomation, false);
|
|
|
|
}
|
|
|
|
|
2014-01-15 05:30:54 -05:00
|
|
|
if (_route->panner_shell()) {
|
|
|
|
_route->panner_shell()->Changed.connect (*this, invalidator (*this), boost::bind (&MidiTimeAxisView::ensure_pan_views, this, false), gui_context());
|
|
|
|
}
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
/* map current state of the route */
|
2014-01-15 05:30:54 -05:00
|
|
|
ensure_pan_views (false);
|
2016-02-11 18:25:17 -05:00
|
|
|
update_control_names();
|
2009-11-30 18:16:28 -05:00
|
|
|
processors_changed (RouteProcessorChange ());
|
2006-07-23 08:03:19 -04:00
|
|
|
|
2006-08-14 04:44:14 -04:00
|
|
|
if (is_track()) {
|
2013-01-19 00:54:44 -05:00
|
|
|
_piano_roll_header->SetNoteSelection.connect (
|
|
|
|
sigc::mem_fun (*this, &MidiTimeAxisView::set_note_selection));
|
|
|
|
_piano_roll_header->AddNoteSelection.connect (
|
|
|
|
sigc::mem_fun (*this, &MidiTimeAxisView::add_note_selection));
|
|
|
|
_piano_roll_header->ExtendNoteSelection.connect (
|
|
|
|
sigc::mem_fun (*this, &MidiTimeAxisView::extend_note_selection));
|
|
|
|
_piano_roll_header->ToggleNoteSelection.connect (
|
|
|
|
sigc::mem_fun (*this, &MidiTimeAxisView::toggle_note_selection));
|
2010-01-07 14:15:33 -05:00
|
|
|
|
2012-06-13 16:58:12 -04:00
|
|
|
/* Put the scroomer and the keyboard in a VBox with a padding
|
|
|
|
label so that they can be reduced in height for stacked-view
|
|
|
|
tracks.
|
2012-06-13 16:37:34 -04:00
|
|
|
*/
|
2014-08-31 10:15:52 -04:00
|
|
|
|
2014-09-08 12:43:08 -04:00
|
|
|
HSeparator* separator = manage (new HSeparator());
|
|
|
|
separator->set_name("TrackSeparator");
|
|
|
|
separator->set_size_request(-1, 1);
|
|
|
|
separator->show();
|
|
|
|
|
2012-06-13 16:58:12 -04:00
|
|
|
VBox* v = manage (new VBox);
|
|
|
|
HBox* h = manage (new HBox);
|
2014-08-31 10:15:52 -04:00
|
|
|
h->pack_end (*_piano_roll_header);
|
|
|
|
h->pack_end (*_range_scroomer);
|
2014-09-08 12:43:08 -04:00
|
|
|
v->pack_start (*separator, false, false);
|
2014-09-08 12:42:41 -04:00
|
|
|
v->pack_start (*h, true, true);
|
2012-06-13 19:28:32 -04:00
|
|
|
v->show ();
|
|
|
|
h->show ();
|
2014-09-08 12:43:08 -04:00
|
|
|
top_hbox.remove(scroomer_placeholder);
|
2014-09-08 12:42:41 -04:00
|
|
|
time_axis_hbox.pack_end(*v, false, false, 0);
|
2014-09-08 12:43:08 -04:00
|
|
|
midi_scroomer_size_group->add_widget (*v);
|
2006-07-23 08:03:19 -04:00
|
|
|
|
2019-07-14 12:39:50 -04:00
|
|
|
/* callback from StreamView scroomer drags, as well as
|
|
|
|
* automatic changes of note-range (e.g. at rec-stop).
|
|
|
|
* This callback is used to save the note-range-min/max
|
|
|
|
* GUI Object property
|
|
|
|
*/
|
|
|
|
_note_range_changed_connection = midi_view()->NoteRangeChanged.connect (
|
|
|
|
sigc::mem_fun (*this, &MidiTimeAxisView::note_range_changed));
|
2008-02-10 13:16:25 -05:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
/* ask for notifications of any new RegionViews */
|
2013-01-19 00:54:44 -05:00
|
|
|
_view->RegionViewAdded.connect (
|
|
|
|
sigc::mem_fun(*this, &MidiTimeAxisView::region_view_added));
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-09-26 22:04:16 -04:00
|
|
|
if (!_editor.have_idled()) {
|
|
|
|
/* first idle will do what we need */
|
|
|
|
} else {
|
|
|
|
first_idle ();
|
|
|
|
}
|
2007-09-05 22:30:39 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2017-07-15 11:38:28 -04:00
|
|
|
ArdourWidgets::set_tooltip (_midnam_model_selector, _("External MIDI Device"));
|
|
|
|
ArdourWidgets::set_tooltip (_midnam_custom_device_mode_selector, _("External Device Mode"));
|
2012-06-11 18:59:35 -04:00
|
|
|
|
2016-10-29 13:28:18 -04:00
|
|
|
_midi_controls_box.pack_start (_midnam_model_selector, false, false, 2);
|
|
|
|
_midi_controls_box.pack_start (_midnam_custom_device_mode_selector, false, false, 2);
|
|
|
|
|
2012-10-11 04:13:40 -04:00
|
|
|
_midi_controls_box.set_homogeneous(false);
|
2014-09-09 08:39:36 -04:00
|
|
|
_midi_controls_box.set_border_width (2);
|
2013-01-19 11:05:06 -05:00
|
|
|
|
2020-04-02 21:42:56 -04:00
|
|
|
/* this directly calls use_midnam_info() if there are midnam's already */
|
|
|
|
MIDI::Name::MidiPatchManager::instance().maybe_use (*this, invalidator (*this), boost::bind (&MidiTimeAxisView::use_midnam_info, this), gui_context());
|
2013-01-19 05:02:00 -05:00
|
|
|
|
2008-12-09 03:35:02 -05:00
|
|
|
controls_vbox.pack_start(_midi_controls_box, false, false);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2013-01-19 01:17:02 -05:00
|
|
|
const string color_mode = gui_property ("color-mode");
|
|
|
|
if (!color_mode.empty()) {
|
|
|
|
_color_mode = ColorMode (string_2_enum(color_mode, _color_mode));
|
2013-03-27 21:50:18 -04:00
|
|
|
if (_channel_selector && _color_mode == ChannelColors) {
|
2013-04-04 00:32:52 -04:00
|
|
|
_channel_selector->set_channel_colors(NoteBase::midi_channel_colors);
|
2008-12-28 20:02:41 -05:00
|
|
|
}
|
|
|
|
}
|
2009-10-07 11:41:12 -04:00
|
|
|
|
2011-07-06 20:37:13 -04:00
|
|
|
set_color_mode (_color_mode, true, false);
|
|
|
|
|
2013-01-19 01:17:02 -05:00
|
|
|
const string note_mode = gui_property ("note-mode");
|
|
|
|
if (!note_mode.empty()) {
|
|
|
|
_note_mode = NoteMode (string_2_enum (note_mode, _note_mode));
|
2009-10-22 12:10:21 -04:00
|
|
|
if (_percussion_mode_item) {
|
2009-10-07 11:41:12 -04:00
|
|
|
_percussion_mode_item->set_active (_note_mode == Percussive);
|
|
|
|
}
|
|
|
|
}
|
2011-07-13 13:13:30 -04:00
|
|
|
|
2013-01-19 00:54:44 -05:00
|
|
|
/* Look for any GUI object state nodes that represent automation children
|
|
|
|
* that should exist, and create the children.
|
2011-07-13 13:13:30 -04:00
|
|
|
*/
|
2012-01-20 13:02:43 -05:00
|
|
|
|
2013-01-19 01:17:02 -05:00
|
|
|
const list<string> gui_ids = gui_object_state().all_ids ();
|
2012-01-20 13:02:43 -05:00
|
|
|
for (list<string>::const_iterator i = gui_ids.begin(); i != gui_ids.end(); ++i) {
|
2011-07-13 13:13:30 -04:00
|
|
|
PBD::ID route_id;
|
|
|
|
bool has_parameter;
|
|
|
|
Evoral::Parameter parameter (0, 0, 0);
|
|
|
|
|
2013-01-19 00:54:44 -05:00
|
|
|
bool const p = AutomationTimeAxisView::parse_state_id (
|
|
|
|
*i, route_id, has_parameter, parameter);
|
2011-07-13 13:13:30 -04:00
|
|
|
if (p && route_id == _route->id () && has_parameter) {
|
2013-01-19 00:54:44 -05:00
|
|
|
const std::string& visible = gui_object_state().get_string (*i, X_("visible"));
|
2016-08-30 08:34:40 -04:00
|
|
|
create_automation_child (parameter, string_to<bool> (visible));
|
2011-07-13 13:13:30 -04:00
|
|
|
}
|
|
|
|
}
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
|
|
|
|
2010-09-26 22:04:16 -04:00
|
|
|
void
|
|
|
|
MidiTimeAxisView::first_idle ()
|
|
|
|
{
|
|
|
|
if (is_track ()) {
|
|
|
|
_view->attach ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
MidiTimeAxisView::~MidiTimeAxisView ()
|
|
|
|
{
|
2013-03-27 21:50:18 -04:00
|
|
|
delete _channel_selector;
|
|
|
|
|
2008-02-21 20:45:29 -05:00
|
|
|
delete _piano_roll_header;
|
|
|
|
_piano_roll_header = 0;
|
2008-02-10 13:16:25 -05:00
|
|
|
|
2008-02-21 20:45:29 -05:00
|
|
|
delete _range_scroomer;
|
|
|
|
_range_scroomer = 0;
|
2010-01-07 14:15:33 -05:00
|
|
|
|
|
|
|
delete controller_menu;
|
2013-01-19 00:54:44 -05:00
|
|
|
delete _step_editor;
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
|
|
|
|
2010-07-27 11:42:14 -04:00
|
|
|
void
|
2010-08-15 12:39:51 -04:00
|
|
|
MidiTimeAxisView::check_step_edit ()
|
2010-07-27 11:42:14 -04:00
|
|
|
{
|
2011-02-12 07:29:20 -05:00
|
|
|
ensure_step_editor ();
|
2013-01-19 00:54:44 -05:00
|
|
|
_step_editor->check_step_edit ();
|
2010-07-27 11:42:14 -04:00
|
|
|
}
|
|
|
|
|
2020-04-03 08:39:03 -04:00
|
|
|
void
|
|
|
|
MidiTimeAxisView::processors_changed (RouteProcessorChange c)
|
|
|
|
{
|
|
|
|
RouteTimeAxisView::processors_changed (c);
|
|
|
|
maybe_trigger_model_change ();
|
|
|
|
}
|
|
|
|
|
2019-12-23 12:26:33 -05:00
|
|
|
void
|
|
|
|
MidiTimeAxisView::use_midnam_info ()
|
|
|
|
{
|
|
|
|
setup_midnam_patches ();
|
|
|
|
}
|
|
|
|
|
2020-04-03 08:39:03 -04:00
|
|
|
void
|
|
|
|
MidiTimeAxisView::maybe_trigger_model_change ()
|
|
|
|
{
|
|
|
|
if (_route->instrument_info().have_custom_plugin_info ()) {
|
|
|
|
/* ensure that "Plugin Provided" is at the top of the list */
|
|
|
|
if (_midnam_model_selector.items().empty () || _midnam_model_selector.items().begin()->get_label() != _("Plugin Provided")) {
|
|
|
|
/* setup_midnam_patches unconditionally calls model_changed() */
|
|
|
|
setup_midnam_patches ();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* no plugin provided MIDNAM for this plugin */
|
|
|
|
if (!_midnam_model_selector.items().empty () && _midnam_model_selector.items().begin()->get_label() == _("Plugin Provided")) {
|
|
|
|
/* setup_midnam_patches unconditionally calls model_changed() */
|
|
|
|
setup_midnam_patches ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-29 13:28:18 -04:00
|
|
|
void
|
|
|
|
MidiTimeAxisView::setup_midnam_patches ()
|
|
|
|
{
|
|
|
|
typedef MIDI::Name::MidiPatchManager PatchManager;
|
|
|
|
PatchManager& patch_manager = PatchManager::instance();
|
|
|
|
|
|
|
|
_midnam_model_selector.clear_items ();
|
2019-11-12 11:00:50 -05:00
|
|
|
|
2020-04-01 00:58:00 -04:00
|
|
|
if (_route->instrument_info().have_custom_plugin_info ()) {
|
|
|
|
Menu_Helpers::MenuElem elem = Gtk::Menu_Helpers::MenuElem(_("Plugin Provided"), sigc::bind(sigc::mem_fun(*this, &MidiTimeAxisView::model_changed), ""));
|
|
|
|
_midnam_model_selector.AddMenuElem(elem);
|
2019-11-12 11:00:50 -05:00
|
|
|
}
|
|
|
|
|
2020-02-06 16:41:20 -05:00
|
|
|
for (PatchManager::DeviceNamesByMaker::const_iterator m = patch_manager.devices_by_manufacturer().begin(); m != patch_manager.devices_by_manufacturer().end(); ++m) {
|
2016-10-29 13:28:18 -04:00
|
|
|
Menu* menu = Gtk::manage(new Menu);
|
|
|
|
Menu_Helpers::MenuList& items = menu->items();
|
|
|
|
|
2020-04-03 08:39:03 -04:00
|
|
|
/* Build manufacturer submenu */
|
2020-02-06 16:41:20 -05:00
|
|
|
for (MIDI::Name::MIDINameDocument::MasterDeviceNamesList::const_iterator n = m->second.begin(); n != m->second.end(); ++n) {
|
2019-11-12 00:29:05 -05:00
|
|
|
|
|
|
|
if (patch_manager.is_custom_model (n->first)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2016-10-29 13:28:18 -04:00
|
|
|
Menu_Helpers::MenuElem elem = Gtk::Menu_Helpers::MenuElem(
|
|
|
|
n->first.c_str(),
|
|
|
|
sigc::bind(sigc::mem_fun(*this, &MidiTimeAxisView::model_changed),
|
|
|
|
n->first.c_str()));
|
|
|
|
|
|
|
|
items.push_back(elem);
|
|
|
|
}
|
2019-11-12 00:29:05 -05:00
|
|
|
if (items.empty ()) {
|
|
|
|
delete menu;
|
|
|
|
continue;
|
|
|
|
}
|
2016-10-29 13:28:18 -04:00
|
|
|
|
2020-04-03 08:39:03 -04:00
|
|
|
/* Add manufacturer submenu to selector */
|
2016-10-29 13:28:18 -04:00
|
|
|
_midnam_model_selector.AddMenuElem(Menu_Helpers::MenuElem(m->first, *menu));
|
|
|
|
}
|
|
|
|
|
2020-04-02 21:42:56 -04:00
|
|
|
if (patch_manager.all_models().empty()) {
|
|
|
|
_midnam_model_selector.hide ();
|
|
|
|
_midnam_custom_device_mode_selector.hide ();
|
|
|
|
} else {
|
|
|
|
_midnam_model_selector.show ();
|
|
|
|
if (_midnam_custom_device_mode_selector.items().size() > 1) {
|
|
|
|
_midnam_custom_device_mode_selector.show ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* call _midnam_model_selector.set_text ()
|
|
|
|
* and show/hide _midnam_custom_device_mode_selector
|
|
|
|
*/
|
2020-04-01 00:58:00 -04:00
|
|
|
std::string model = gui_property (X_("midnam-model-name"));
|
|
|
|
if (model.empty() && _route->instrument_info().have_custom_plugin_info ()) {
|
|
|
|
/* use plugin's MIDNAM */
|
|
|
|
model_changed ("");
|
|
|
|
} else if (!_route->instrument_info().master_device_names()) {
|
|
|
|
/* switch to use default */
|
|
|
|
model_changed ("");
|
2020-04-02 21:42:56 -04:00
|
|
|
} else {
|
|
|
|
model_changed (model);
|
2016-10-29 13:28:18 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-01 13:00:29 -04:00
|
|
|
void
|
2020-02-11 15:41:44 -05:00
|
|
|
MidiTimeAxisView::model_changed (const std::string& m)
|
2008-12-11 03:06:27 -05:00
|
|
|
{
|
2019-11-12 11:00:50 -05:00
|
|
|
typedef MIDI::Name::MidiPatchManager PatchManager;
|
|
|
|
PatchManager& patch_manager = PatchManager::instance();
|
2020-04-01 00:58:00 -04:00
|
|
|
|
2020-02-11 15:41:44 -05:00
|
|
|
std::string model (m);
|
2020-04-01 00:58:00 -04:00
|
|
|
bool save_model = m != "";
|
|
|
|
|
|
|
|
if (model.empty() && !_route->instrument_info().have_custom_plugin_info ()) {
|
|
|
|
model = DEFAULT_MIDNAM_MODEL;
|
|
|
|
}
|
2020-02-11 15:41:44 -05:00
|
|
|
|
|
|
|
std::list<std::string> device_modes = patch_manager.custom_device_mode_names_by_model (model);
|
|
|
|
|
|
|
|
if (device_modes.empty()) {
|
2020-02-20 02:26:29 -05:00
|
|
|
save_model = false;
|
2020-04-01 00:58:00 -04:00
|
|
|
if (_route->instrument_info().have_custom_plugin_info ()) {
|
|
|
|
model = "";
|
|
|
|
} else {
|
|
|
|
model = DEFAULT_MIDNAM_MODEL;
|
|
|
|
}
|
2020-02-11 15:41:44 -05:00
|
|
|
device_modes = patch_manager.custom_device_mode_names_by_model (model);
|
|
|
|
}
|
2019-11-12 11:00:50 -05:00
|
|
|
|
2020-04-01 00:58:00 -04:00
|
|
|
if (model == "") {
|
2020-02-06 16:43:41 -05:00
|
|
|
_midnam_model_selector.set_text (_("Plugin Provided"));
|
2019-11-12 11:00:50 -05:00
|
|
|
} else {
|
2020-04-01 00:58:00 -04:00
|
|
|
_midnam_model_selector.set_text (model);
|
2019-11-12 11:00:50 -05:00
|
|
|
}
|
2020-02-07 14:19:57 -05:00
|
|
|
|
2020-04-01 00:58:00 -04:00
|
|
|
if (save_model) {
|
|
|
|
set_gui_property (X_("midnam-model-name"), model);
|
|
|
|
} else {
|
|
|
|
remove_gui_property (X_("midnam-model-name"));
|
2020-04-02 21:42:56 -04:00
|
|
|
model = "";
|
2020-04-01 00:58:00 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2020-04-02 21:42:56 -04:00
|
|
|
/* set new mode */
|
|
|
|
const std::string current_mode = gui_property (X_("midname-custom-device-mode"));
|
|
|
|
std::string mode;
|
2020-04-01 00:58:00 -04:00
|
|
|
if (find (device_modes.begin(), device_modes.end(), current_mode) == device_modes.end()) {
|
|
|
|
if (device_modes.size() > 0) {
|
2020-04-02 21:42:56 -04:00
|
|
|
mode = device_modes.front();
|
2020-02-07 14:19:27 -05:00
|
|
|
custom_device_mode_changed (device_modes.front());
|
2020-02-11 15:41:44 -05:00
|
|
|
} else {
|
2020-04-02 21:42:56 -04:00
|
|
|
mode = "";
|
2020-02-07 14:19:27 -05:00
|
|
|
}
|
2020-04-01 00:58:00 -04:00
|
|
|
} else {
|
2020-04-02 21:42:56 -04:00
|
|
|
mode = current_mode;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* set backend state */
|
|
|
|
_route->instrument_info().set_external_instrument (model, mode);
|
|
|
|
|
2020-04-03 08:39:03 -04:00
|
|
|
/* query effective model/mode -- may be plugin provided */
|
2020-04-02 21:42:56 -04:00
|
|
|
if (_effective_model == _route->instrument_info().model () && _effective_mode == _route->instrument_info().mode ()) {
|
|
|
|
/* no change */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
_effective_model = _route->instrument_info().model ();
|
2020-04-03 08:39:03 -04:00
|
|
|
_effective_mode = _route->instrument_info().mode ();
|
2020-04-02 21:42:56 -04:00
|
|
|
|
|
|
|
/* update GUI */
|
|
|
|
|
|
|
|
_midnam_custom_device_mode_selector.clear_items();
|
|
|
|
for (std::list<std::string>::const_iterator i = device_modes.begin(); i != device_modes.end(); ++i) {
|
|
|
|
_midnam_custom_device_mode_selector.AddMenuElem (Gtk::Menu_Helpers::MenuElem(*i, sigc::bind(sigc::mem_fun(*this, &MidiTimeAxisView::custom_device_mode_changed), *i)));
|
2014-12-12 23:38:41 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (device_modes.size() > 1) {
|
|
|
|
_midnam_custom_device_mode_selector.show();
|
|
|
|
} else {
|
|
|
|
_midnam_custom_device_mode_selector.hide();
|
|
|
|
}
|
|
|
|
|
2020-04-02 21:42:56 -04:00
|
|
|
/* set _midnam_custom_device_mode_selector */
|
|
|
|
custom_device_mode_changed (mode);
|
2020-03-31 18:51:01 -04:00
|
|
|
|
2020-04-02 21:42:56 -04:00
|
|
|
/* Rebuild controller menu */
|
2013-01-19 01:17:02 -05:00
|
|
|
_controller_menu_map.clear ();
|
|
|
|
delete controller_menu;
|
|
|
|
controller_menu = 0;
|
2020-04-02 21:42:56 -04:00
|
|
|
build_automation_action_menu (false);
|
2017-09-08 13:37:48 -04:00
|
|
|
|
2017-09-09 12:25:36 -04:00
|
|
|
if (patch_change_dialog ()) {
|
|
|
|
patch_change_dialog ()->refresh ();
|
2017-09-08 13:37:48 -04:00
|
|
|
}
|
2008-12-11 03:06:27 -05:00
|
|
|
}
|
|
|
|
|
2012-06-02 10:53:34 -04:00
|
|
|
void
|
2014-12-12 23:38:41 -05:00
|
|
|
MidiTimeAxisView::custom_device_mode_changed(const std::string& mode)
|
2008-12-11 03:06:27 -05:00
|
|
|
{
|
2014-12-12 23:38:41 -05:00
|
|
|
const std::string model = gui_property (X_("midnam-model-name"));
|
2012-10-12 05:25:55 -04:00
|
|
|
set_gui_property (X_("midnam-custom-device-mode"), mode);
|
2020-02-11 15:41:44 -05:00
|
|
|
_midnam_custom_device_mode_selector.set_text (mode);
|
2020-03-31 18:51:01 -04:00
|
|
|
/* inform the backend, route owned instrument info */
|
2014-12-12 23:38:41 -05:00
|
|
|
_route->instrument_info().set_external_instrument (model, mode);
|
2008-12-11 03:06:27 -05:00
|
|
|
}
|
|
|
|
|
2007-07-05 03:02:24 -04:00
|
|
|
MidiStreamView*
|
|
|
|
MidiTimeAxisView::midi_view()
|
|
|
|
{
|
|
|
|
return dynamic_cast<MidiStreamView*>(_view);
|
|
|
|
}
|
|
|
|
|
2008-09-27 14:07:37 -04:00
|
|
|
void
|
2015-03-19 16:47:34 -04:00
|
|
|
MidiTimeAxisView::set_height (uint32_t h, TrackHeightMode m)
|
2008-09-27 14:07:37 -04:00
|
|
|
{
|
2011-11-27 08:44:40 -05:00
|
|
|
if (h >= MIDI_CONTROLS_BOX_MIN_HEIGHT) {
|
2013-01-19 00:36:43 -05:00
|
|
|
_midi_controls_box.show ();
|
2008-10-04 22:32:05 -04:00
|
|
|
} else {
|
2008-12-09 03:35:02 -05:00
|
|
|
_midi_controls_box.hide();
|
2008-10-04 22:32:05 -04:00
|
|
|
}
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2011-11-27 08:44:40 -05:00
|
|
|
if (h >= KEYBOARD_MIN_HEIGHT) {
|
2011-07-07 09:15:53 -04:00
|
|
|
if (is_track() && _range_scroomer) {
|
2008-09-27 14:07:37 -04:00
|
|
|
_range_scroomer->show();
|
2011-07-07 09:15:53 -04:00
|
|
|
}
|
|
|
|
if (is_track() && _piano_roll_header) {
|
2008-09-27 14:07:37 -04:00
|
|
|
_piano_roll_header->show();
|
2011-07-07 09:15:53 -04:00
|
|
|
}
|
2008-09-27 14:07:37 -04:00
|
|
|
} else {
|
2011-07-07 09:15:53 -04:00
|
|
|
if (is_track() && _range_scroomer) {
|
2008-09-27 14:07:37 -04:00
|
|
|
_range_scroomer->hide();
|
2011-07-07 09:15:53 -04:00
|
|
|
}
|
|
|
|
if (is_track() && _piano_roll_header) {
|
2008-09-27 14:07:37 -04:00
|
|
|
_piano_roll_header->hide();
|
2011-07-07 09:15:53 -04:00
|
|
|
}
|
2008-09-27 14:07:37 -04:00
|
|
|
}
|
2011-11-27 08:44:40 -05:00
|
|
|
|
|
|
|
/* We need to do this after changing visibility of our stuff, as it will
|
|
|
|
eventually trigger a call to Editor::reset_controls_layout_width(),
|
|
|
|
which needs to know if we have just shown or hidden a scroomer /
|
|
|
|
piano roll.
|
|
|
|
*/
|
2015-03-19 16:47:34 -04:00
|
|
|
RouteTimeAxisView::set_height (h, m);
|
2008-09-27 14:07:37 -04:00
|
|
|
}
|
|
|
|
|
2007-07-14 21:56:11 -04:00
|
|
|
void
|
|
|
|
MidiTimeAxisView::append_extra_display_menu_items ()
|
|
|
|
{
|
|
|
|
using namespace Menu_Helpers;
|
|
|
|
|
|
|
|
MenuList& items = display_menu->items();
|
|
|
|
|
|
|
|
// Note range
|
|
|
|
Menu *range_menu = manage(new Menu);
|
|
|
|
MenuList& range_items = range_menu->items();
|
|
|
|
range_menu->set_name ("ArdourContextMenu");
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2013-01-19 00:54:44 -05:00
|
|
|
range_items.push_back (
|
|
|
|
MenuElem (_("Show Full Range"),
|
2015-10-04 14:51:05 -04:00
|
|
|
sigc::bind (sigc::mem_fun(*this, &MidiTimeAxisView::set_note_range),
|
2013-01-19 00:54:44 -05:00
|
|
|
MidiStreamView::FullRange, true)));
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2013-01-19 00:54:44 -05:00
|
|
|
range_items.push_back (
|
|
|
|
MenuElem (_("Fit Contents"),
|
|
|
|
sigc::bind (sigc::mem_fun(*this, &MidiTimeAxisView::set_note_range),
|
|
|
|
MidiStreamView::ContentsRange, true)));
|
2007-07-14 21:56:11 -04:00
|
|
|
|
2011-05-16 18:22:57 -04:00
|
|
|
items.push_back (MenuElem (_("Note Range"), *range_menu));
|
|
|
|
items.push_back (MenuElem (_("Note Mode"), *build_note_mode_menu()));
|
2017-09-08 12:09:26 -04:00
|
|
|
items.push_back (MenuElem (_("Channel Selector..."),
|
2013-03-27 21:50:18 -04:00
|
|
|
sigc::mem_fun(*this, &MidiTimeAxisView::toggle_channel_selector)));
|
2009-09-25 15:00:34 -04:00
|
|
|
|
2017-09-08 12:09:26 -04:00
|
|
|
items.push_back (MenuElem (_("Patch Selector..."),
|
2017-09-09 12:25:36 -04:00
|
|
|
sigc::mem_fun(*this, &RouteUI::select_midi_patch)));
|
2016-12-06 12:48:36 -05:00
|
|
|
|
2019-03-07 10:40:16 -05:00
|
|
|
items.push_back (MenuElem (_("Color Mode"), *build_color_mode_menu ()));
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2011-02-20 19:16:36 -05:00
|
|
|
items.push_back (SeparatorElem ());
|
2009-09-25 15:00:34 -04:00
|
|
|
}
|
|
|
|
|
2013-03-27 21:50:18 -04:00
|
|
|
void
|
|
|
|
MidiTimeAxisView::toggle_channel_selector ()
|
|
|
|
{
|
|
|
|
if (!_channel_selector) {
|
|
|
|
_channel_selector = new MidiChannelSelectorWindow (midi_track());
|
|
|
|
|
|
|
|
if (_color_mode == ChannelColors) {
|
2013-04-04 00:32:52 -04:00
|
|
|
_channel_selector->set_channel_colors(NoteBase::midi_channel_colors);
|
2013-03-27 21:50:18 -04:00
|
|
|
} else {
|
|
|
|
_channel_selector->set_default_channel_color ();
|
|
|
|
}
|
|
|
|
|
|
|
|
_channel_selector->show_all ();
|
|
|
|
} else {
|
|
|
|
_channel_selector->cycle_visibility ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
void
|
2011-03-07 08:04:36 -05:00
|
|
|
MidiTimeAxisView::build_automation_action_menu (bool for_selection)
|
2006-07-23 08:03:19 -04:00
|
|
|
{
|
2007-06-27 11:51:50 -04:00
|
|
|
using namespace Menu_Helpers;
|
|
|
|
|
2010-05-16 14:04:47 -04:00
|
|
|
/* If we have a controller menu, we need to detach it before
|
|
|
|
RouteTimeAxis::build_automation_action_menu destroys the
|
|
|
|
menu it is attached to. Otherwise GTK destroys
|
|
|
|
controller_menu's gobj, meaning that it can't be reattached
|
|
|
|
below. See bug #3134.
|
|
|
|
*/
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-05-16 14:04:47 -04:00
|
|
|
if (controller_menu) {
|
|
|
|
detach_menu (*controller_menu);
|
|
|
|
}
|
|
|
|
|
2010-06-08 17:48:38 -04:00
|
|
|
_channel_command_menu_map.clear ();
|
2011-03-07 08:04:36 -05:00
|
|
|
RouteTimeAxisView::build_automation_action_menu (for_selection);
|
2007-06-27 11:51:50 -04:00
|
|
|
|
|
|
|
MenuList& automation_items = automation_action_menu->items();
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2013-03-27 21:50:18 -04:00
|
|
|
uint16_t selected_channels = midi_track()->get_playback_channel_mask();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-01-08 21:36:47 -05:00
|
|
|
if (selected_channels != 0) {
|
|
|
|
|
|
|
|
automation_items.push_back (SeparatorElem());
|
|
|
|
|
2013-01-19 00:54:44 -05:00
|
|
|
/* these 2 MIDI "command" types are semantically more like automation
|
|
|
|
than note data, but they are not MIDI controllers. We give them
|
|
|
|
special status in this menu, since they will not show up in the
|
|
|
|
controller list and anyone who actually knows something about MIDI
|
|
|
|
(!) would not expect to find them there.
|
2010-01-08 21:36:47 -05:00
|
|
|
*/
|
|
|
|
|
2013-01-19 00:54:44 -05:00
|
|
|
add_channel_command_menu_item (
|
|
|
|
automation_items, _("Bender"), MidiPitchBenderAutomation, 0);
|
|
|
|
automation_items.back().set_sensitive (
|
|
|
|
!for_selection || _editor.get_selection().tracks.size() == 1);
|
|
|
|
add_channel_command_menu_item (
|
|
|
|
automation_items, _("Pressure"), MidiChannelPressureAutomation, 0);
|
|
|
|
automation_items.back().set_sensitive (
|
|
|
|
!for_selection || _editor.get_selection().tracks.size() == 1);
|
|
|
|
|
|
|
|
/* now all MIDI controllers. Always offer the possibility that we will
|
|
|
|
rebuild the controllers menu since it might need to be updated after
|
|
|
|
a channel mode change or other change. Also detach it first in case
|
|
|
|
it has been used anywhere else.
|
2010-01-08 21:36:47 -05:00
|
|
|
*/
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-01-08 21:36:47 -05:00
|
|
|
build_controller_menu ();
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-01-08 21:36:47 -05:00
|
|
|
automation_items.push_back (MenuElem (_("Controllers"), *controller_menu));
|
2016-08-24 17:38:25 -04:00
|
|
|
|
|
|
|
if (!poly_pressure_menu) {
|
|
|
|
poly_pressure_menu = new Gtk::Menu;
|
|
|
|
}
|
|
|
|
|
|
|
|
automation_items.push_back (MenuElem (_("Polyphonic Pressure"), *poly_pressure_menu));
|
|
|
|
|
2013-01-19 00:54:44 -05:00
|
|
|
automation_items.back().set_sensitive (
|
|
|
|
!for_selection || _editor.get_selection().tracks.size() == 1);
|
2010-01-08 21:36:47 -05:00
|
|
|
} else {
|
2013-01-19 00:54:44 -05:00
|
|
|
automation_items.push_back (
|
|
|
|
MenuElem (string_compose ("<i>%1</i>", _("No MIDI Channels selected"))));
|
2011-02-17 11:43:30 -05:00
|
|
|
dynamic_cast<Label*> (automation_items.back().get_child())->set_use_markup (true);
|
2010-01-08 21:36:47 -05:00
|
|
|
}
|
|
|
|
}
|
2010-01-06 16:56:23 -05:00
|
|
|
|
2010-01-08 21:36:47 -05:00
|
|
|
void
|
|
|
|
MidiTimeAxisView::change_all_channel_tracks_visibility (bool yn, Evoral::Parameter param)
|
|
|
|
{
|
2013-03-27 21:50:18 -04:00
|
|
|
const uint16_t selected_channels = midi_track()->get_playback_channel_mask();
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-01-08 21:36:47 -05:00
|
|
|
for (uint8_t chn = 0; chn < 16; chn++) {
|
|
|
|
if (selected_channels & (0x0001 << chn)) {
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-01-08 21:36:47 -05:00
|
|
|
Evoral::Parameter fully_qualified_param (param.type(), chn, param.id());
|
2010-05-25 10:50:45 -04:00
|
|
|
Gtk::CheckMenuItem* menu = automation_child_menu_item (fully_qualified_param);
|
2010-01-07 14:15:33 -05:00
|
|
|
|
2010-05-25 10:50:45 -04:00
|
|
|
if (menu) {
|
|
|
|
menu->set_active (yn);
|
2010-01-08 21:36:47 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-01-19 00:54:44 -05:00
|
|
|
MidiTimeAxisView::add_channel_command_menu_item (Menu_Helpers::MenuList& items,
|
|
|
|
const string& label,
|
|
|
|
AutomationType auto_type,
|
|
|
|
uint8_t cmd)
|
2010-01-08 21:36:47 -05:00
|
|
|
{
|
|
|
|
using namespace Menu_Helpers;
|
|
|
|
|
2013-01-19 00:54:44 -05:00
|
|
|
/* count the number of selected channels because we will build a different menu
|
|
|
|
structure if there is more than 1 selected.
|
2010-01-08 21:36:47 -05:00
|
|
|
*/
|
2010-01-07 14:15:33 -05:00
|
|
|
|
2013-03-27 21:50:18 -04:00
|
|
|
const uint16_t selected_channels = midi_track()->get_playback_channel_mask();
|
2010-01-08 21:36:47 -05:00
|
|
|
int chn_cnt = 0;
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-01-08 21:36:47 -05:00
|
|
|
for (uint8_t chn = 0; chn < 16; chn++) {
|
|
|
|
if (selected_channels & (0x0001 << chn)) {
|
|
|
|
if (++chn_cnt > 1) {
|
|
|
|
break;
|
2010-01-07 14:15:33 -05:00
|
|
|
}
|
|
|
|
}
|
2010-01-08 21:36:47 -05:00
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-01-08 21:36:47 -05:00
|
|
|
if (chn_cnt > 1) {
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-01-08 21:36:47 -05:00
|
|
|
/* multiple channels - create a submenu, with 1 item per channel */
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-01-08 21:36:47 -05:00
|
|
|
Menu* chn_menu = manage (new Menu);
|
|
|
|
MenuList& chn_items (chn_menu->items());
|
|
|
|
Evoral::Parameter param_without_channel (auto_type, 0, cmd);
|
|
|
|
|
|
|
|
/* add a couple of items to hide/show all of them */
|
|
|
|
|
2013-01-19 00:54:44 -05:00
|
|
|
chn_items.push_back (
|
|
|
|
MenuElem (_("Hide all channels"),
|
|
|
|
sigc::bind (sigc::mem_fun (*this, &MidiTimeAxisView::change_all_channel_tracks_visibility),
|
|
|
|
false, param_without_channel)));
|
|
|
|
chn_items.push_back (
|
|
|
|
MenuElem (_("Show all channels"),
|
|
|
|
sigc::bind (sigc::mem_fun (*this, &MidiTimeAxisView::change_all_channel_tracks_visibility),
|
|
|
|
true, param_without_channel)));
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-01-08 21:36:47 -05:00
|
|
|
for (uint8_t chn = 0; chn < 16; chn++) {
|
|
|
|
if (selected_channels & (0x0001 << chn)) {
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-01-08 21:36:47 -05:00
|
|
|
/* for each selected channel, add a menu item for this controller */
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-01-08 21:36:47 -05:00
|
|
|
Evoral::Parameter fully_qualified_param (auto_type, chn, cmd);
|
2013-01-19 00:54:44 -05:00
|
|
|
chn_items.push_back (
|
|
|
|
CheckMenuElem (string_compose (_("Channel %1"), chn+1),
|
|
|
|
sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::toggle_automation_track),
|
|
|
|
fully_qualified_param)));
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-05-25 10:50:45 -04:00
|
|
|
boost::shared_ptr<AutomationTimeAxisView> track = automation_child (fully_qualified_param);
|
2010-01-08 21:36:47 -05:00
|
|
|
bool visible = false;
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-05-25 10:50:45 -04:00
|
|
|
if (track) {
|
|
|
|
if (track->marked_for_display()) {
|
2010-01-08 21:36:47 -05:00
|
|
|
visible = true;
|
|
|
|
}
|
|
|
|
}
|
2010-06-08 17:48:38 -04:00
|
|
|
|
2013-07-11 15:32:31 -04:00
|
|
|
Gtk::CheckMenuItem* cmi = static_cast<Gtk::CheckMenuItem*>(&chn_items.back());
|
2010-06-08 17:48:38 -04:00
|
|
|
_channel_command_menu_map[fully_qualified_param] = cmi;
|
2010-01-08 21:36:47 -05:00
|
|
|
cmi->set_active (visible);
|
|
|
|
}
|
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-01-08 21:36:47 -05:00
|
|
|
/* now create an item in the parent menu that has the per-channel list as a submenu */
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-01-08 21:36:47 -05:00
|
|
|
items.push_back (MenuElem (label, *chn_menu));
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-01-08 21:36:47 -05:00
|
|
|
} else {
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-01-08 21:36:47 -05:00
|
|
|
/* just one channel - create a single menu item for this command+channel combination*/
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-01-08 21:36:47 -05:00
|
|
|
for (uint8_t chn = 0; chn < 16; chn++) {
|
|
|
|
if (selected_channels & (0x0001 << chn)) {
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-01-08 21:36:47 -05:00
|
|
|
Evoral::Parameter fully_qualified_param (auto_type, chn, cmd);
|
2013-01-19 00:54:44 -05:00
|
|
|
items.push_back (
|
|
|
|
CheckMenuElem (label,
|
|
|
|
sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::toggle_automation_track),
|
|
|
|
fully_qualified_param)));
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-05-25 10:50:45 -04:00
|
|
|
boost::shared_ptr<AutomationTimeAxisView> track = automation_child (fully_qualified_param);
|
2010-01-08 21:36:47 -05:00
|
|
|
bool visible = false;
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-05-25 10:50:45 -04:00
|
|
|
if (track) {
|
|
|
|
if (track->marked_for_display()) {
|
2010-01-08 21:36:47 -05:00
|
|
|
visible = true;
|
|
|
|
}
|
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2013-07-11 15:32:31 -04:00
|
|
|
Gtk::CheckMenuItem* cmi = static_cast<Gtk::CheckMenuItem*>(&items.back());
|
2010-06-08 17:48:38 -04:00
|
|
|
_channel_command_menu_map[fully_qualified_param] = cmi;
|
2010-01-08 21:36:47 -05:00
|
|
|
cmi->set_active (visible);
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-01-08 21:36:47 -05:00
|
|
|
/* one channel only */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2010-01-07 14:15:33 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-19 05:02:00 -05:00
|
|
|
/** Add a single menu item for a controller on one channel. */
|
|
|
|
void
|
|
|
|
MidiTimeAxisView::add_single_channel_controller_item(Menu_Helpers::MenuList& ctl_items,
|
|
|
|
int ctl,
|
|
|
|
const std::string& name)
|
|
|
|
{
|
|
|
|
using namespace Menu_Helpers;
|
|
|
|
|
2013-03-27 21:50:18 -04:00
|
|
|
const uint16_t selected_channels = midi_track()->get_playback_channel_mask();
|
2013-01-19 05:02:00 -05:00
|
|
|
for (uint8_t chn = 0; chn < 16; chn++) {
|
|
|
|
if (selected_channels & (0x0001 << chn)) {
|
|
|
|
|
|
|
|
Evoral::Parameter fully_qualified_param (MidiCCAutomation, chn, ctl);
|
|
|
|
ctl_items.push_back (
|
|
|
|
CheckMenuElem (
|
2014-07-14 00:03:04 -04:00
|
|
|
string_compose ("<b>%1</b>: %2 [%3]", ctl, name, int (chn + 1)),
|
2013-01-19 05:02:00 -05:00
|
|
|
sigc::bind (
|
|
|
|
sigc::mem_fun (*this, &RouteTimeAxisView::toggle_automation_track),
|
|
|
|
fully_qualified_param)));
|
|
|
|
dynamic_cast<Label*> (ctl_items.back().get_child())->set_use_markup (true);
|
|
|
|
|
|
|
|
boost::shared_ptr<AutomationTimeAxisView> track = automation_child (
|
|
|
|
fully_qualified_param);
|
|
|
|
|
|
|
|
bool visible = false;
|
|
|
|
if (track) {
|
|
|
|
if (track->marked_for_display()) {
|
|
|
|
visible = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-19 04:41:34 -04:00
|
|
|
Gtk::CheckMenuItem* cmi = static_cast<Gtk::CheckMenuItem*>(&ctl_items.back());
|
2013-01-19 05:02:00 -05:00
|
|
|
_controller_menu_map[fully_qualified_param] = cmi;
|
|
|
|
cmi->set_active (visible);
|
|
|
|
|
|
|
|
/* one channel only */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Add a submenu with 1 item per channel for a controller on many channels. */
|
|
|
|
void
|
|
|
|
MidiTimeAxisView::add_multi_channel_controller_item(Menu_Helpers::MenuList& ctl_items,
|
|
|
|
int ctl,
|
|
|
|
const std::string& name)
|
|
|
|
{
|
|
|
|
using namespace Menu_Helpers;
|
|
|
|
|
2013-03-27 21:50:18 -04:00
|
|
|
const uint16_t selected_channels = midi_track()->get_playback_channel_mask();
|
2013-01-19 05:02:00 -05:00
|
|
|
|
|
|
|
Menu* chn_menu = manage (new Menu);
|
|
|
|
MenuList& chn_items (chn_menu->items());
|
|
|
|
|
|
|
|
/* add a couple of items to hide/show this controller on all channels */
|
|
|
|
|
|
|
|
Evoral::Parameter param_without_channel (MidiCCAutomation, 0, ctl);
|
|
|
|
chn_items.push_back (
|
|
|
|
MenuElem (_("Hide all channels"),
|
|
|
|
sigc::bind (sigc::mem_fun (*this, &MidiTimeAxisView::change_all_channel_tracks_visibility),
|
|
|
|
false, param_without_channel)));
|
|
|
|
chn_items.push_back (
|
|
|
|
MenuElem (_("Show all channels"),
|
|
|
|
sigc::bind (sigc::mem_fun (*this, &MidiTimeAxisView::change_all_channel_tracks_visibility),
|
|
|
|
true, param_without_channel)));
|
|
|
|
|
|
|
|
for (uint8_t chn = 0; chn < 16; chn++) {
|
|
|
|
if (selected_channels & (0x0001 << chn)) {
|
|
|
|
|
|
|
|
/* for each selected channel, add a menu item for this controller */
|
|
|
|
|
|
|
|
Evoral::Parameter fully_qualified_param (MidiCCAutomation, chn, ctl);
|
|
|
|
chn_items.push_back (
|
|
|
|
CheckMenuElem (string_compose (_("Channel %1"), chn+1),
|
|
|
|
sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::toggle_automation_track),
|
|
|
|
fully_qualified_param)));
|
|
|
|
|
|
|
|
boost::shared_ptr<AutomationTimeAxisView> track = automation_child (
|
|
|
|
fully_qualified_param);
|
|
|
|
bool visible = false;
|
|
|
|
|
|
|
|
if (track) {
|
|
|
|
if (track->marked_for_display()) {
|
|
|
|
visible = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-19 04:41:34 -04:00
|
|
|
Gtk::CheckMenuItem* cmi = static_cast<Gtk::CheckMenuItem*>(&chn_items.back());
|
2013-01-19 05:02:00 -05:00
|
|
|
_controller_menu_map[fully_qualified_param] = cmi;
|
|
|
|
cmi->set_active (visible);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* add the per-channel menu to the list of controllers, with the name of the controller */
|
|
|
|
ctl_items.push_back (MenuElem (string_compose ("<b>%1</b>: %2", ctl, name),
|
|
|
|
*chn_menu));
|
|
|
|
dynamic_cast<Label*> (ctl_items.back().get_child())->set_use_markup (true);
|
|
|
|
}
|
|
|
|
|
2010-01-07 14:15:33 -05:00
|
|
|
void
|
|
|
|
MidiTimeAxisView::build_controller_menu ()
|
|
|
|
{
|
|
|
|
using namespace Menu_Helpers;
|
|
|
|
|
2010-01-08 21:36:47 -05:00
|
|
|
if (controller_menu) {
|
2013-01-19 00:54:44 -05:00
|
|
|
/* it exists and has not been invalidated by a channel mode change */
|
2010-01-08 21:36:47 -05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
controller_menu = new Menu; // explicitly managed by us
|
2010-01-07 14:15:33 -05:00
|
|
|
MenuList& items (controller_menu->items());
|
|
|
|
|
2013-01-19 00:54:44 -05:00
|
|
|
/* create several "top level" menu items for sets of controllers (16 at a
|
|
|
|
time), and populate each one with a submenu for each controller+channel
|
|
|
|
combination covering the currently selected channels for this track
|
2010-01-07 14:15:33 -05:00
|
|
|
*/
|
|
|
|
|
2013-03-27 21:50:18 -04:00
|
|
|
const uint16_t selected_channels = midi_track()->get_playback_channel_mask();
|
2010-01-07 14:15:33 -05:00
|
|
|
|
2013-01-19 00:54:44 -05:00
|
|
|
/* count the number of selected channels because we will build a different menu
|
|
|
|
structure if there is more than 1 selected.
|
|
|
|
*/
|
2010-01-07 14:15:33 -05:00
|
|
|
|
|
|
|
int chn_cnt = 0;
|
|
|
|
for (uint8_t chn = 0; chn < 16; chn++) {
|
|
|
|
if (selected_channels & (0x0001 << chn)) {
|
|
|
|
if (++chn_cnt > 1) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2020-04-01 17:26:13 -04:00
|
|
|
size_t total_ctrls = _route->instrument_info().master_controller_count ();
|
|
|
|
if (total_ctrls > 0) {
|
|
|
|
using namespace MIDI::Name;
|
2013-01-16 03:24:31 -05:00
|
|
|
|
2013-01-19 05:02:00 -05:00
|
|
|
/* Controllers names available in midnam file, generate fancy menu */
|
|
|
|
unsigned n_items = 0;
|
|
|
|
unsigned n_groups = 0;
|
2013-01-20 03:56:00 -05:00
|
|
|
|
2019-06-04 17:51:50 -04:00
|
|
|
/* keep track of CC numbers that are added */
|
|
|
|
uint16_t ctl_start = 1;
|
|
|
|
uint16_t ctl_end = 1;
|
|
|
|
|
2020-04-01 17:26:13 -04:00
|
|
|
MasterDeviceNames::ControlNameLists const& ctllist (_route->instrument_info().master_device_names ()->controls ());
|
2019-06-04 17:51:50 -04:00
|
|
|
|
|
|
|
bool to_top_level = total_ctrls < 32;
|
|
|
|
|
2013-01-20 03:56:00 -05:00
|
|
|
/* TODO: This is not correct, should look up the currently applicable ControlNameList
|
|
|
|
and only build a menu for that one. */
|
2019-06-04 17:51:50 -04:00
|
|
|
for (MasterDeviceNames::ControlNameLists::const_iterator l = ctllist.begin(); l != ctllist.end(); ++l) {
|
2013-01-20 03:56:00 -05:00
|
|
|
boost::shared_ptr<ControlNameList> name_list = l->second;
|
2013-01-19 05:02:00 -05:00
|
|
|
Menu* ctl_menu = NULL;
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2013-01-20 03:56:00 -05:00
|
|
|
for (ControlNameList::Controls::const_iterator c = name_list->controls().begin();
|
2013-01-26 17:08:06 -05:00
|
|
|
c != name_list->controls().end();) {
|
2013-01-20 03:56:00 -05:00
|
|
|
const uint16_t ctl = c->second->number();
|
2019-06-04 17:51:50 -04:00
|
|
|
|
|
|
|
/* Skip bank select controllers since they're handled specially */
|
2013-01-26 17:30:34 -05:00
|
|
|
if (ctl != MIDI_CTL_MSB_BANK && ctl != MIDI_CTL_LSB_BANK) {
|
2019-06-04 17:51:50 -04:00
|
|
|
|
|
|
|
if (to_top_level) {
|
|
|
|
ctl_menu = controller_menu;
|
|
|
|
} else if (!ctl_menu) {
|
2013-01-26 17:30:34 -05:00
|
|
|
/* Create a new submenu */
|
|
|
|
ctl_menu = manage (new Menu);
|
2019-06-04 17:51:50 -04:00
|
|
|
ctl_start = ctl;
|
2013-01-26 17:30:34 -05:00
|
|
|
}
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2013-01-26 17:30:34 -05:00
|
|
|
MenuList& ctl_items (ctl_menu->items());
|
|
|
|
if (chn_cnt > 1) {
|
|
|
|
add_multi_channel_controller_item(ctl_items, ctl, c->second->name());
|
|
|
|
} else {
|
|
|
|
add_single_channel_controller_item(ctl_items, ctl, c->second->name());
|
|
|
|
}
|
2019-06-04 17:51:50 -04:00
|
|
|
ctl_end = ctl;
|
2013-01-19 05:02:00 -05:00
|
|
|
}
|
2013-01-26 17:08:06 -05:00
|
|
|
|
|
|
|
++c;
|
2019-06-04 17:51:50 -04:00
|
|
|
|
|
|
|
if (!ctl_menu || to_top_level) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (++n_items == 32 || ctl < ctl_start || c == name_list->controls().end()) {
|
|
|
|
/* Submenu has 32 items or we're done, or a new name-list started:
|
|
|
|
* add it to controller menu and reset */
|
|
|
|
items.push_back (MenuElem (string_compose (_("Controllers %1-%2"), ctl_start, ctl_end), *ctl_menu));
|
2013-01-19 05:02:00 -05:00
|
|
|
ctl_menu = NULL;
|
|
|
|
n_items = 0;
|
|
|
|
++n_groups;
|
2010-01-07 14:15:33 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-01-19 05:02:00 -05:00
|
|
|
} else {
|
|
|
|
/* No controllers names, generate generic numeric menu */
|
2019-06-04 17:51:50 -04:00
|
|
|
for (int i = 0; i < 127; i += 32) {
|
2013-01-19 05:02:00 -05:00
|
|
|
Menu* ctl_menu = manage (new Menu);
|
|
|
|
MenuList& ctl_items (ctl_menu->items());
|
|
|
|
|
2019-06-04 17:51:50 -04:00
|
|
|
for (int ctl = i; ctl < i + 32; ++ctl) {
|
2013-01-19 05:02:00 -05:00
|
|
|
if (ctl == MIDI_CTL_MSB_BANK || ctl == MIDI_CTL_LSB_BANK) {
|
|
|
|
/* Skip bank select controllers since they're handled specially */
|
|
|
|
continue;
|
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2013-01-19 05:02:00 -05:00
|
|
|
if (chn_cnt > 1) {
|
|
|
|
add_multi_channel_controller_item(
|
|
|
|
ctl_items, ctl, string_compose(_("Controller %1"), ctl));
|
|
|
|
} else {
|
|
|
|
add_single_channel_controller_item(
|
|
|
|
ctl_items, ctl, string_compose(_("Controller %1"), ctl));
|
|
|
|
}
|
|
|
|
}
|
2010-01-07 14:15:33 -05:00
|
|
|
|
2013-01-19 05:02:00 -05:00
|
|
|
/* Add submenu for this block of controllers to controller menu */
|
2019-06-04 17:51:50 -04:00
|
|
|
switch (i) {
|
|
|
|
case 0:
|
|
|
|
case 32:
|
|
|
|
/* skip 0x00 and 0x20 (bank-select) */
|
|
|
|
items.push_back (MenuElem (string_compose (_("Controllers %1-%2"), i + 1, i + 31), *ctl_menu));
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
items.push_back (MenuElem (string_compose (_("Controllers %1-%2"), i, i + 31), *ctl_menu));
|
|
|
|
break;
|
|
|
|
}
|
2013-01-19 05:02:00 -05:00
|
|
|
}
|
2010-01-07 14:15:33 -05:00
|
|
|
}
|
2010-01-06 16:56:23 -05:00
|
|
|
}
|
|
|
|
|
2007-07-06 23:19:04 -04:00
|
|
|
Gtk::Menu*
|
2008-12-28 20:02:41 -05:00
|
|
|
MidiTimeAxisView::build_note_mode_menu()
|
2007-07-06 23:19:04 -04:00
|
|
|
{
|
|
|
|
using namespace Menu_Helpers;
|
|
|
|
|
|
|
|
Menu* mode_menu = manage (new Menu);
|
|
|
|
MenuList& items = mode_menu->items();
|
|
|
|
mode_menu->set_name ("ArdourContextMenu");
|
|
|
|
|
|
|
|
RadioMenuItem::Group mode_group;
|
2013-01-19 00:54:44 -05:00
|
|
|
items.push_back (
|
|
|
|
RadioMenuElem (mode_group,_("Sustained"),
|
|
|
|
sigc::bind (sigc::mem_fun (*this, &MidiTimeAxisView::set_note_mode),
|
|
|
|
Sustained, true)));
|
2007-07-06 23:19:04 -04:00
|
|
|
_note_mode_item = dynamic_cast<RadioMenuItem*>(&items.back());
|
2007-07-28 03:09:21 -04:00
|
|
|
_note_mode_item->set_active(_note_mode == Sustained);
|
2007-07-06 23:19:04 -04:00
|
|
|
|
2013-01-19 00:54:44 -05:00
|
|
|
items.push_back (
|
|
|
|
RadioMenuElem (mode_group, _("Percussive"),
|
|
|
|
sigc::bind (sigc::mem_fun (*this, &MidiTimeAxisView::set_note_mode),
|
|
|
|
Percussive, true)));
|
2007-07-06 23:19:04 -04:00
|
|
|
_percussion_mode_item = dynamic_cast<RadioMenuItem*>(&items.back());
|
2007-07-28 03:09:21 -04:00
|
|
|
_percussion_mode_item->set_active(_note_mode == Percussive);
|
2007-07-06 23:19:04 -04:00
|
|
|
|
|
|
|
return mode_menu;
|
|
|
|
}
|
2008-12-23 20:24:49 -05:00
|
|
|
|
|
|
|
Gtk::Menu*
|
|
|
|
MidiTimeAxisView::build_color_mode_menu()
|
|
|
|
{
|
|
|
|
using namespace Menu_Helpers;
|
|
|
|
|
|
|
|
Menu* mode_menu = manage (new Menu);
|
|
|
|
MenuList& items = mode_menu->items();
|
|
|
|
mode_menu->set_name ("ArdourContextMenu");
|
|
|
|
|
|
|
|
RadioMenuItem::Group mode_group;
|
2013-01-19 00:54:44 -05:00
|
|
|
items.push_back (
|
|
|
|
RadioMenuElem (mode_group, _("Meter Colors"),
|
|
|
|
sigc::bind (sigc::mem_fun (*this, &MidiTimeAxisView::set_color_mode),
|
|
|
|
MeterColors, false, true, true)));
|
2008-12-23 20:24:49 -05:00
|
|
|
_meter_color_mode_item = dynamic_cast<RadioMenuItem*>(&items.back());
|
|
|
|
_meter_color_mode_item->set_active(_color_mode == MeterColors);
|
|
|
|
|
2013-01-19 00:54:44 -05:00
|
|
|
items.push_back (
|
|
|
|
RadioMenuElem (mode_group, _("Channel Colors"),
|
|
|
|
sigc::bind (sigc::mem_fun (*this, &MidiTimeAxisView::set_color_mode),
|
|
|
|
ChannelColors, false, true, true)));
|
2008-12-23 20:24:49 -05:00
|
|
|
_channel_color_mode_item = dynamic_cast<RadioMenuItem*>(&items.back());
|
|
|
|
_channel_color_mode_item->set_active(_color_mode == ChannelColors);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2013-01-19 00:54:44 -05:00
|
|
|
items.push_back (
|
|
|
|
RadioMenuElem (mode_group, _("Track Color"),
|
|
|
|
sigc::bind (sigc::mem_fun (*this, &MidiTimeAxisView::set_color_mode),
|
|
|
|
TrackColor, false, true, true)));
|
2008-12-23 20:24:49 -05:00
|
|
|
_channel_color_mode_item = dynamic_cast<RadioMenuItem*>(&items.back());
|
|
|
|
_channel_color_mode_item->set_active(_color_mode == TrackColor);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-12-23 20:24:49 -05:00
|
|
|
return mode_menu;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-07-06 23:19:04 -04:00
|
|
|
void
|
2012-06-13 13:24:15 -04:00
|
|
|
MidiTimeAxisView::set_note_mode(NoteMode mode, bool apply_to_selection)
|
2007-07-06 23:19:04 -04:00
|
|
|
{
|
2012-06-13 13:24:15 -04:00
|
|
|
if (apply_to_selection) {
|
2013-01-19 00:54:44 -05:00
|
|
|
_editor.get_selection().tracks.foreach_midi_time_axis (
|
|
|
|
boost::bind (&MidiTimeAxisView::set_note_mode, _1, mode, false));
|
2011-05-16 14:18:13 -04:00
|
|
|
} else {
|
2012-06-13 13:24:15 -04:00
|
|
|
if (_note_mode != mode || midi_track()->note_mode() != mode) {
|
|
|
|
_note_mode = mode;
|
|
|
|
midi_track()->set_note_mode(mode);
|
|
|
|
set_gui_property ("note-mode", enum_2_string(_note_mode));
|
|
|
|
_view->redisplay_track();
|
|
|
|
}
|
2011-05-19 17:29:47 -04:00
|
|
|
}
|
2008-12-23 20:24:49 -05:00
|
|
|
}
|
2007-07-14 21:56:11 -04:00
|
|
|
|
|
|
|
void
|
2012-06-13 13:24:15 -04:00
|
|
|
MidiTimeAxisView::set_color_mode (ColorMode mode, bool force, bool redisplay, bool apply_to_selection)
|
2007-07-14 21:56:11 -04:00
|
|
|
{
|
2012-06-13 13:24:15 -04:00
|
|
|
if (apply_to_selection) {
|
|
|
|
_editor.get_selection().tracks.foreach_midi_time_axis (
|
2013-01-19 00:54:44 -05:00
|
|
|
boost::bind (&MidiTimeAxisView::set_color_mode, _1, mode, force, redisplay, false));
|
2012-06-13 13:24:15 -04:00
|
|
|
} else {
|
|
|
|
if (_color_mode == mode && !force) {
|
|
|
|
return;
|
|
|
|
}
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2013-03-27 21:50:18 -04:00
|
|
|
if (_channel_selector) {
|
|
|
|
if (mode == ChannelColors) {
|
2013-04-04 18:45:27 -04:00
|
|
|
_channel_selector->set_channel_colors(NoteBase::midi_channel_colors);
|
2013-03-27 21:50:18 -04:00
|
|
|
} else {
|
|
|
|
_channel_selector->set_default_channel_color();
|
|
|
|
}
|
2012-06-13 13:24:15 -04:00
|
|
|
}
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2012-06-13 13:24:15 -04:00
|
|
|
_color_mode = mode;
|
|
|
|
set_gui_property ("color-mode", enum_2_string(_color_mode));
|
|
|
|
if (redisplay) {
|
|
|
|
_view->redisplay_track();
|
|
|
|
}
|
2012-06-13 11:38:27 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-06-13 13:24:15 -04:00
|
|
|
MidiTimeAxisView::set_note_range (MidiStreamView::VisibleNoteRange range, bool apply_to_selection)
|
2012-06-13 11:38:27 -04:00
|
|
|
{
|
2012-06-13 13:24:15 -04:00
|
|
|
if (apply_to_selection) {
|
|
|
|
_editor.get_selection().tracks.foreach_midi_time_axis (
|
2013-01-19 00:54:44 -05:00
|
|
|
boost::bind (&MidiTimeAxisView::set_note_range, _1, range, false));
|
2012-06-13 13:24:15 -04:00
|
|
|
} else {
|
|
|
|
if (!_ignore_signals) {
|
|
|
|
midi_view()->set_note_range(range);
|
2012-06-13 11:38:27 -04:00
|
|
|
}
|
|
|
|
}
|
2007-07-14 21:56:11 -04:00
|
|
|
}
|
|
|
|
|
2008-09-19 13:24:52 -04:00
|
|
|
void
|
2011-03-07 08:04:46 -05:00
|
|
|
MidiTimeAxisView::show_all_automation (bool apply_to_selection)
|
2008-09-19 13:24:52 -04:00
|
|
|
{
|
2014-07-14 00:43:36 -04:00
|
|
|
using namespace MIDI::Name;
|
|
|
|
|
2011-03-07 08:04:46 -05:00
|
|
|
if (apply_to_selection) {
|
2013-01-19 00:54:44 -05:00
|
|
|
_editor.get_selection().tracks.foreach_midi_time_axis (
|
|
|
|
boost::bind (&MidiTimeAxisView::show_all_automation, _1, false));
|
2011-03-07 08:04:46 -05:00
|
|
|
} else {
|
|
|
|
if (midi_track()) {
|
2014-07-14 00:43:36 -04:00
|
|
|
// Show existing automation
|
2011-03-07 08:04:46 -05:00
|
|
|
const set<Evoral::Parameter> params = midi_track()->midi_playlist()->contained_automation();
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2011-03-07 08:04:46 -05:00
|
|
|
for (set<Evoral::Parameter>::const_iterator i = params.begin(); i != params.end(); ++i) {
|
|
|
|
create_automation_child(*i, true);
|
|
|
|
}
|
2014-07-14 00:43:36 -04:00
|
|
|
|
2020-04-01 17:26:13 -04:00
|
|
|
/* Show automation for all controllers named in midnam file */
|
|
|
|
if (_route->instrument_info().master_controller_count () > 0) {
|
2020-02-11 15:59:05 -05:00
|
|
|
|
2020-04-01 00:58:00 -04:00
|
|
|
const uint16_t selected_channels = midi_track()->get_playback_channel_mask();
|
2020-02-11 15:59:05 -05:00
|
|
|
|
2014-07-14 00:43:36 -04:00
|
|
|
for (uint32_t chn = 0; chn < 16; ++chn) {
|
2020-02-11 15:59:05 -05:00
|
|
|
|
2014-07-14 00:43:36 -04:00
|
|
|
if ((selected_channels & (0x0001 << chn)) == 0) {
|
|
|
|
// Channel not in use
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2020-04-01 00:58:00 -04:00
|
|
|
boost::shared_ptr<ControlNameList> control_names = _route->instrument_info().control_name_list (chn);
|
2014-07-14 00:43:36 -04:00
|
|
|
if (!control_names) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2020-04-01 00:58:00 -04:00
|
|
|
for (ControlNameList::Controls::const_iterator c = control_names->controls().begin(); c != control_names->controls().end(); ++c) {
|
2014-07-14 00:43:36 -04:00
|
|
|
const uint16_t ctl = c->second->number();
|
|
|
|
if (ctl != MIDI_CTL_MSB_BANK && ctl != MIDI_CTL_LSB_BANK) {
|
|
|
|
/* Skip bank select controllers since they're handled specially */
|
|
|
|
const Evoral::Parameter param(MidiCCAutomation, chn, ctl);
|
|
|
|
create_automation_child(param, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-09-21 12:17:02 -04:00
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2011-03-07 08:04:46 -05:00
|
|
|
RouteTimeAxisView::show_all_automation ();
|
2008-09-19 13:24:52 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-02-18 22:24:44 -05:00
|
|
|
void
|
2011-03-07 08:04:46 -05:00
|
|
|
MidiTimeAxisView::show_existing_automation (bool apply_to_selection)
|
2008-02-18 22:24:44 -05:00
|
|
|
{
|
2011-03-07 08:04:46 -05:00
|
|
|
if (apply_to_selection) {
|
2013-01-19 00:54:44 -05:00
|
|
|
_editor.get_selection().tracks.foreach_midi_time_axis (
|
|
|
|
boost::bind (&MidiTimeAxisView::show_existing_automation, _1, false));
|
2011-03-07 08:04:46 -05:00
|
|
|
} else {
|
|
|
|
if (midi_track()) {
|
|
|
|
const set<Evoral::Parameter> params = midi_track()->midi_playlist()->contained_automation();
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2011-03-07 08:04:46 -05:00
|
|
|
for (set<Evoral::Parameter>::const_iterator i = params.begin(); i != params.end(); ++i) {
|
2011-07-06 20:37:13 -04:00
|
|
|
create_automation_child (*i, true);
|
2011-03-07 08:04:46 -05:00
|
|
|
}
|
2008-09-21 12:17:02 -04:00
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2011-03-07 08:04:46 -05:00
|
|
|
RouteTimeAxisView::show_existing_automation ();
|
2008-02-18 22:24:44 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-06-08 17:48:38 -04:00
|
|
|
/** Create an automation track for the given parameter (pitch bend, channel pressure).
|
2010-01-06 16:56:23 -05:00
|
|
|
*/
|
2007-06-27 11:51:50 -04:00
|
|
|
void
|
2008-09-29 18:47:40 -04:00
|
|
|
MidiTimeAxisView::create_automation_child (const Evoral::Parameter& param, bool show)
|
2007-06-27 11:51:50 -04:00
|
|
|
{
|
2009-02-15 23:53:01 -05:00
|
|
|
if (param.type() == NullAutomation) {
|
|
|
|
return;
|
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-01-08 21:36:47 -05:00
|
|
|
AutomationTracks::iterator existing = _automation_tracks.find (param);
|
2011-06-11 11:35:34 -04:00
|
|
|
|
2010-01-08 21:36:47 -05:00
|
|
|
if (existing != _automation_tracks.end()) {
|
2011-06-11 11:35:34 -04:00
|
|
|
|
|
|
|
/* automation track created because we had existing data for
|
|
|
|
* the processor, but visibility may need to be controlled
|
|
|
|
* since it will have been set visible by default.
|
|
|
|
*/
|
|
|
|
|
2014-11-17 00:13:53 -05:00
|
|
|
existing->second->set_marked_for_display (show);
|
|
|
|
|
|
|
|
if (!no_redraw) {
|
2011-07-06 20:37:13 -04:00
|
|
|
request_redraw ();
|
2011-06-11 11:35:34 -04:00
|
|
|
}
|
|
|
|
|
2009-01-21 03:32:23 -05:00
|
|
|
return;
|
2010-01-08 21:36:47 -05:00
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2011-06-11 11:35:34 -04:00
|
|
|
boost::shared_ptr<AutomationTimeAxisView> track;
|
2014-08-31 17:52:09 -04:00
|
|
|
boost::shared_ptr<AutomationControl> control;
|
|
|
|
|
2011-06-11 11:35:34 -04:00
|
|
|
switch (param.type()) {
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2011-06-11 11:35:34 -04:00
|
|
|
case GainAutomation:
|
2019-12-14 09:04:32 -05:00
|
|
|
case BusSendLevel:
|
2011-06-11 11:35:34 -04:00
|
|
|
create_gain_automation_child (param, show);
|
|
|
|
break;
|
|
|
|
|
2014-07-01 14:36:58 -04:00
|
|
|
case MuteAutomation:
|
|
|
|
create_mute_automation_child (param, show);
|
|
|
|
break;
|
|
|
|
|
2011-06-11 11:35:34 -04:00
|
|
|
case PluginAutomation:
|
|
|
|
/* handled elsewhere */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MidiCCAutomation:
|
|
|
|
case MidiPgmChangeAutomation:
|
|
|
|
case MidiPitchBenderAutomation:
|
|
|
|
case MidiChannelPressureAutomation:
|
2019-10-11 19:03:50 -04:00
|
|
|
case MidiNotePressureAutomation:
|
2011-06-11 11:35:34 -04:00
|
|
|
case MidiSystemExclusiveAutomation:
|
|
|
|
/* These controllers are region "automation" - they are owned
|
|
|
|
* by regions (and their MidiModels), not by the track. As a
|
2014-08-31 17:52:09 -04:00
|
|
|
* result there is no AutomationList/Line for the track, but we create
|
|
|
|
* a controller for the user to write immediate events, so the editor
|
|
|
|
* can act as a control surface for the present MIDI controllers.
|
|
|
|
*
|
|
|
|
* TODO: Record manipulation of the controller to regions?
|
2011-06-11 11:35:34 -04:00
|
|
|
*/
|
|
|
|
|
2014-08-31 17:52:09 -04:00
|
|
|
control = _route->automation_control(param, true);
|
2011-06-11 11:35:34 -04:00
|
|
|
track.reset (new AutomationTimeAxisView (
|
2013-01-19 00:54:44 -05:00
|
|
|
_session,
|
|
|
|
_route,
|
2014-08-31 17:52:09 -04:00
|
|
|
control ? _route : boost::shared_ptr<Automatable> (),
|
|
|
|
control,
|
2013-01-19 00:54:44 -05:00
|
|
|
param,
|
|
|
|
_editor,
|
|
|
|
*this,
|
|
|
|
true,
|
|
|
|
parent_canvas,
|
|
|
|
_route->describe_parameter(param)));
|
2011-02-26 18:48:43 -05:00
|
|
|
|
|
|
|
if (_view) {
|
2013-01-19 00:54:44 -05:00
|
|
|
_view->foreach_regionview (
|
|
|
|
sigc::mem_fun (*track.get(), &TimeAxisView::add_ghost));
|
2011-02-26 18:48:43 -05:00
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-09-26 22:04:16 -04:00
|
|
|
add_automation_child (param, track, show);
|
2017-07-21 09:49:28 -04:00
|
|
|
if (selected ()) {
|
|
|
|
reshow_selection (_editor.get_selection().time);
|
|
|
|
}
|
|
|
|
|
2011-06-11 11:35:34 -04:00
|
|
|
break;
|
|
|
|
|
2014-01-15 05:30:54 -05:00
|
|
|
case PanWidthAutomation:
|
|
|
|
case PanElevationAutomation:
|
|
|
|
case PanAzimuthAutomation:
|
|
|
|
ensure_pan_views (show);
|
2011-06-11 11:35:34 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2013-01-19 00:54:44 -05:00
|
|
|
error << "MidiTimeAxisView: unknown automation child "
|
|
|
|
<< EventTypeMap::instance().to_symbol(param) << endmsg;
|
2010-09-26 22:04:16 -04:00
|
|
|
}
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MidiTimeAxisView::route_active_changed ()
|
|
|
|
{
|
2020-01-21 19:35:18 -05:00
|
|
|
RouteTimeAxisView::route_active_changed ();
|
2016-02-11 18:25:17 -05:00
|
|
|
update_control_names();
|
2020-01-20 17:03:22 -05:00
|
|
|
|
|
|
|
if (!_route->active()) {
|
|
|
|
controls_table.hide();
|
|
|
|
inactive_table.show_all();
|
|
|
|
RouteTimeAxisView::hide_all_automation();
|
|
|
|
} else {
|
|
|
|
inactive_table.hide();
|
|
|
|
controls_table.show();
|
|
|
|
}
|
2016-02-11 18:25:17 -05:00
|
|
|
}
|
2006-07-23 08:03:19 -04:00
|
|
|
|
2016-02-11 18:25:17 -05:00
|
|
|
void
|
|
|
|
MidiTimeAxisView::update_control_names ()
|
|
|
|
{
|
2006-08-14 04:44:14 -04:00
|
|
|
if (is_track()) {
|
2006-07-27 21:08:57 -04:00
|
|
|
if (_route->active()) {
|
2006-07-23 08:03:19 -04:00
|
|
|
controls_base_selected_name = "MidiTrackControlsBaseSelected";
|
|
|
|
controls_base_unselected_name = "MidiTrackControlsBaseUnselected";
|
|
|
|
} else {
|
|
|
|
controls_base_selected_name = "MidiTrackControlsBaseInactiveSelected";
|
|
|
|
controls_base_unselected_name = "MidiTrackControlsBaseInactiveUnselected";
|
|
|
|
}
|
2016-02-11 18:25:17 -05:00
|
|
|
} else { // MIDI bus (which doesn't exist yet..)
|
2006-07-27 21:08:57 -04:00
|
|
|
if (_route->active()) {
|
2006-07-23 08:03:19 -04:00
|
|
|
controls_base_selected_name = "BusControlsBaseSelected";
|
|
|
|
controls_base_unselected_name = "BusControlsBaseUnselected";
|
|
|
|
} else {
|
|
|
|
controls_base_selected_name = "BusControlsBaseInactiveSelected";
|
|
|
|
controls_base_unselected_name = "BusControlsBaseInactiveUnselected";
|
|
|
|
}
|
|
|
|
}
|
2016-02-11 18:25:17 -05:00
|
|
|
|
2016-06-05 19:49:51 -04:00
|
|
|
if (selected()) {
|
2016-02-11 18:25:17 -05:00
|
|
|
controls_ebox.set_name (controls_base_selected_name);
|
2017-09-18 14:45:56 -04:00
|
|
|
time_axis_frame.set_name (controls_base_selected_name);
|
2016-02-11 18:25:17 -05:00
|
|
|
} else {
|
|
|
|
controls_ebox.set_name (controls_base_unselected_name);
|
2017-09-18 14:45:56 -04:00
|
|
|
time_axis_frame.set_name (controls_base_unselected_name);
|
2016-02-11 18:25:17 -05:00
|
|
|
}
|
2006-07-23 08:03:19 -04:00
|
|
|
}
|
2008-04-19 06:30:38 -04:00
|
|
|
|
2012-01-19 21:54:23 -05:00
|
|
|
void
|
|
|
|
MidiTimeAxisView::set_note_selection (uint8_t note)
|
|
|
|
{
|
2013-03-27 21:50:18 -04:00
|
|
|
uint16_t chn_mask = midi_track()->get_playback_channel_mask();
|
2012-01-19 21:54:23 -05:00
|
|
|
|
2015-03-25 08:31:23 -04:00
|
|
|
_editor.begin_reversible_selection_op (X_("Set Note Selection"));
|
2015-01-10 12:07:31 -05:00
|
|
|
|
2019-08-11 22:49:31 -04:00
|
|
|
/* set_note_selection_region_view() will not work with multiple regions,
|
|
|
|
* as each individual `foreach` call will clear prior selection.
|
|
|
|
* Use clear_midi_notes() and add_note_selection_region_view() instead. */
|
|
|
|
|
|
|
|
_editor.get_selection().clear_midi_notes();
|
|
|
|
|
2012-01-19 21:54:23 -05:00
|
|
|
if (_view->num_selected_regionviews() == 0) {
|
2013-01-19 00:54:44 -05:00
|
|
|
_view->foreach_regionview (
|
2019-08-11 22:49:31 -04:00
|
|
|
sigc::bind (sigc::mem_fun (*this, &MidiTimeAxisView::add_note_selection_region_view),
|
2013-01-19 00:54:44 -05:00
|
|
|
note, chn_mask));
|
2012-01-19 21:54:23 -05:00
|
|
|
} else {
|
2013-01-19 00:54:44 -05:00
|
|
|
_view->foreach_selected_regionview (
|
2019-08-11 22:49:31 -04:00
|
|
|
sigc::bind (sigc::mem_fun (*this, &MidiTimeAxisView::add_note_selection_region_view),
|
2013-01-19 00:54:44 -05:00
|
|
|
note, chn_mask));
|
2012-01-19 21:54:23 -05:00
|
|
|
}
|
2015-01-10 12:07:31 -05:00
|
|
|
|
|
|
|
_editor.commit_reversible_selection_op();
|
2012-01-19 21:54:23 -05:00
|
|
|
}
|
2010-01-07 14:15:33 -05:00
|
|
|
|
|
|
|
void
|
|
|
|
MidiTimeAxisView::add_note_selection (uint8_t note)
|
|
|
|
{
|
2013-03-27 21:50:18 -04:00
|
|
|
const uint16_t chn_mask = midi_track()->get_playback_channel_mask();
|
2010-01-07 14:15:33 -05:00
|
|
|
|
2015-03-25 08:31:23 -04:00
|
|
|
_editor.begin_reversible_selection_op (X_("Add Note Selection"));
|
2015-01-10 12:07:31 -05:00
|
|
|
|
2010-01-07 14:15:33 -05:00
|
|
|
if (_view->num_selected_regionviews() == 0) {
|
2013-01-19 00:54:44 -05:00
|
|
|
_view->foreach_regionview (
|
|
|
|
sigc::bind (sigc::mem_fun (*this, &MidiTimeAxisView::add_note_selection_region_view),
|
|
|
|
note, chn_mask));
|
2010-01-07 14:15:33 -05:00
|
|
|
} else {
|
2013-01-19 00:54:44 -05:00
|
|
|
_view->foreach_selected_regionview (
|
|
|
|
sigc::bind (sigc::mem_fun (*this, &MidiTimeAxisView::add_note_selection_region_view),
|
|
|
|
note, chn_mask));
|
2010-01-07 14:15:33 -05:00
|
|
|
}
|
2015-01-10 12:07:31 -05:00
|
|
|
|
|
|
|
_editor.commit_reversible_selection_op();
|
2010-01-07 14:15:33 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MidiTimeAxisView::extend_note_selection (uint8_t note)
|
|
|
|
{
|
2013-03-27 21:50:18 -04:00
|
|
|
const uint16_t chn_mask = midi_track()->get_playback_channel_mask();
|
2010-01-07 14:15:33 -05:00
|
|
|
|
2015-03-25 08:31:23 -04:00
|
|
|
_editor.begin_reversible_selection_op (X_("Extend Note Selection"));
|
2015-01-10 12:07:31 -05:00
|
|
|
|
2010-01-07 14:15:33 -05:00
|
|
|
if (_view->num_selected_regionviews() == 0) {
|
2013-01-19 00:54:44 -05:00
|
|
|
_view->foreach_regionview (
|
|
|
|
sigc::bind (sigc::mem_fun (*this, &MidiTimeAxisView::extend_note_selection_region_view),
|
|
|
|
note, chn_mask));
|
2010-01-07 14:15:33 -05:00
|
|
|
} else {
|
2013-01-19 00:54:44 -05:00
|
|
|
_view->foreach_selected_regionview (
|
|
|
|
sigc::bind (sigc::mem_fun (*this, &MidiTimeAxisView::extend_note_selection_region_view),
|
|
|
|
note, chn_mask));
|
2010-01-07 14:15:33 -05:00
|
|
|
}
|
2015-01-10 12:07:31 -05:00
|
|
|
|
|
|
|
_editor.commit_reversible_selection_op();
|
2010-01-07 14:15:33 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MidiTimeAxisView::toggle_note_selection (uint8_t note)
|
|
|
|
{
|
2013-03-27 21:50:18 -04:00
|
|
|
const uint16_t chn_mask = midi_track()->get_playback_channel_mask();
|
2010-01-07 14:15:33 -05:00
|
|
|
|
2015-03-25 08:31:23 -04:00
|
|
|
_editor.begin_reversible_selection_op (X_("Toggle Note Selection"));
|
2015-01-10 12:07:31 -05:00
|
|
|
|
2010-01-07 14:15:33 -05:00
|
|
|
if (_view->num_selected_regionviews() == 0) {
|
2013-01-19 00:54:44 -05:00
|
|
|
_view->foreach_regionview (
|
|
|
|
sigc::bind (sigc::mem_fun (*this, &MidiTimeAxisView::toggle_note_selection_region_view),
|
|
|
|
note, chn_mask));
|
2010-01-07 14:15:33 -05:00
|
|
|
} else {
|
2013-01-19 00:54:44 -05:00
|
|
|
_view->foreach_selected_regionview (
|
|
|
|
sigc::bind (sigc::mem_fun (*this, &MidiTimeAxisView::toggle_note_selection_region_view),
|
|
|
|
note, chn_mask));
|
2010-01-07 14:15:33 -05:00
|
|
|
}
|
2015-01-10 12:07:31 -05:00
|
|
|
|
|
|
|
_editor.commit_reversible_selection_op();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-09-24 12:03:54 -04:00
|
|
|
MidiTimeAxisView::get_per_region_note_selection (list<pair<PBD::ID, set<boost::shared_ptr<Evoral::Note<Temporal::Beats> > > > >& selection)
|
2015-01-10 12:07:31 -05:00
|
|
|
{
|
|
|
|
_view->foreach_regionview (
|
|
|
|
sigc::bind (sigc::mem_fun (*this, &MidiTimeAxisView::get_per_region_note_selection_region_view), sigc::ref(selection)));
|
2010-01-07 14:15:33 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-01-19 21:54:23 -05:00
|
|
|
MidiTimeAxisView::set_note_selection_region_view (RegionView* rv, uint8_t note, uint16_t chn_mask)
|
2010-01-07 14:15:33 -05:00
|
|
|
{
|
|
|
|
dynamic_cast<MidiRegionView*>(rv)->select_matching_notes (note, chn_mask, false, false);
|
|
|
|
}
|
|
|
|
|
2012-01-19 21:54:23 -05:00
|
|
|
void
|
|
|
|
MidiTimeAxisView::add_note_selection_region_view (RegionView* rv, uint8_t note, uint16_t chn_mask)
|
|
|
|
{
|
|
|
|
dynamic_cast<MidiRegionView*>(rv)->select_matching_notes (note, chn_mask, true, false);
|
|
|
|
}
|
|
|
|
|
2010-01-07 14:15:33 -05:00
|
|
|
void
|
|
|
|
MidiTimeAxisView::extend_note_selection_region_view (RegionView* rv, uint8_t note, uint16_t chn_mask)
|
|
|
|
{
|
|
|
|
dynamic_cast<MidiRegionView*>(rv)->select_matching_notes (note, chn_mask, true, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MidiTimeAxisView::toggle_note_selection_region_view (RegionView* rv, uint8_t note, uint16_t chn_mask)
|
|
|
|
{
|
|
|
|
dynamic_cast<MidiRegionView*>(rv)->toggle_matching_notes (note, chn_mask);
|
|
|
|
}
|
2010-01-08 21:36:47 -05:00
|
|
|
|
2015-01-10 12:07:31 -05:00
|
|
|
void
|
2017-09-24 12:03:54 -04:00
|
|
|
MidiTimeAxisView::get_per_region_note_selection_region_view (RegionView* rv, list<pair<PBD::ID, std::set<boost::shared_ptr<Evoral::Note<Temporal::Beats> > > > > &selection)
|
2015-01-10 12:07:31 -05:00
|
|
|
{
|
2017-09-24 12:03:54 -04:00
|
|
|
Evoral::Sequence<Temporal::Beats>::Notes selected;
|
2015-01-10 12:07:31 -05:00
|
|
|
dynamic_cast<MidiRegionView*>(rv)->selection_as_notelist (selected, false);
|
|
|
|
|
2017-09-24 12:03:54 -04:00
|
|
|
std::set<boost::shared_ptr<Evoral::Note<Temporal::Beats> > > notes;
|
2015-01-10 12:07:31 -05:00
|
|
|
|
2017-09-24 12:03:54 -04:00
|
|
|
Evoral::Sequence<Temporal::Beats>::Notes::iterator sel_it;
|
2015-01-10 12:07:31 -05:00
|
|
|
for (sel_it = selected.begin(); sel_it != selected.end(); ++sel_it) {
|
|
|
|
notes.insert (*sel_it);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!notes.empty()) {
|
|
|
|
selection.push_back (make_pair ((rv)->region()->id(), notes));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-01-08 21:36:47 -05:00
|
|
|
void
|
|
|
|
MidiTimeAxisView::set_channel_mode (ChannelMode, uint16_t)
|
|
|
|
{
|
2010-01-10 13:11:02 -05:00
|
|
|
/* hide all automation tracks that use the wrong channel(s) and show all those that use
|
|
|
|
the right ones.
|
|
|
|
*/
|
|
|
|
|
2013-03-27 21:50:18 -04:00
|
|
|
const uint16_t selected_channels = midi_track()->get_playback_channel_mask();
|
2010-01-10 13:11:02 -05:00
|
|
|
bool changed = false;
|
|
|
|
|
|
|
|
no_redraw = true;
|
|
|
|
|
|
|
|
for (uint32_t ctl = 0; ctl < 127; ++ctl) {
|
|
|
|
|
|
|
|
for (uint32_t chn = 0; chn < 16; ++chn) {
|
|
|
|
Evoral::Parameter fully_qualified_param (MidiCCAutomation, chn, ctl);
|
2010-05-25 10:50:45 -04:00
|
|
|
boost::shared_ptr<AutomationTimeAxisView> track = automation_child (fully_qualified_param);
|
2010-01-10 13:11:02 -05:00
|
|
|
|
2010-05-25 10:50:45 -04:00
|
|
|
if (!track) {
|
2010-01-10 13:11:02 -05:00
|
|
|
continue;
|
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-01-10 13:11:02 -05:00
|
|
|
if ((selected_channels & (0x0001 << chn)) == 0) {
|
2011-06-01 13:00:29 -04:00
|
|
|
/* channel not in use. hiding it will trigger RouteTimeAxisView::automation_track_hidden()
|
2010-01-10 13:11:02 -05:00
|
|
|
which will cause a redraw. We don't want one per channel, so block that with no_redraw.
|
2013-01-19 00:54:44 -05:00
|
|
|
*/
|
2011-07-06 20:37:13 -04:00
|
|
|
changed = track->set_marked_for_display (false) || changed;
|
2010-01-10 13:11:02 -05:00
|
|
|
} else {
|
2011-07-06 20:37:13 -04:00
|
|
|
changed = track->set_marked_for_display (true) || changed;
|
2010-01-10 13:11:02 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
no_redraw = false;
|
|
|
|
|
2010-12-28 13:19:40 -05:00
|
|
|
/* TODO: Bender, Pressure */
|
2010-01-10 13:11:02 -05:00
|
|
|
|
2011-02-17 11:43:30 -05:00
|
|
|
/* invalidate the controller menu, so that we rebuild it next time */
|
2010-06-08 17:48:38 -04:00
|
|
|
_controller_menu_map.clear ();
|
2010-01-08 21:36:47 -05:00
|
|
|
delete controller_menu;
|
|
|
|
controller_menu = 0;
|
2010-01-10 13:11:02 -05:00
|
|
|
|
|
|
|
if (changed) {
|
2011-07-06 20:37:13 -04:00
|
|
|
request_redraw ();
|
2010-01-10 13:11:02 -05:00
|
|
|
}
|
2010-01-08 21:36:47 -05:00
|
|
|
}
|
2010-06-08 17:48:38 -04:00
|
|
|
|
|
|
|
Gtk::CheckMenuItem*
|
|
|
|
MidiTimeAxisView::automation_child_menu_item (Evoral::Parameter param)
|
|
|
|
{
|
|
|
|
Gtk::CheckMenuItem* m = RouteTimeAxisView::automation_child_menu_item (param);
|
|
|
|
if (m) {
|
|
|
|
return m;
|
|
|
|
}
|
|
|
|
|
|
|
|
ParameterMenuMap::iterator i = _controller_menu_map.find (param);
|
|
|
|
if (i != _controller_menu_map.end()) {
|
|
|
|
return i->second;
|
|
|
|
}
|
|
|
|
|
|
|
|
i = _channel_command_menu_map.find (param);
|
|
|
|
if (i != _channel_command_menu_map.end()) {
|
|
|
|
return i->second;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2010-08-15 12:39:51 -04:00
|
|
|
|
|
|
|
boost::shared_ptr<MidiRegion>
|
2017-09-18 12:39:17 -04:00
|
|
|
MidiTimeAxisView::add_region (samplepos_t f, samplecnt_t length, bool commit)
|
2010-08-15 12:39:51 -04:00
|
|
|
{
|
|
|
|
Editor* real_editor = dynamic_cast<Editor*> (&_editor);
|
2017-09-18 12:39:17 -04:00
|
|
|
MusicSample pos (f, 0);
|
2017-01-26 08:41:17 -05:00
|
|
|
|
2015-06-16 19:26:40 -04:00
|
|
|
if (commit) {
|
|
|
|
real_editor->begin_reversible_command (Operations::create_region);
|
|
|
|
}
|
2013-01-19 00:54:44 -05:00
|
|
|
playlist()->clear_changes ();
|
2010-08-15 12:39:51 -04:00
|
|
|
|
2014-11-16 01:05:21 -05:00
|
|
|
real_editor->snap_to (pos, RoundNearest);
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2014-04-13 10:29:07 -04:00
|
|
|
boost::shared_ptr<Source> src = _session->create_midi_source_by_stealing_name (view()->trackview().track());
|
2011-06-01 13:00:29 -04:00
|
|
|
PropertyList plist;
|
|
|
|
|
2010-08-15 12:39:51 -04:00
|
|
|
plist.add (ARDOUR::Properties::start, 0);
|
|
|
|
plist.add (ARDOUR::Properties::length, length);
|
|
|
|
plist.add (ARDOUR::Properties::name, PBD::basename_nosuffix(src->name()));
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-08-15 12:39:51 -04:00
|
|
|
boost::shared_ptr<Region> region = (RegionFactory::create (src, plist));
|
2016-06-15 10:18:27 -04:00
|
|
|
/* sets beat position */
|
2017-09-18 12:39:17 -04:00
|
|
|
region->set_position (pos.sample, pos.division);
|
|
|
|
playlist()->add_region (region, pos.sample, 1.0, false, pos.division);
|
2010-08-15 12:39:51 -04:00
|
|
|
_session->add_command (new StatefulDiffCommand (playlist()));
|
|
|
|
|
2010-08-20 08:01:13 -04:00
|
|
|
if (commit) {
|
|
|
|
real_editor->commit_reversible_command ();
|
|
|
|
}
|
2010-08-15 12:39:51 -04:00
|
|
|
|
|
|
|
return boost::dynamic_pointer_cast<MidiRegion>(region);
|
|
|
|
}
|
|
|
|
|
2011-02-12 07:29:20 -05:00
|
|
|
void
|
|
|
|
MidiTimeAxisView::ensure_step_editor ()
|
|
|
|
{
|
|
|
|
if (!_step_editor) {
|
|
|
|
_step_editor = new StepEditor (_editor, midi_track(), *this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-01 13:00:29 -04:00
|
|
|
void
|
2010-08-15 12:39:51 -04:00
|
|
|
MidiTimeAxisView::start_step_editing ()
|
|
|
|
{
|
2011-02-12 07:29:20 -05:00
|
|
|
ensure_step_editor ();
|
2013-01-19 00:54:44 -05:00
|
|
|
_step_editor->start_step_editing ();
|
2010-08-15 12:39:51 -04:00
|
|
|
|
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
void
|
2010-08-15 12:39:51 -04:00
|
|
|
MidiTimeAxisView::stop_step_editing ()
|
|
|
|
{
|
2013-01-19 00:54:44 -05:00
|
|
|
if (_step_editor) {
|
|
|
|
_step_editor->stop_step_editing ();
|
|
|
|
}
|
2010-08-15 12:39:51 -04:00
|
|
|
}
|
2011-05-25 11:19:47 -04:00
|
|
|
|
|
|
|
/** @return channel (counted from 0) to add an event to, based on the current setting
|
|
|
|
* of the channel selector.
|
|
|
|
*/
|
|
|
|
uint8_t
|
|
|
|
MidiTimeAxisView::get_channel_for_add () const
|
|
|
|
{
|
2013-03-27 21:50:18 -04:00
|
|
|
uint16_t const chn_mask = midi_track()->get_playback_channel_mask();
|
2011-05-25 11:19:47 -04:00
|
|
|
int chn_cnt = 0;
|
|
|
|
uint8_t channel = 0;
|
|
|
|
|
|
|
|
/* pick the highest selected channel, unless all channels are selected,
|
|
|
|
which is interpreted to mean channel 1 (zero)
|
|
|
|
*/
|
|
|
|
|
|
|
|
for (uint16_t i = 0; i < 16; ++i) {
|
|
|
|
if (chn_mask & (1<<i)) {
|
|
|
|
channel = i;
|
|
|
|
chn_cnt++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (chn_cnt == 16) {
|
|
|
|
channel = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return channel;
|
|
|
|
}
|
2011-08-14 14:40:57 -04:00
|
|
|
|
|
|
|
void
|
|
|
|
MidiTimeAxisView::note_range_changed ()
|
|
|
|
{
|
|
|
|
set_gui_property ("note-range-min", (int) midi_view()->lowest_note ());
|
|
|
|
set_gui_property ("note-range-max", (int) midi_view()->highest_note ());
|
|
|
|
}
|
2012-06-02 10:53:34 -04:00
|
|
|
|
2012-06-13 16:37:34 -04:00
|
|
|
void
|
|
|
|
MidiTimeAxisView::contents_height_changed ()
|
|
|
|
{
|
2014-09-08 12:42:41 -04:00
|
|
|
_range_scroomer->queue_resize ();
|
2012-06-13 16:37:34 -04:00
|
|
|
}
|
2013-03-28 17:10:57 -04:00
|
|
|
|
2014-12-16 14:37:40 -05:00
|
|
|
bool
|
2017-09-18 12:39:17 -04:00
|
|
|
MidiTimeAxisView::paste (samplepos_t pos, const Selection& selection, PasteContext& ctx, const int32_t sub_num)
|
2014-12-16 14:37:40 -05:00
|
|
|
{
|
|
|
|
if (!_editor.internal_editing()) {
|
|
|
|
// Non-internal paste, paste regions like any other route
|
2016-06-16 13:20:37 -04:00
|
|
|
return RouteTimeAxisView::paste(pos, selection, ctx, sub_num);
|
2014-12-16 14:37:40 -05:00
|
|
|
}
|
|
|
|
|
2016-06-16 13:20:37 -04:00
|
|
|
return midi_view()->paste(pos, selection, ctx, sub_num);
|
2014-12-16 14:37:40 -05:00
|
|
|
}
|