Add a method for obtaining the frame position of beat/whatever zero
[ardour.git] / libs / ardour / automatable.cc
index dfc7be417ab06ac36899112ff083531f7002deb3..462f4f29748065fcce4bcfb4ecb39237e86245f9 100644 (file)
 #include "ardour/plugin_insert.h"
 #include "ardour/record_enable_control.h"
 #include "ardour/session.h"
+#ifdef LV2_SUPPORT
 #include "ardour/uri_map.h"
+#endif
 #include "ardour/value_as_string.h"
 
-#include "i18n.h"
+#include "pbd/i18n.h"
 
 using namespace std;
 using namespace ARDOUR;
@@ -186,6 +188,8 @@ Automatable::describe_parameter (Evoral::Parameter param)
                return string_compose("Bender [%1]", int(param.channel()) + 1);
        } else if (param.type() == MidiChannelPressureAutomation) {
                return string_compose("Pressure [%1]", int(param.channel()) + 1);
+       } else if (param.type() == MidiNotePressureAutomation) {
+               return string_compose("PolyPressure [%1]", int(param.channel()) + 1);
 #ifdef LV2_SUPPORT
        } else if (param.type() == PluginPropertyAutomation) {
                return string_compose("Property %1", URIMap::instance().id_to_uri(param.id()));
@@ -276,7 +280,7 @@ Automatable::get_automation_xml_state ()
 
        for (Controls::iterator li = controls().begin(); li != controls().end(); ++li) {
                boost::shared_ptr<AutomationList> l = boost::dynamic_pointer_cast<AutomationList>(li->second->list());
-               if (l && !l->empty()) {
+               if (l) {
                        node->add_child_nocopy (l->get_state ());
                }
        }
@@ -504,6 +508,21 @@ Automatable::control_factory(const Evoral::Parameter& param)
        return boost::shared_ptr<Evoral::Control>(control);
 }
 
+boost::shared_ptr<AutomationControl>
+Automatable::automation_control (PBD::ID const & id) const
+{
+       Controls::const_iterator li;
+
+       for (li = _controls.begin(); li != _controls.end(); ++li) {
+               boost::shared_ptr<AutomationControl> ac = boost::dynamic_pointer_cast<AutomationControl> (li->second);
+               if (ac && (ac->id() == id)) {
+                       return ac;
+               }
+       }
+
+       return boost::shared_ptr<AutomationControl>();
+}
+
 boost::shared_ptr<AutomationControl>
 Automatable::automation_control (const Evoral::Parameter& id, bool create)
 {
@@ -544,6 +563,13 @@ Automatable::find_next_event (double now, double end, Evoral::ControlEvent& next
                        continue;
                }
 
+               boost::shared_ptr<SlavableAutomationControl> sc
+                       = boost::dynamic_pointer_cast<SlavableAutomationControl>(li->second);
+
+               if (sc) {
+                       sc->find_next_event (now, end, next_event);
+               }
+
                Evoral::ControlList::const_iterator i;
                boost::shared_ptr<const Evoral::ControlList> alist (li->second->list());
                Evoral::ControlEvent cp (now, 0.0f);