X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fmidi_time_axis.cc;h=59cfe4abbd3d7e2246f8fee4ddeca4873d2cf23e;hb=3b079064e62facf91a35d2307709fc00feb0bb19;hp=62beda87741b58839616bcffe60d178bb275c058;hpb=faca3e5f5d666fc543b23f6ab7b93a14f6c8ff7f;p=ardour.git diff --git a/gtk2_ardour/midi_time_axis.cc b/gtk2_ardour/midi_time_axis.cc index 62beda8774..59cfe4abbd 100644 --- a/gtk2_ardour/midi_time_axis.cc +++ b/gtk2_ardour/midi_time_axis.cc @@ -116,6 +116,7 @@ MidiTimeAxisView::MidiTimeAxisView (PublicEditor& ed, Session* sess, , _midi_thru_item (0) , default_channel_menu (0) , controller_menu (0) + , _step_editor (0) { subplugin_menu.set_name ("ArdourContextMenu"); @@ -163,8 +164,12 @@ MidiTimeAxisView::MidiTimeAxisView (PublicEditor& ed, Session* sess, /* ask for notifications of any new RegionViews */ _view->RegionViewAdded.connect (sigc::mem_fun(*this, &MidiTimeAxisView::region_view_added)); - _view->attach (); - + + if (!_editor.have_idled()) { + /* first idle will do what we need */ + } else { + first_idle (); + } } HBox* midi_controls_hbox = manage(new HBox()); @@ -218,6 +223,14 @@ MidiTimeAxisView::MidiTimeAxisView (PublicEditor& ed, Session* sess, } } +void +MidiTimeAxisView::first_idle () +{ + if (is_track ()) { + _view->attach (); + } +} + MidiTimeAxisView::~MidiTimeAxisView () { delete _piano_roll_header; @@ -407,13 +420,12 @@ MidiTimeAxisView::build_automation_action_menu () automation_items.push_back (SeparatorElem()); - /* these 3 MIDI "command" types are semantically more like automation than note data, + /* 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. */ - add_channel_command_menu_item (automation_items, _("Program Change"), MidiPgmChangeAutomation, 0); add_channel_command_menu_item (automation_items, _("Bender"), MidiPitchBenderAutomation, 0); add_channel_command_menu_item (automation_items, _("Pressure"), MidiChannelPressureAutomation, 0); @@ -579,7 +591,8 @@ MidiTimeAxisView::build_controller_menu () } } - /* loop over all 127 MIDI controllers, in groups of 16 */ + /* loop over all 127 MIDI controllers, in groups of 16; except don't offer + bank select controllers, as they are handled by the `patch' code */ for (int i = 0; i < 127; i += 16) { @@ -591,6 +604,10 @@ MidiTimeAxisView::build_controller_menu () for (int ctl = i; ctl < i+16; ++ctl) { + if (ctl == MIDI_CTL_MSB_BANK || ctl == MIDI_CTL_LSB_BANK) { + continue; + } + if (chn_cnt > 1) { /* multiple channels - create a submenu, with 1 item per channel */ @@ -806,32 +823,36 @@ MidiTimeAxisView::show_existing_automation () void MidiTimeAxisView::create_automation_child (const Evoral::Parameter& param, bool show) { - /* These controllers are region "automation", so we do not create - * an AutomationList/Line for the track */ - if (param.type() == NullAutomation) { cerr << "WARNING: Attempt to create NullAutomation child, ignoring" << endl; return; } - + AutomationTracks::iterator existing = _automation_tracks.find (param); if (existing != _automation_tracks.end()) { return; } - - boost::shared_ptr c = _route->get_control (param); - - assert(c); - - boost::shared_ptr track(new AutomationTimeAxisView (_session, - _route, boost::shared_ptr(), c, - _editor, - *this, - true, - parent_canvas, - _route->describe_parameter(param))); - - add_automation_child (param, track, show); + + if (param.type() == GainAutomation) { + create_gain_automation_child (param, show); + } else { + + /* These controllers are region "automation", so we do not create + * an AutomationList/Line for the track */ + + boost::shared_ptr c = _route->get_control (param); + assert (c); + + boost::shared_ptr track(new AutomationTimeAxisView (_session, + _route, boost::shared_ptr(), c, + _editor, + *this, + true, + parent_canvas, + _route->describe_parameter(param))); + + add_automation_child (param, track, show); + } } @@ -969,7 +990,7 @@ MidiTimeAxisView::set_channel_mode (ChannelMode, uint16_t) no_redraw = false; - /* TODO: Bender, PgmChange, Pressure */ + /* TODO: Bender, Pressure */ /* invalidate the controller menu, so that we rebuilt it next time */ _controller_menu_map.clear (); @@ -1003,18 +1024,15 @@ MidiTimeAxisView::automation_child_menu_item (Evoral::Parameter param) } boost::shared_ptr -MidiTimeAxisView::add_region (framepos_t pos) +MidiTimeAxisView::add_region (framepos_t pos, framecnt_t length, bool commit) { Editor* real_editor = dynamic_cast (&_editor); real_editor->begin_reversible_command (_("create region")); - playlist()->clear_history (); + playlist()->clear_changes (); real_editor->snap_to (pos, 0); - const Meter& m = _session->tempo_map().meter_at(pos); - const Tempo& t = _session->tempo_map().tempo_at(pos); - double length = floor (m.frames_per_bar(t, _session->frame_rate())); - + boost::shared_ptr src = _session->create_midi_source_for_session (view()->trackview().track().get(), view()->trackview().track()->name()); PropertyList plist; @@ -1028,7 +1046,9 @@ MidiTimeAxisView::add_region (framepos_t pos) playlist()->add_region (region, pos); _session->add_command (new StatefulDiffCommand (playlist())); - real_editor->commit_reversible_command(); + if (commit) { + real_editor->commit_reversible_command (); + } return boost::dynamic_pointer_cast(region); }