diff --git a/gtk2_ardour/editor_routes.cc b/gtk2_ardour/editor_routes.cc index 9e27c7725e..a8fbb58d32 100644 --- a/gtk2_ardour/editor_routes.cc +++ b/gtk2_ardour/editor_routes.cc @@ -87,11 +87,29 @@ EditorRoutes::EditorRoutes (Editor* e) rec_state_column->add_attribute(rec_col_renderer->property_state(), _columns.rec_state); rec_state_column->add_attribute(rec_col_renderer->property_visible(), _columns.is_track); + rec_state_column->set_sizing(TREE_VIEW_COLUMN_FIXED); rec_state_column->set_alignment(ALIGN_CENTER); rec_state_column->set_expand(false); rec_state_column->set_fixed_width(15); + // MIDI Input Active + + CellRendererPixbufMulti* input_active_col_renderer = manage (new CellRendererPixbufMulti()); + input_active_col_renderer->set_pixbuf (0, ::get_icon("midi_socket_small")); + input_active_col_renderer->set_pixbuf (1, ::get_icon("midi_socket_small")); + input_active_col_renderer->signal_changed().connect (sigc::mem_fun (*this, &EditorRoutes::on_input_active_changed)); + + TreeViewColumn* input_active_column = manage (new TreeViewColumn ("I", *input_active_col_renderer)); + + input_active_column->add_attribute(input_active_col_renderer->property_state(), _columns.is_input_active); + input_active_column->add_attribute (input_active_col_renderer->property_visible(), _columns.is_midi); + + input_active_column->set_sizing(TREE_VIEW_COLUMN_FIXED); + input_active_column->set_alignment(ALIGN_CENTER); + input_active_column->set_expand(false); + input_active_column->set_fixed_width(20); + // Mute enable toggle CellRendererPixbufMulti* mute_col_renderer = manage (new CellRendererPixbufMulti()); @@ -153,16 +171,15 @@ EditorRoutes::EditorRoutes (Editor* e) solo_safe_state_column->set_expand(false); solo_safe_state_column->set_fixed_width(22); + _display.append_column (*input_active_column); _display.append_column (*rec_state_column); _display.append_column (*mute_state_column); _display.append_column (*solo_state_column); _display.append_column (*solo_isolate_state_column); _display.append_column (*solo_safe_state_column); - int colnum = _display.append_column (_("Name"), _columns.text); - TreeViewColumn* c = _display.get_column (colnum-1); - c->set_data ("i_am_the_tab_column", (void*) 0xfeedface); - _display.append_column (_("V"), _columns.visible); + _name_column = _display.append_column (_("Name"), _columns.text) - 1; + _visible_column = _display.append_column (_("V"), _columns.visible) - 1; _display.set_headers_visible (true); _display.set_name ("TrackListDisplay"); @@ -173,12 +190,12 @@ EditorRoutes::EditorRoutes (Editor* e) _display.set_size_request (100, -1); _display.add_object_drag (_columns.route.index(), "routes"); - CellRendererText* name_cell = dynamic_cast (_display.get_column_cell_renderer (5)); + CellRendererText* name_cell = dynamic_cast (_display.get_column_cell_renderer (_name_column)); assert (name_cell); name_cell->signal_editing_started().connect (sigc::mem_fun (*this, &EditorRoutes::name_edit_started)); - TreeViewColumn* name_column = _display.get_column (5); + TreeViewColumn* name_column = _display.get_column (_name_column); assert (name_column); @@ -191,13 +208,13 @@ EditorRoutes::EditorRoutes (Editor* e) name_cell->signal_edited().connect (sigc::mem_fun (*this, &EditorRoutes::name_edit)); // Set the visible column cell renderer to radio toggle - CellRendererToggle* visible_cell = dynamic_cast (_display.get_column_cell_renderer (6)); + CellRendererToggle* visible_cell = dynamic_cast (_display.get_column_cell_renderer (_visible_column)); visible_cell->property_activatable() = true; visible_cell->property_radio() = false; visible_cell->signal_toggled().connect (sigc::mem_fun (*this, &EditorRoutes::visible_changed)); - TreeViewColumn* visible_col = dynamic_cast (_display.get_column (6)); + TreeViewColumn* visible_col = dynamic_cast (_display.get_column (_visible_column)); visible_col->set_expand(false); visible_col->set_sizing(TREE_VIEW_COLUMN_FIXED); visible_col->set_fixed_width(30); @@ -291,6 +308,24 @@ EditorRoutes::set_session (Session* s) } } +void +EditorRoutes::on_input_active_changed (std::string const & path_string) +{ + // Get the model row that has been toggled. + Gtk::TreeModel::Row row = *_model->get_iter (Gtk::TreeModel::Path (path_string)); + + TimeAxisView* tv = row[_columns.tv]; + RouteTimeAxisView *rtv = dynamic_cast (tv); + + if (rtv) { + boost::shared_ptr mt; + mt = rtv->midi_track(); + if (mt) { + mt->set_input_active (!mt->input_active()); + } + } +} + void EditorRoutes::on_tv_rec_enable_changed (std::string const & path_string) { @@ -517,6 +552,8 @@ EditorRoutes::routes_added (list routes) for (list::iterator x = routes.begin(); x != routes.end(); ++x) { + boost::shared_ptr midi_trk = boost::dynamic_pointer_cast ((*x)->route()); + row = *(_model->append ()); row[_columns.text] = (*x)->route()->name(); @@ -524,6 +561,15 @@ EditorRoutes::routes_added (list routes) row[_columns.tv] = *x; row[_columns.route] = (*x)->route (); row[_columns.is_track] = (boost::dynamic_pointer_cast ((*x)->route()) != 0); + + if (midi_trk) { + row[_columns.is_input_active] = midi_trk->input_active (); + row[_columns.is_midi] = true; + } else { + row[_columns.is_input_active] = false; + row[_columns.is_midi] = false; + } + row[_columns.mute_state] = (*x)->route()->muted(); row[_columns.solo_state] = RouteUI::solo_visual_state ((*x)->route()); row[_columns.solo_isolate_state] = (*x)->route()->solo_isolated(); @@ -552,6 +598,7 @@ EditorRoutes::routes_added (list routes) if ((*x)->is_midi_track()) { boost::shared_ptr t = boost::dynamic_pointer_cast ((*x)->route()); t->StepEditStatusChange.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_rec_display, this), gui_context()); + t->InputActiveChanged.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_input_active_display, this), gui_context()); } (*x)->route()->mute_changed.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_mute_display, this), gui_context()); @@ -566,6 +613,7 @@ EditorRoutes::routes_added (list routes) update_solo_display (true); update_solo_isolate_display (); update_solo_safe_display (); + update_input_active_display (); resume_redisplay (); _redisplay_does_not_sync_order_keys = false; } @@ -911,7 +959,7 @@ EditorRoutes::key_press (GdkEventKey* ev) name_editable = 0; } - col = _display.get_column (5); // select&focus on name column + col = _display.get_column (_name_column); // select&focus on name column if (Keyboard::modifier_state_equals (ev->state, Keyboard::TertiaryModifier)) { treeview_select_previous (_display, _model, col); @@ -1235,6 +1283,25 @@ EditorRoutes::move_selected_tracks (bool up) _session->sync_order_keys (N_ ("editor")); } +void +EditorRoutes::update_input_active_display () +{ + TreeModel::Children rows = _model->children(); + TreeModel::Children::iterator i; + + for (i = rows.begin(); i != rows.end(); ++i) { + boost::shared_ptr route = (*i)[_columns.route]; + + if (boost::dynamic_pointer_cast (route)) { + boost::shared_ptr mt = boost::dynamic_pointer_cast (route); + + if (mt) { + (*i)[_columns.is_input_active] = mt->input_active(); + } + } + } +} + void EditorRoutes::update_rec_display () { diff --git a/gtk2_ardour/editor_routes.h b/gtk2_ardour/editor_routes.h index c6105bb7be..2ade937eff 100644 --- a/gtk2_ardour/editor_routes.h +++ b/gtk2_ardour/editor_routes.h @@ -59,6 +59,7 @@ public: private: void initial_display (); + void on_input_active_changed (std::string const &); void on_tv_rec_enable_changed (std::string const &); void on_tv_mute_enable_toggled (std::string const &); void on_tv_solo_enable_toggled (std::string const &); @@ -77,6 +78,7 @@ private: void update_solo_display (bool); void update_solo_isolate_display (); void update_solo_safe_display (); + void update_input_active_display (); void set_all_tracks_visibility (bool); void set_all_audio_midi_visibility (int, bool); void show_all_routes (); @@ -111,9 +113,11 @@ private: add (tv); add (route); add (name_editable); + add (is_input_active); + add (is_midi); } - Gtk::TreeModelColumn text; + Gtk::TreeModelColumn text; Gtk::TreeModelColumn visible; Gtk::TreeModelColumn rec_state; Gtk::TreeModelColumn mute_state; @@ -124,12 +128,16 @@ private: Gtk::TreeModelColumn tv; Gtk::TreeModelColumn > route; Gtk::TreeModelColumn name_editable; + Gtk::TreeModelColumn is_input_active; + Gtk::TreeModelColumn is_midi; }; Gtk::ScrolledWindow _scroller; Gtkmm2ext::DnDTreeView > _display; Glib::RefPtr _model; ModelColumns _columns; + int _name_column; + int _visible_column; bool _ignore_reorder; bool _no_redisplay; diff --git a/gtk2_ardour/icons/midi_socket_small.png b/gtk2_ardour/icons/midi_socket_small.png index 2ed5039a8c..ab495dd761 100644 Binary files a/gtk2_ardour/icons/midi_socket_small.png and b/gtk2_ardour/icons/midi_socket_small.png differ diff --git a/gtk2_ardour/mixer_strip.cc b/gtk2_ardour/mixer_strip.cc index 4211e30953..fe9ad7d1c6 100644 --- a/gtk2_ardour/mixer_strip.cc +++ b/gtk2_ardour/mixer_strip.cc @@ -409,10 +409,14 @@ MixerStrip::set_route (boost::shared_ptr rt) midi_input_enable_button->set_image (*img); midi_input_enable_button->signal_toggled().connect (sigc::mem_fun (*this, &MixerStrip::midi_input_toggled)); ARDOUR_UI::instance()->set_tip (midi_input_enable_button, _("Enable/Disable MIDI input")); + } else { + input_button_box.remove (*midi_input_enable_button); } /* get current state */ midi_input_status_changed (); input_button_box.pack_start (*midi_input_enable_button, false, false); + /* follow changes */ + midi_track()->InputActiveChanged.connect (route_connections, invalidator (*this), boost::bind (&MixerStrip::midi_input_status_changed, this), gui_context()); } else { if (midi_input_enable_button) { /* removal from the container will delete it */ @@ -1807,7 +1811,6 @@ MixerStrip::on_key_press_event (GdkEventKey* ev) break; case GDK_r: - cerr << "Stole that r\n"; rec_enable_press (&fake); return true; break; @@ -1860,7 +1863,6 @@ MixerStrip::on_key_release_event (GdkEventKey* ev) break; case GDK_r: - cerr << "Stole that r\n"; rec_enable_release (&fake); return true; break; @@ -1931,7 +1933,6 @@ MixerStrip::midi_input_status_changed () if (midi_input_enable_button) { boost::shared_ptr mt = midi_track (); assert (mt); - cerr << "track input active? " << mt->input_active() << endl; midi_input_enable_button->set_active (mt->input_active ()); } } diff --git a/icons/midi_socket.svg b/icons/midi_socket.svg index 1c59b2044d..61cf70cfe5 100644 --- a/icons/midi_socket.svg +++ b/icons/midi_socket.svg @@ -16,10 +16,10 @@ id="Layer_1" xml:space="preserve" inkscape:version="0.47 r22583" - sodipodi:docname="DIN-5c_Diagram.svg" + sodipodi:docname="midi_socket.svg" inkscape:export-filename="/tmp/DIN-5c_Diagram.png" - inkscape:export-xdpi="4.48" - inkscape:export-ydpi="4.48">image/svg+xml \ No newline at end of file diff --git a/libs/ardour/ardour/midi_track.h b/libs/ardour/ardour/midi_track.h index 5ceeefd307..15a3d3decc 100644 --- a/libs/ardour/ardour/midi_track.h +++ b/libs/ardour/ardour/midi_track.h @@ -39,6 +39,8 @@ public: MidiTrack (Session&, string name, Route::Flag f = Route::Flag (0), TrackMode m = Normal); ~MidiTrack (); + int init (); + int roll (pframes_t nframes, framepos_t start_frame, framepos_t end_frame, int declick, bool can_record, bool rec_monitors_input, bool& need_butler); @@ -129,6 +131,7 @@ protected: NoteMode _note_mode; bool _step_editing; bool _midi_thru; + bool _input_active; int no_roll (pframes_t nframes, framepos_t start_frame, framepos_t end_frame, bool state_changing, bool can_record, bool rec_monitors_input); @@ -136,6 +139,9 @@ protected: void diskstream_data_recorded (boost::shared_ptr, boost::weak_ptr); PBD::ScopedConnection _diskstream_data_recorded_connection; + + void track_input_active (IOChange, void*); + void map_input_active (bool); }; } /* namespace ARDOUR*/ diff --git a/libs/ardour/lv2_plugin_lilv.cc b/libs/ardour/lv2_plugin_lilv.cc index 6839d37c49..36b0a8e139 100644 --- a/libs/ardour/lv2_plugin_lilv.cc +++ b/libs/ardour/lv2_plugin_lilv.cc @@ -582,6 +582,7 @@ LV2Plugin::add_state(XMLNode* root) const if (_supports_persist) { // Create state directory for this plugin instance + cerr << "Create statefile name from ID " << _insert_id << endl; const std::string state_filename = _insert_id.to_s() + ".rdff"; const std::string state_path = Glib::build_filename( _session.plugins_dir(), state_filename); diff --git a/libs/ardour/midi_track.cc b/libs/ardour/midi_track.cc index 2dcee645a9..7d7b51aa7f 100644 --- a/libs/ardour/midi_track.cc +++ b/libs/ardour/midi_track.cc @@ -57,6 +57,7 @@ MidiTrack::MidiTrack (Session& sess, string name, Route::Flag flag, TrackMode mo , _note_mode(Sustained) , _step_editing (false) , _midi_thru (true) + , _input_active (true) { } @@ -64,6 +65,18 @@ MidiTrack::~MidiTrack () { } +int +MidiTrack::init () +{ + if (Track::init ()) { + return -1; + } + + _input->changed.connect_same_thread (*this, boost::bind (&MidiTrack::track_input_active, this, _1, _2)); + + return 0; +} + void MidiTrack::use_new_diskstream () { @@ -146,7 +159,11 @@ MidiTrack::_set_state (const XMLNode& node, int version, bool call_base) } if ((prop = node.property ("midi-thru")) != 0) { - set_midi_thru (prop->value() == "yes"); + set_midi_thru (string_is_affirmative (prop->value())); + } + + if ((prop = node.property ("input-active")) != 0) { + set_input_active (string_is_affirmative (prop->value())); } XMLNodeList nlist; @@ -222,6 +239,7 @@ MidiTrack::state(bool full_state) root.add_property ("step-editing", (_step_editing ? "yes" : "no")); root.add_property ("note-mode", enum_2_string (_note_mode)); root.add_property ("midi-thru", (_midi_thru ? "yes" : "no")); + root.add_property ("input-active", (_input_active ? "yes" : "no")); return root; } @@ -677,8 +695,24 @@ MidiTrack::send_silence () const return false; } +bool +MidiTrack::input_active () const +{ + return _input_active; +} + void MidiTrack::set_input_active (bool yn) +{ + if (yn != _input_active) { + _input_active = yn; + map_input_active (yn); + InputActiveChanged (); /* EMIT SIGNAL */ + } +} + +void +MidiTrack::map_input_active (bool yn) { bool changed = false; @@ -695,27 +729,13 @@ MidiTrack::set_input_active (bool yn) changed = true; } } - - if (changed) { - InputActiveChanged (); /* EMIT SIGNAL */ - } } -bool -MidiTrack::input_active () const +void +MidiTrack::track_input_active (IOChange change, void* /* src */) { - if (!_input) { - cerr << " no input\n"; - return false; - } - - if (_input->ports().count().n_midi() == 0) { - cerr << "no input MIDI ports, " << _input->ports().count() << endl; - return false; + if (change.type & IOChange::ConfigurationChanged) { + map_input_active (_input_active); } - - PortSet::iterator p = _input->ports().begin(DataType::MIDI); - MidiPort* mp = dynamic_cast (&*p); - cerr << "first port is active: " << mp->input_active() << endl; - return mp->input_active (); } + diff --git a/libs/ardour/plugin_insert.cc b/libs/ardour/plugin_insert.cc index fadf588ffe..fd8f0e3dee 100644 --- a/libs/ardour/plugin_insert.cc +++ b/libs/ardour/plugin_insert.cc @@ -70,9 +70,7 @@ PluginInsert::PluginInsert (Session& s, boost::shared_ptr plug) /* the first is the master */ if (plug) { - plug->set_insert_info (this); - _plugins.push_back (plug); - + add_plugin (plug); create_automatable_parameters (); Glib::Mutex::Lock em (_session.engine().process_lock()); @@ -884,6 +882,17 @@ PluginInsert::set_state(const XMLNode& node, int version) uint32_t count = 1; +#if 0 + // Processor::set_state() will set this, but too late + // for it to be available when setting up plugin + // state. We can't call Processor::set_state() until + // the plugins themselves are created and added. + + if ((prop = node.property ("id")) != 0) { + _id = prop->value(); + } +#endif + if (_plugins.empty()) { /* if we are adding the first plugin, we will need to set up automatable controls. @@ -903,6 +912,8 @@ PluginInsert::set_state(const XMLNode& node, int version) } } + Processor::set_state (node, version); + for (niter = nlist.begin(); niter != nlist.end(); ++niter) { /* find the node with the type-specific node name ("lv2", "ladspa", etc) @@ -921,8 +932,6 @@ PluginInsert::set_state(const XMLNode& node, int version) } } - Processor::set_state (node, version); - if (version < 3000) { /* Only 2.X sessions need a call to set_parameter_state() - in 3.X and above