void
AutomationStreamView::set_automation_state (AutoState state)
{
- /* XXX: not sure if this is right, but for now the automation state is basically held by
- the regions' AutomationLists. Each region is always set to have the same AutoState.
- */
+ /* Setting the automation state for this view sets the state of all regions' lists to the same thing */
if (region_views.empty()) {
_pending_automation_state = state;
// don't lock to avoid deadlock because we're triggered by
// AutomationControl::Changed() while the automation lock is taken
- switch (insert->get_parameter_automation_state (cui->parameter(), false)
+ switch (insert->get_parameter_automation_state (cui->parameter())
& (Off|Play|Touch|Write)) {
case Off:
cui->automate_button.set_label (_("Manual"));
virtual std::string describe_parameter(Evoral::Parameter param);
- AutoState get_parameter_automation_state (Evoral::Parameter param, bool lock = true);
+ AutoState get_parameter_automation_state (Evoral::Parameter param);
virtual void set_parameter_automation_state (Evoral::Parameter param, AutoState);
AutoStyle get_parameter_automation_style (Evoral::Parameter param);
int set_automation_state (const XMLNode&, Evoral::Parameter default_param);
XMLNode& get_automation_state();
-
- /** Emitted when the automation state of one of our controls changes */
- PBD::Signal1<void, Evoral::Parameter> AutomationStateChanged;
protected:
Session& _a_session;
void can_automate(Evoral::Parameter);
- virtual void auto_state_changed (Evoral::Parameter /*which*/) {}
+ virtual void automation_list_automation_state_changed (Evoral::Parameter, AutoState) {}
int load_automation (const std::string& path);
int old_set_automation_state(const XMLNode&);
static nframes_t _automation_interval;
private:
- void automation_state_changed (Evoral::Parameter const &);
PBD::ScopedConnectionList _control_connections; ///< connections to our controls' signals
};
void set_automation_state (AutoState);
AutoState automation_state() const { return _state; }
- PBD::Signal0<void> automation_state_changed;
+ PBD::Signal1<void, AutoState> automation_state_changed;
void set_automation_style (AutoStyle m);
AutoStyle automation_style() const { return _style; }
friend class DeltaCommand;
void source_interpolation_changed (Evoral::Parameter, Evoral::ControlList::InterpolationStyle);
+ void source_automation_state_changed (Evoral::Parameter, AutoState);
void control_list_interpolation_changed (Evoral::Parameter, Evoral::ControlList::InterpolationStyle);
+ void automation_list_automation_state_changed (Evoral::Parameter, AutoState);
PBD::ScopedConnectionList _midi_source_connections;
void copy_interpolation_from (boost::shared_ptr<MidiSource>);
void copy_interpolation_from (MidiSource *);
+ AutoState automation_state_of (Evoral::Parameter) const;
+ void set_automation_state_of (Evoral::Parameter, AutoState);
+ void copy_automation_state_from (boost::shared_ptr<MidiSource>);
+ void copy_automation_state_from (MidiSource *);
+
/** Emitted when a different MidiModel is set */
PBD::Signal0<void> ModelChanged;
/** Emitted when a parameter's interpolation style is changed */
PBD::Signal2<void, Evoral::Parameter, Evoral::ControlList::InterpolationStyle> InterpolationChanged;
+ /** Emitted when a parameter's automation state is changed */
+ PBD::Signal2<void, Evoral::Parameter, AutoState> AutomationStateChanged;
protected:
virtual void flush_midi() = 0;
*/
typedef std::map<Evoral::Parameter, Evoral::ControlList::InterpolationStyle> InterpolationStyleMap;
InterpolationStyleMap _interpolation_style;
+
+ /** Map of automation states to use for Parameters; if they are not in this map,
+ * the correct automation state is Off.
+ */
+ typedef std::map<Evoral::Parameter, AutoState> AutomationStateMap;
+ AutomationStateMap _automation_state;
};
}
void connect_and_run (BufferSet& bufs, nframes_t nframes, nframes_t offset, bool with_auto, nframes_t now = 0);
void set_automatable ();
- void auto_state_changed (Evoral::Parameter which);
+ void control_list_automation_state_changed (Evoral::Parameter, AutoState);
void set_parameter_state (const XMLNode& node, int version);
void set_parameter_state_2X (const XMLNode& node, int version);
{
Evoral::Parameter param = ac->parameter();
- ControlSet::add_control(ac);
- _can_automate_list.insert(param);
- auto_state_changed(param); // sync everything up
-
- /* connect to automation_state_changed so that we can emit a signal when one of our controls'
- automation state changes
- */
- boost::shared_ptr<AutomationControl> c = boost::dynamic_pointer_cast<AutomationControl> (ac);
- if (c) {
- c->alist()->automation_state_changed.connect_same_thread (
- _control_connections, boost::bind (&Automatable::automation_state_changed, this, c->parameter())
- );
- }
+ boost::shared_ptr<AutomationList> al = boost::dynamic_pointer_cast<AutomationList> (ac->list ());
+ assert (al);
+
+ al->automation_state_changed.connect_same_thread (
+ _list_connections, boost::bind (&Automatable::automation_list_automation_state_changed, this, ac->parameter(), _1)
+ );
+
+ ControlSet::add_control (ac);
+ _can_automate_list.insert (param);
+
+ automation_list_automation_state_changed (param, al->automation_state ()); // sync everything up
}
void
}
AutoState
-Automatable::get_parameter_automation_state (Evoral::Parameter param, bool lock)
+Automatable::get_parameter_automation_state (Evoral::Parameter param)
{
AutoState result = Off;
- if (lock)
- control_lock().lock();
-
boost::shared_ptr<Evoral::Control> c = control(param);
boost::shared_ptr<AutomationList> l = boost::dynamic_pointer_cast<AutomationList>(c->list());
- if (c)
+ if (c) {
result = l->automation_state();
-
- if (lock)
- control_lock().unlock();
+ }
return result;
}
return boost::dynamic_pointer_cast<const AutomationControl>(Evoral::ControlSet::control(id));
}
-void
-Automatable::automation_state_changed (Evoral::Parameter const & p)
-{
- AutomationStateChanged (p); /* EMIT SIGNAL */
-}
-
void
Automatable::clear_controls ()
{
_control_connections.drop_connections ();
ControlSet::clear_controls ();
}
-
{
if (s != _state) {
_state = s;
- automation_state_changed (); /* EMIT SIGNAL */
+ automation_state_changed (s); /* EMIT SIGNAL */
}
}
_midi_source->InterpolationChanged.connect_same_thread (
_midi_source_connections, boost::bind (&MidiModel::source_interpolation_changed, this, _1, _2)
);
+
+ _midi_source->AutomationStateChanged.connect_same_thread (
+ _midi_source_connections, boost::bind (&MidiModel::source_automation_state_changed, this, _1, _2)
+ );
}
/** The source has signalled that the interpolation style for a parameter has changed. In order to
* keep MidiSource and ControlList interpolation state the same, we pass this change onto the
* appropriate ControlList.
*
- * The idea is that MidiSource and the MidiModel's ControlList states are kept in sync, and the
- * MidiSource's InterpolationChanged signal is listened to by the GUI.
+ * The idea is that MidiSource and the MidiModel's ControlList states are kept in sync, and one
+ * or the other is listened to by the GUI.
*/
void
MidiModel::source_interpolation_changed (Evoral::Parameter p, Evoral::ControlList::InterpolationStyle s)
_midi_source->set_interpolation_of (p, s);
}
+void
+MidiModel::source_automation_state_changed (Evoral::Parameter p, AutoState s)
+{
+ Glib::Mutex::Lock lm (_control_lock);
+ boost::shared_ptr<AutomationList> al = boost::dynamic_pointer_cast<AutomationList> (control(p)->list ());
+ al->set_automation_state (s);
+}
+
+void
+MidiModel::automation_list_automation_state_changed (Evoral::Parameter p, AutoState s)
+{
+ _midi_source->set_automation_state_of (p, s);
+}
+
boost::shared_ptr<Evoral::Control>
MidiModel::control_factory (Evoral::Parameter const & p)
{
boost::shared_ptr<Evoral::Control> c = Automatable::control_factory (p);
- /* Set up newly created control's lists to the appropriate interpolation state
- from our source.
+ /* Set up newly created control's lists to the appropriate interpolation and
+ automation state from our source.
*/
assert (_midi_source);
c->list()->set_interpolation (_midi_source->interpolation_of (p));
+ boost::shared_ptr<AutomationList> al = boost::dynamic_pointer_cast<AutomationList> (c->list ());
+ assert (al);
+
+ al->set_automation_state (_midi_source->automation_state_of (p));
+
return c;
}
}
/* watch for changes to controls' AutoState */
- model()->AutomationStateChanged.connect_same_thread (
+ midi_source()->AutomationStateChanged.connect_same_thread (
_model_connection, boost::bind (&MidiRegion::model_automation_state_changed, this, _1)
);
}
child->add_property (X_("parameter"), EventTypeMap::instance().to_symbol (i->first));
child->add_property (X_("style"), enum_2_string (i->second));
}
-
+
+ for (AutomationStateMap::const_iterator i = _automation_state.begin(); i != _automation_state.end(); ++i) {
+ XMLNode* child = node.add_child (X_("AutomationState"));
+ child->add_property (X_("parameter"), EventTypeMap::instance().to_symbol (i->first));
+ child->add_property (X_("state"), enum_2_string (i->second));
+ }
+
return node;
}
Evoral::ControlList::InterpolationStyle s = static_cast<Evoral::ControlList::InterpolationStyle> (string_2_enum (prop->value(), s));
set_interpolation_of (p, s);
+
+ } else if ((*i)->name() == X_("AutomationState")) {
+
+ XMLProperty* prop;
+
+ if ((prop = (*i)->property (X_("parameter"))) == 0) {
+ error << _("Missing parameter property on AutomationState") << endmsg;
+ return -1;
+ }
+
+ Evoral::Parameter p = EventTypeMap::instance().new_parameter (prop->value());
+
+ if ((prop = (*i)->property (X_("state"))) == 0) {
+ error << _("Missing state property on AutomationState") << endmsg;
+ return -1;
+ }
+
+ AutoState s = static_cast<AutoState> (string_2_enum (prop->value(), s));
+ set_automation_state_of (p, s);
}
}
newsrc->set_timeline_position(_timeline_position);
newsrc->copy_interpolation_from (this);
+ newsrc->copy_automation_state_from (this);
if (_model) {
if (begin == Evoral::MinMusicalTime && end == Evoral::MaxMusicalTime) {
return i->second;
}
+AutoState
+MidiSource::automation_state_of (Evoral::Parameter p) const
+{
+ AutomationStateMap::const_iterator i = _automation_state.find (p);
+ if (i == _automation_state.end()) {
+ return Off;
+ }
+
+ return i->second;
+}
+
/** Set interpolation style to be used for a given parameter. This change will be
* propagated to anyone who needs to know.
*/
InterpolationChanged (p, s); /* EMIT SIGNAL */
}
+void
+MidiSource::set_automation_state_of (Evoral::Parameter p, AutoState s)
+{
+ if (automation_state_of (p) == s) {
+ return;
+ }
+
+ if (s == Off) {
+ /* automation state is being set to the default, so we don't need a note in our map */
+ _automation_state.erase (p);
+ } else {
+ _automation_state[p] = s;
+ }
+
+ AutomationStateChanged (p, s); /* EMIT SIGNAL */
+}
+
void
MidiSource::copy_interpolation_from (boost::shared_ptr<MidiSource> s)
{
copy_interpolation_from (s.get ());
}
+void
+MidiSource::copy_automation_state_from (boost::shared_ptr<MidiSource> s)
+{
+ copy_automation_state_from (s.get ());
+}
+
void
MidiSource::copy_interpolation_from (MidiSource* s)
{
/* XXX: should probably emit signals here */
}
+
+void
+MidiSource::copy_automation_state_from (MidiSource* s)
+{
+ _automation_state = s->_automation_state;
+
+ /* XXX: should probably emit signals here */
+}
}
void
-PluginInsert::auto_state_changed (Evoral::Parameter which)
+PluginInsert::control_list_automation_state_changed (Evoral::Parameter which, AutoState s)
{
if (which.type() != PluginAutomation)
return;
boost::shared_ptr<AutomationControl> c
= boost::dynamic_pointer_cast<AutomationControl>(control (which));
- if (c && ((AutomationList*)c->list().get())->automation_state() != Off) {
+ if (c && s != Off) {
_plugins[0]->set_parameter (which.id(), c->list()->eval (_session.transport_frame()));
}
}
mutable Glib::Mutex _control_lock;
Controls _controls;
+ PBD::ScopedConnectionList _list_connections;
+
private:
PBD::ScopedConnectionList _control_connections;
- PBD::ScopedConnectionList _list_connections;
};