2006-07-23 08:03:19 -04:00
|
|
|
/*
|
2009-10-14 12:10:01 -04:00
|
|
|
Copyright (C) 2000 Paul Davis
|
2006-07-23 08:03:19 -04:00
|
|
|
|
|
|
|
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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <cstdlib>
|
|
|
|
#include <cmath>
|
|
|
|
|
|
|
|
#include <algorithm>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include <sigc++/bind.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/selector.h"
|
|
|
|
#include "gtkmm2ext/bindable_button.h"
|
|
|
|
#include "gtkmm2ext/utils.h"
|
2006-07-23 08:03:19 -04:00
|
|
|
|
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"
|
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
|
|
|
|
2011-11-02 12:46:49 -04:00
|
|
|
#include "ardour_button.h"
|
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"
|
|
|
|
#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"
|
|
|
|
#include "prompter.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"
|
2015-01-05 00:32:14 -05:00
|
|
|
#include "tooltips.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
|
|
|
|
|
|
|
#include "i18n.h"
|
|
|
|
|
|
|
|
using namespace ARDOUR;
|
2014-06-25 15:27:37 -04:00
|
|
|
using namespace ARDOUR_UI_UTILS;
|
2006-07-23 08:03:19 -04:00
|
|
|
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
|
|
|
|
2013-04-04 00:32:52 -04:00
|
|
|
MidiTimeAxisView::MidiTimeAxisView (PublicEditor& ed, Session* sess, ArdourCanvas::Canvas& canvas)
|
2008-09-22 22:40:29 -04:00
|
|
|
: AxisView(sess) // virtually inherited
|
2011-07-06 20:37:13 -04:00
|
|
|
, 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)
|
2013-01-19 00:54:44 -05:00
|
|
|
, _step_editor (0)
|
2006-07-23 08:03:19 -04:00
|
|
|
{
|
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);
|
|
|
|
|
2015-01-09 17:49:16 -05:00
|
|
|
_view->apply_color (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");
|
|
|
|
|
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
|
|
|
midi_view()->NoteRangeChanged.connect (
|
|
|
|
sigc::mem_fun (*this, &MidiTimeAxisView::note_range_changed));
|
|
|
|
_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()) {
|
2006-07-23 08:03:19 -04:00
|
|
|
controls_ebox.set_name ("MidiTimeAxisViewControlsBaseUnselected");
|
2014-08-31 12:51:04 -04:00
|
|
|
time_axis_frame.set_name ("MidiTimeAxisViewControlsBaseUnselected");
|
2007-07-06 23:19:04 -04:00
|
|
|
_note_mode = midi_track()->note_mode();
|
|
|
|
} else { // MIDI bus (which doesn't exist yet..)
|
2006-07-23 08:03:19 -04:00
|
|
|
controls_ebox.set_name ("MidiBusControlsBaseUnselected");
|
2014-08-31 12:51:04 -04:00
|
|
|
time_axis_frame.set_name ("MidiBusControlsBaseUnselected");
|
2007-07-06 23:19:04 -04:00
|
|
|
}
|
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);
|
2006-07-23 08:03:19 -04:00
|
|
|
|
2009-11-30 18:16:28 -05:00
|
|
|
processors_changed (RouteProcessorChange ());
|
2006-07-23 08:03:19 -04:00
|
|
|
|
2013-01-19 00:54:44 -05:00
|
|
|
_route->processors_changed.connect (*this, invalidator (*this),
|
|
|
|
boost::bind (&MidiTimeAxisView::processors_changed, this, _1),
|
|
|
|
gui_context());
|
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
|
|
|
|
2011-04-16 09:31:27 -04:00
|
|
|
/* Suspend updates of the StreamView during scroomer drags to speed things up */
|
2013-01-19 00:54:44 -05:00
|
|
|
_range_scroomer->DragStarting.connect (
|
|
|
|
sigc::mem_fun (*midi_view(), &MidiStreamView::suspend_updates));
|
|
|
|
_range_scroomer->DragFinishing.connect (
|
|
|
|
sigc::mem_fun (*midi_view(), &MidiStreamView::resume_updates));
|
2011-04-16 09:31:27 -04: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
|
|
|
|
|
|
|
controls_ebox.set_name ("MidiTrackControlsBaseUnselected");
|
2014-08-31 12:51:04 -04:00
|
|
|
time_axis_frame.set_name ("MidiTrackControlsBaseUnselected");
|
2006-07-23 08:03:19 -04:00
|
|
|
controls_base_selected_name = "MidiTrackControlsBaseSelected";
|
|
|
|
controls_base_unselected_name = "MidiTrackControlsBaseUnselected";
|
|
|
|
|
2013-01-19 00:54:44 -05:00
|
|
|
midi_view()->NoteRangeChanged.connect (
|
|
|
|
sigc::mem_fun(*this, &MidiTimeAxisView::update_range));
|
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
|
|
|
|
2015-03-28 23:24:41 -04:00
|
|
|
midi_track()->playback_filter().ChannelModeChanged.connect (
|
|
|
|
*this, invalidator (*this),
|
|
|
|
boost::bind (&MidiTimeAxisView::playback_channel_mode_changed, this),
|
|
|
|
gui_context());
|
|
|
|
midi_track()->playback_filter().ChannelMaskChanged.connect (
|
|
|
|
*this, invalidator (*this),
|
|
|
|
boost::bind (&MidiTimeAxisView::playback_channel_mode_changed, this),
|
|
|
|
gui_context());
|
|
|
|
midi_track()->capture_filter().ChannelModeChanged.connect (
|
|
|
|
*this, invalidator (*this),
|
|
|
|
boost::bind (&MidiTimeAxisView::capture_channel_mode_changed, this),
|
|
|
|
gui_context());
|
|
|
|
midi_track()->capture_filter().ChannelMaskChanged.connect (
|
|
|
|
*this, invalidator (*this),
|
|
|
|
boost::bind (&MidiTimeAxisView::capture_channel_mode_changed, this),
|
|
|
|
gui_context());
|
2013-03-28 17:10:57 -04:00
|
|
|
|
|
|
|
playback_channel_mode_changed ();
|
|
|
|
capture_channel_mode_changed ();
|
|
|
|
|
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
|
|
|
|
2014-12-13 00:37:34 -05:00
|
|
|
typedef MIDI::Name::MidiPatchManager PatchManager;
|
|
|
|
|
|
|
|
PatchManager& patch_manager = PatchManager::instance();
|
|
|
|
|
|
|
|
for (PatchManager::DeviceNamesByMaker::const_iterator m = patch_manager.devices_by_manufacturer().begin();
|
|
|
|
m != patch_manager.devices_by_manufacturer().end(); ++m) {
|
|
|
|
Menu* menu = Gtk::manage(new Menu);
|
|
|
|
Menu_Helpers::MenuList& items = menu->items();
|
|
|
|
|
|
|
|
// Build manufacturer submenu
|
|
|
|
for (MIDI::Name::MIDINameDocument::MasterDeviceNamesList::const_iterator n = m->second.begin();
|
|
|
|
n != m->second.end(); ++n) {
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add manufacturer submenu to selector
|
|
|
|
_midnam_model_selector.AddMenuElem(Menu_Helpers::MenuElem(m->first, *menu));
|
2008-12-09 02:42:19 -05:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2013-01-19 14:06:21 -05:00
|
|
|
if (gui_property (X_("midnam-model-name")).empty()) {
|
|
|
|
set_gui_property (X_("midnam-model-name"), "Generic");
|
|
|
|
}
|
|
|
|
|
2013-01-19 15:15:15 -05:00
|
|
|
if (gui_property (X_("midnam-custom-device-mode")).empty()) {
|
2013-01-19 19:46:55 -05:00
|
|
|
boost::shared_ptr<MIDI::Name::MasterDeviceNames> device_names = get_device_names();
|
2013-01-19 15:15:15 -05:00
|
|
|
if (device_names) {
|
|
|
|
set_gui_property (X_("midnam-custom-device-mode"),
|
|
|
|
*device_names->custom_device_mode_names().begin());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-05 00:32:14 -05:00
|
|
|
set_tooltip (_midnam_model_selector, _("External MIDI Device"));
|
|
|
|
set_tooltip (_midnam_custom_device_mode_selector, _("External Device Mode"));
|
2012-06-11 18:59:35 -04:00
|
|
|
|
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
|
|
|
|
2013-03-28 17:10:57 -04:00
|
|
|
_channel_status_box.set_homogeneous (false);
|
2014-09-09 08:39:36 -04:00
|
|
|
_channel_status_box.set_spacing (4);
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2014-09-09 08:39:36 -04:00
|
|
|
ArdourButton *channel_selector_button = manage (new ArdourButton(_("Chns")));
|
|
|
|
channel_selector_button->set_name ("route button");
|
2015-01-05 00:32:14 -05:00
|
|
|
set_tooltip (channel_selector_button, _("Click to edit channel settings"));
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2015-03-13 21:54:57 -04:00
|
|
|
// Insert expanding space labels to get full width justification
|
|
|
|
_channel_status_box.pack_start (_playback_channel_status, false, false, 2);
|
|
|
|
_channel_status_box.pack_start (*Gtk::manage(new Gtk::Label(" ")), true, true);
|
|
|
|
_channel_status_box.pack_start (_capture_channel_status, false, false, 2);
|
|
|
|
_channel_status_box.pack_start (*Gtk::manage(new Gtk::Label(" ")), true, true);
|
2014-09-09 08:39:36 -04:00
|
|
|
_channel_status_box.pack_end (*channel_selector_button, false, false);
|
2013-03-28 17:10:57 -04:00
|
|
|
_channel_status_box.show_all ();
|
|
|
|
|
2014-09-09 08:39:36 -04:00
|
|
|
channel_selector_button->signal_clicked.connect (sigc::mem_fun (*this, &MidiTimeAxisView::toggle_channel_selector));
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2013-03-28 17:10:57 -04:00
|
|
|
_midi_controls_box.pack_start (_channel_status_box, false, false, 10);
|
|
|
|
|
2008-12-10 05:54:45 -05:00
|
|
|
if (!patch_manager.all_models().empty()) {
|
2012-10-11 04:55:20 -04:00
|
|
|
|
2013-01-19 11:05:06 -05:00
|
|
|
_midnam_model_selector.show ();
|
2014-09-09 08:39:36 -04:00
|
|
|
_midi_controls_box.pack_start (_midnam_model_selector, false, false, 2);
|
2012-10-11 04:55:20 -04:00
|
|
|
|
2013-01-19 11:05:06 -05:00
|
|
|
_midnam_custom_device_mode_selector.show ();
|
2013-01-19 14:06:21 -05:00
|
|
|
|
2014-09-09 08:39:36 -04:00
|
|
|
_midi_controls_box.pack_start (_midnam_custom_device_mode_selector, false, false, 2);
|
2015-10-04 14:51:05 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2014-12-12 23:38:41 -05:00
|
|
|
model_changed(gui_property(X_("midnam-model-name")));
|
|
|
|
custom_device_mode_changed(gui_property(X_("midnam-custom-device-mode")));
|
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"));
|
|
|
|
create_automation_child (parameter, string_is_affirmative (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
|
|
|
}
|
|
|
|
|
2011-06-01 13:00:29 -04:00
|
|
|
void
|
2014-12-12 23:38:41 -05:00
|
|
|
MidiTimeAxisView::model_changed(const std::string& model)
|
2008-12-11 03:06:27 -05:00
|
|
|
{
|
2012-10-12 05:25:55 -04:00
|
|
|
set_gui_property (X_("midnam-model-name"), model);
|
|
|
|
|
2013-01-19 05:02:00 -05:00
|
|
|
const std::list<std::string> device_modes = MIDI::Name::MidiPatchManager::instance()
|
2012-10-12 05:25:55 -04:00
|
|
|
.custom_device_mode_names_by_model(model);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2014-12-12 23:38:41 -05:00
|
|
|
_midnam_model_selector.set_text(model);
|
2012-10-12 05:25:55 -04:00
|
|
|
_midnam_custom_device_mode_selector.clear_items();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2013-01-19 15:15:15 -05:00
|
|
|
for (std::list<std::string>::const_iterator i = device_modes.begin();
|
|
|
|
i != device_modes.end(); ++i) {
|
2014-12-12 23:38:41 -05:00
|
|
|
_midnam_custom_device_mode_selector.AddMenuElem(
|
|
|
|
Gtk::Menu_Helpers::MenuElem(
|
|
|
|
*i, sigc::bind(sigc::mem_fun(*this, &MidiTimeAxisView::custom_device_mode_changed),
|
|
|
|
*i)));
|
2008-12-11 03:06:27 -05:00
|
|
|
}
|
|
|
|
|
2014-12-12 23:38:41 -05:00
|
|
|
if (!device_modes.empty()) {
|
|
|
|
custom_device_mode_changed(device_modes.front());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (device_modes.size() > 1) {
|
|
|
|
_midnam_custom_device_mode_selector.show();
|
|
|
|
} else {
|
|
|
|
_midnam_custom_device_mode_selector.hide();
|
|
|
|
}
|
|
|
|
|
2015-01-10 13:31:50 -05:00
|
|
|
if (device_modes.size() > 0) {
|
|
|
|
_route->instrument_info().set_external_instrument (model, device_modes.front());
|
|
|
|
} else {
|
|
|
|
_route->instrument_info().set_external_instrument (model, "");
|
|
|
|
}
|
2013-01-19 01:17:02 -05:00
|
|
|
|
|
|
|
// Rebuild controller menu
|
|
|
|
_controller_menu_map.clear ();
|
|
|
|
delete controller_menu;
|
|
|
|
controller_menu = 0;
|
|
|
|
build_automation_action_menu(false);
|
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);
|
2014-12-12 23:38:41 -05:00
|
|
|
_midnam_custom_device_mode_selector.set_text(mode);
|
|
|
|
_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()));
|
2013-03-27 21:50:18 -04:00
|
|
|
items.push_back (MenuElem (_("Channel Selector"),
|
|
|
|
sigc::mem_fun(*this, &MidiTimeAxisView::toggle_channel_selector)));
|
2009-09-25 15:00:34 -04:00
|
|
|
|
2013-03-27 21:50:18 -04:00
|
|
|
color_mode_menu = build_color_mode_menu();
|
|
|
|
if (color_mode_menu) {
|
|
|
|
items.push_back (MenuElem (_("Color Mode"), *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));
|
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);
|
|
|
|
}
|
|
|
|
|
2013-01-19 19:46:55 -05:00
|
|
|
boost::shared_ptr<MIDI::Name::CustomDeviceMode>
|
|
|
|
MidiTimeAxisView::get_device_mode()
|
|
|
|
{
|
|
|
|
using namespace MIDI::Name;
|
|
|
|
|
|
|
|
boost::shared_ptr<MasterDeviceNames> device_names = get_device_names();
|
|
|
|
if (!device_names) {
|
|
|
|
return boost::shared_ptr<MIDI::Name::CustomDeviceMode>();
|
|
|
|
}
|
|
|
|
|
|
|
|
return device_names->custom_device_mode_by_name(
|
|
|
|
gui_property (X_("midnam-custom-device-mode")));
|
|
|
|
}
|
|
|
|
|
2013-01-19 15:15:15 -05:00
|
|
|
boost::shared_ptr<MIDI::Name::MasterDeviceNames>
|
2013-01-19 19:46:55 -05:00
|
|
|
MidiTimeAxisView::get_device_names()
|
2013-01-19 15:15:15 -05:00
|
|
|
{
|
|
|
|
using namespace MIDI::Name;
|
2013-01-19 19:46:55 -05:00
|
|
|
|
|
|
|
const std::string model = gui_property (X_("midnam-model-name"));
|
|
|
|
|
2013-01-19 15:15:15 -05:00
|
|
|
boost::shared_ptr<MIDINameDocument> midnam = MidiPatchManager::instance()
|
|
|
|
.document_by_model(model);
|
|
|
|
if (midnam) {
|
|
|
|
return midnam->master_device_names(model);
|
|
|
|
} else {
|
|
|
|
return boost::shared_ptr<MasterDeviceNames>();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2013-01-16 03:24:31 -05:00
|
|
|
using namespace MIDI::Name;
|
2013-01-19 19:46:55 -05:00
|
|
|
boost::shared_ptr<MasterDeviceNames> device_names = get_device_names();
|
2013-01-16 03:24:31 -05:00
|
|
|
|
|
|
|
if (device_names && !device_names->controls().empty()) {
|
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
|
|
|
|
|
|
|
/* TODO: This is not correct, should look up the currently applicable ControlNameList
|
|
|
|
and only build a menu for that one. */
|
2013-01-16 03:24:31 -05:00
|
|
|
for (MasterDeviceNames::ControlNameLists::const_iterator l = device_names->controls().begin();
|
|
|
|
l != device_names->controls().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();
|
2013-01-26 17:30:34 -05:00
|
|
|
if (ctl != MIDI_CTL_MSB_BANK && ctl != MIDI_CTL_LSB_BANK) {
|
2013-01-19 05:02:00 -05:00
|
|
|
/* Skip bank select controllers since they're handled specially */
|
2013-01-26 17:30:34 -05:00
|
|
|
if (n_items == 0) {
|
|
|
|
/* Create a new submenu */
|
|
|
|
ctl_menu = manage (new Menu);
|
|
|
|
}
|
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());
|
|
|
|
}
|
2013-01-19 05:02:00 -05:00
|
|
|
}
|
2013-01-26 17:08:06 -05:00
|
|
|
|
|
|
|
++c;
|
2013-01-26 17:30:34 -05:00
|
|
|
if (ctl_menu && (++n_items == 16 || c == name_list->controls().end())) {
|
|
|
|
/* Submenu has 16 items or we're done, add it to controller menu and reset */
|
2013-01-19 05:02:00 -05:00
|
|
|
items.push_back(
|
|
|
|
MenuElem(string_compose(_("Controllers %1-%2"),
|
|
|
|
(16 * n_groups), (16 * n_groups) + n_items - 1),
|
|
|
|
*ctl_menu));
|
|
|
|
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 */
|
|
|
|
for (int i = 0; i < 127; i += 16) {
|
|
|
|
Menu* ctl_menu = manage (new Menu);
|
|
|
|
MenuList& ctl_items (ctl_menu->items());
|
|
|
|
|
|
|
|
for (int ctl = i; ctl < i+16; ++ctl) {
|
|
|
|
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 */
|
|
|
|
items.push_back (
|
|
|
|
MenuElem (string_compose (_("Controllers %1-%2"), i, i + 15),
|
|
|
|
*ctl_menu));
|
|
|
|
}
|
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-02-10 13:16:25 -05:00
|
|
|
void
|
2008-02-18 22:24:44 -05:00
|
|
|
MidiTimeAxisView::update_range()
|
|
|
|
{
|
2008-02-10 13:16:25 -05:00
|
|
|
MidiGhostRegion* mgr;
|
|
|
|
|
2013-01-19 01:17:02 -05:00
|
|
|
for (list<GhostRegion*>::iterator i = ghosts.begin(); i != ghosts.end(); ++i) {
|
2008-02-21 20:45:29 -05:00
|
|
|
if ((mgr = dynamic_cast<MidiGhostRegion*>(*i)) != 0) {
|
2008-02-10 13:16:25 -05:00
|
|
|
mgr->update_range();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
|
|
|
// Show automation for all controllers named in midnam file
|
|
|
|
boost::shared_ptr<MasterDeviceNames> device_names = get_device_names();
|
2014-07-14 01:27:21 -04:00
|
|
|
if (gui_property (X_("midnam-model-name")) != "Generic" &&
|
|
|
|
device_names && !device_names->controls().empty()) {
|
2014-12-12 23:38:41 -05:00
|
|
|
const std::string device_mode = gui_property (X_("midnam-custom-device-mode"));
|
2014-07-14 00:43:36 -04:00
|
|
|
const uint16_t selected_channels = midi_track()->get_playback_channel_mask();
|
|
|
|
for (uint32_t chn = 0; chn < 16; ++chn) {
|
|
|
|
if ((selected_channels & (0x0001 << chn)) == 0) {
|
|
|
|
// Channel not in use
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
boost::shared_ptr<ChannelNameSet> chan_names = device_names->channel_name_set_by_channel(
|
|
|
|
device_mode, chn);
|
|
|
|
if (!chan_names) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
boost::shared_ptr<ControlNameList> control_names = device_names->control_name_list(
|
|
|
|
chan_names->control_list_name());
|
|
|
|
if (!control_names) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (ControlNameList::Controls::const_iterator c = control_names->controls().begin();
|
|
|
|
c != control_names->controls().end();
|
|
|
|
++c) {
|
|
|
|
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:
|
|
|
|
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:
|
|
|
|
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);
|
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 ()
|
|
|
|
{
|
|
|
|
RouteUI::route_active_changed ();
|
|
|
|
|
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_ebox.set_name ("MidiTrackControlsBaseUnselected");
|
2014-08-31 12:51:04 -04:00
|
|
|
time_axis_frame.set_name ("MidiTrackControlsBaseUnselected");
|
2006-07-23 08:03:19 -04:00
|
|
|
controls_base_selected_name = "MidiTrackControlsBaseSelected";
|
|
|
|
controls_base_unselected_name = "MidiTrackControlsBaseUnselected";
|
|
|
|
} else {
|
|
|
|
controls_ebox.set_name ("MidiTrackControlsBaseInactiveUnselected");
|
2014-08-31 12:51:04 -04:00
|
|
|
time_axis_frame.set_name ("MidiTrackControlsBaseInactiveUnselected");
|
2006-07-23 08:03:19 -04:00
|
|
|
controls_base_selected_name = "MidiTrackControlsBaseInactiveSelected";
|
|
|
|
controls_base_unselected_name = "MidiTrackControlsBaseInactiveUnselected";
|
|
|
|
}
|
|
|
|
} else {
|
2006-07-27 21:08:57 -04:00
|
|
|
if (_route->active()) {
|
2006-07-23 08:03:19 -04:00
|
|
|
controls_ebox.set_name ("BusControlsBaseUnselected");
|
2014-08-31 12:51:04 -04:00
|
|
|
time_axis_frame.set_name ("BusControlsBaseUnselected");
|
2006-07-23 08:03:19 -04:00
|
|
|
controls_base_selected_name = "BusControlsBaseSelected";
|
|
|
|
controls_base_unselected_name = "BusControlsBaseUnselected";
|
|
|
|
} else {
|
|
|
|
controls_ebox.set_name ("BusControlsBaseInactiveUnselected");
|
2014-08-31 12:51:04 -04:00
|
|
|
time_axis_frame.set_name ("BusControlsBaseInactiveUnselected");
|
2006-07-23 08:03:19 -04:00
|
|
|
controls_base_selected_name = "BusControlsBaseInactiveSelected";
|
|
|
|
controls_base_unselected_name = "BusControlsBaseInactiveUnselected";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
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
|
|
|
|
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 (
|
|
|
|
sigc::bind (sigc::mem_fun (*this, &MidiTimeAxisView::set_note_selection_region_view),
|
|
|
|
note, chn_mask));
|
2012-01-19 21:54:23 -05:00
|
|
|
} else {
|
2013-01-19 00:54:44 -05:00
|
|
|
_view->foreach_selected_regionview (
|
|
|
|
sigc::bind (sigc::mem_fun (*this, &MidiTimeAxisView::set_note_selection_region_view),
|
|
|
|
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
|
|
|
|
MidiTimeAxisView::get_per_region_note_selection (list<pair<PBD::ID, set<boost::shared_ptr<Evoral::Note<Evoral::Beats> > > > >& selection)
|
|
|
|
{
|
|
|
|
_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
|
|
|
|
MidiTimeAxisView::get_per_region_note_selection_region_view (RegionView* rv, list<pair<PBD::ID, std::set<boost::shared_ptr<Evoral::Note<Evoral::Beats> > > > > &selection)
|
|
|
|
{
|
|
|
|
Evoral::Sequence<Evoral::Beats>::Notes selected;
|
|
|
|
dynamic_cast<MidiRegionView*>(rv)->selection_as_notelist (selected, false);
|
|
|
|
|
|
|
|
std::set<boost::shared_ptr<Evoral::Note<Evoral::Beats> > > notes;
|
|
|
|
|
|
|
|
Evoral::Sequence<Evoral::Beats>::Notes::iterator sel_it;
|
|
|
|
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>
|
2010-08-20 08:01:13 -04:00
|
|
|
MidiTimeAxisView::add_region (framepos_t pos, framecnt_t length, bool commit)
|
2010-08-15 12:39:51 -04:00
|
|
|
{
|
|
|
|
Editor* real_editor = dynamic_cast<Editor*> (&_editor);
|
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));
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-08-15 12:39:51 -04:00
|
|
|
playlist()->add_region (region, pos);
|
|
|
|
_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
|
|
|
|
|
|
|
void
|
|
|
|
MidiTimeAxisView::playback_channel_mode_changed ()
|
|
|
|
{
|
|
|
|
switch (midi_track()->get_playback_channel_mode()) {
|
|
|
|
case AllChannels:
|
2013-05-30 15:36:39 -04:00
|
|
|
_playback_channel_status.set_markup (string_compose ("<b>%1</b>: <i>%2</i>", _("Play"), _("all")));
|
2013-03-28 17:10:57 -04:00
|
|
|
break;
|
|
|
|
case FilterChannels:
|
2013-05-30 15:36:39 -04:00
|
|
|
_playback_channel_status.set_markup (string_compose ("<b>%1</b>: <i>%2</i>", _("Play"), _("some")));
|
2013-03-28 17:10:57 -04:00
|
|
|
break;
|
|
|
|
case ForceChannel:
|
2013-07-17 06:03:34 -04:00
|
|
|
_playback_channel_status.set_markup (string_compose ("<b>%1</b>: <i>%2>%3</i>", _("Play"), _("all"), PBD::ffs (midi_track()->get_playback_channel_mask())));
|
2013-03-28 17:10:57 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MidiTimeAxisView::capture_channel_mode_changed ()
|
|
|
|
{
|
|
|
|
switch (midi_track()->get_capture_channel_mode()) {
|
|
|
|
case AllChannels:
|
2013-05-30 15:36:39 -04:00
|
|
|
_capture_channel_status.set_markup (string_compose ("<b>%1</b>: <i>%2</i>", _("Rec"), _("all")));
|
2013-03-28 17:10:57 -04:00
|
|
|
break;
|
|
|
|
case FilterChannels:
|
2013-05-30 15:36:39 -04:00
|
|
|
_capture_channel_status.set_markup (string_compose ("<b>%1</b>: <i>%2</i>", _("Rec"), _("some")));
|
2013-03-28 17:10:57 -04:00
|
|
|
break;
|
|
|
|
case ForceChannel:
|
2013-07-17 06:03:34 -04:00
|
|
|
_capture_channel_status.set_markup (string_compose ("<b>%1</b>: <i>%2>%3</i>", _("Rec"), _("all"), PBD::ffs (midi_track()->get_capture_channel_mask())));
|
2013-03-28 17:10:57 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2014-12-16 14:37:40 -05:00
|
|
|
|
|
|
|
bool
|
|
|
|
MidiTimeAxisView::paste (framepos_t pos, const Selection& selection, PasteContext& ctx)
|
|
|
|
{
|
|
|
|
if (!_editor.internal_editing()) {
|
|
|
|
// Non-internal paste, paste regions like any other route
|
|
|
|
return RouteTimeAxisView::paste(pos, selection, ctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
return midi_view()->paste(pos, selection, ctx);
|
|
|
|
}
|