ARDOUR_UI::TransportControllable::TransportControllable (std::string name, ARDOUR_UI& u, ToggleType tp)
- : Controllable (name), ui (u), type(tp)
+ : Controllable (name, string() /* missing URI */), ui (u), type(tp)
{
}
const Evoral::Parameter& parameter,
boost::shared_ptr<ARDOUR::AutomationList> list,
const string& name)
- : Controllable((name != "") ? name : EventTypeMap::instance().to_symbol(parameter))
+ : Controllable((name != "") ? name : EventTypeMap::instance().to_symbol(parameter), string("") /* XXX missing URI */)
, Evoral::Control(parameter, list)
, _session(session)
{
}
Track::RecEnableControllable::RecEnableControllable (Track& s)
- : Controllable (X_("recenable")), track (s)
+ : Controllable (X_("recenable"), string() /* XXX missing URI */), track (s)
{
}
#include "i18n.h"
using namespace PBD;
+using namespace std;
sigc::signal<void,Controllable*> Controllable::Destroyed;
sigc::signal<bool,Controllable*> Controllable::StartLearning;
Controllable::Controllables Controllable::registry;
Controllable::ControllablesByURI Controllable::registry_by_uri;
-Controllable::Controllable (const std::string& name, const std::string& uri)
+Controllable::Controllable (const string& name, const string& uri)
: _name (name)
, _uri (uri)
, _touching (false)
void
Controllable::add ()
{
- Glib::RWLock::WriterLock lm (*registry_lock);
+ Glib::RWLock::WriterLock lm (registry_lock);
registry.insert (this);
if (!_uri.empty()) {
void
Controllable::remove ()
{
- Glib::RWLock::WriterLock lm (*registry_lock);
+ Glib::RWLock::WriterLock lm (registry_lock);
for (Controllables::iterator i = registry.begin(); i != registry.end(); ++i) {
if ((*i) == this) {
}
}
- if (_uri) {
+ if (!_uri.empty()) {
ControllablesByURI::iterator i = registry_by_uri.find (_uri);
if (i != registry_by_uri.end()) {
registry_by_uri.erase (i);
}
void
-Controllable::set_uri (const std::string& new_uri)
+Controllable::set_uri (const string& new_uri)
{
- Glib::RWLock::WriterLock lm (*registry_lock);
+ Glib::RWLock::WriterLock lm (registry_lock);
- if (_uri) {
+ if (!_uri.empty()) {
ControllablesByURI::iterator i = registry_by_uri.find (_uri);
if (i != registry_by_uri.end()) {
registry_by_uri.erase (i);
Controllable*
Controllable::by_id (const ID& id)
{
- Glib::RWLock::ReaderLock lm (*registry_lock);
+ Glib::RWLock::ReaderLock lm (registry_lock);
for (Controllables::iterator i = registry.begin(); i != registry.end(); ++i) {
if ((*i)->id() == id) {
Controllable*
Controllable::by_uri (const string& uri)
{
- Glib::RWLock::ReaderLock lm (*registry_lock);
+ Glib::RWLock::ReaderLock lm (registry_lock);
ControllablesByURI::iterator i;
- if ((i = registry_by_ui.find (uri)) != registry_by_uri.end()) {
+ if ((i = registry_by_uri.find (uri)) != registry_by_uri.end()) {
return i->second;
}
return 0;
}
Controllable*
-Controllable::by_name (const std::string& str)
+Controllable::by_name (const string& str)
{
- Glib::RWLock::ReaderLock lm (*registry_lock);
+ Glib::RWLock::ReaderLock lm (registry_lock);
for (Controllables::iterator i = registry.begin(); i != registry.end(); ++i) {
if ((*i)->_name == str) {
#include <string>
#include <set>
+#include <map>
#include <sigc++/trackable.h>
#include <sigc++/signal.h>
+#include <glibmm/thread.h>
#include "pbd/statefuldestructible.h"
class Controllable : public PBD::StatefulDestructible {
public:
- Controllable (std::string name, const std::string& uri);
+ Controllable (const std::string& name, const std::string& uri);
virtual ~Controllable() { Destroyed (this); }
void set_uri (const std::string&);
class IgnorableControllable : public Controllable
{
public:
- IgnorableControllable () : PBD::Controllable ("ignoreMe") {}
- ~IgnorableControllable () {}
+ IgnorableControllable () : PBD::Controllable ("ignoreMe", std::string()) {}
+ ~IgnorableControllable () {}
- void set_value (float /*v*/) {}
- float get_value () const { return 0.0; }
+ void set_value (float /*v*/) {}
+ float get_value () const { return 0.0; }
};
}
for (MIDIControllables::iterator i = controllables.begin(); i != controllables.end(); ) {
tmp = i;
++tmp;
- if (&(*i)->get_controllable() == c) {
+ if ((*i)->get_controllable() == c) {
delete (*i);
controllables.erase (i);
}
for (MIDIPendingControllables::iterator i = pending_controllables.begin(); i != pending_controllables.end(); ) {
ptmp = i;
++ptmp;
- if (&((*i).first)->get_controllable() == c) {
+ if (((*i).first)->get_controllable() == c) {
(*i).second.disconnect();
delete (*i).first;
pending_controllables.erase (i);
MIDIControllable* mc = 0;
for (MIDIControllables::iterator i = controllables.begin(); i != controllables.end(); ++i) {
- if ((*i)->get_controllable().id() == c->id()) {
+ if ((*i)->get_controllable()->id() == c->id()) {
mc = *i;
break;
}
*/
for (MIDIPendingControllables::iterator i = pending_controllables.begin(); i != pending_controllables.end(); ++i) {
- if (&((*i).first)->get_controllable() == c) {
+ if (((*i).first)->get_controllable() == c) {
(*i).first->stop_learning ();
dptr = (*i).first;
(*i).second.disconnect();
for (MIDIControllables::iterator iter = controllables.begin(); iter != controllables.end(); ++iter) {
MIDIControllable* existingBinding = (*iter);
- if (control == &(existingBinding->get_controllable())) {
+ if (control == (existingBinding->get_controllable())) {
delete existingBinding;
controllables.erase (iter);
}
#include "midicontrollable.h"
using namespace sigc;
+using namespace std;
using namespace MIDI;
using namespace PBD;
using namespace ARDOUR;
MIDIControllable::MIDIControllable (Port& p, const string& c, bool is_bistate)
- : controllable (0), _port (p), bistate (is_bistate)
+ : controllable (0), _current_uri (c), _port (p), bistate (is_bistate)
{
init ();
}
void
MIDIControllable::reacquire_controllable ()
{
- _controllable = Controllable::controllable_by_uri (current_uri);
+ if (!_current_uri.empty()) {
+ controllable = Controllable::by_uri (_current_uri);
+ } else {
+ controllable = 0;
+ }
}
void
{
float control_min = 0.0f;
float control_max = 1.0f;
- ARDOUR::AutomationControl* ac = dynamic_cast<ARDOUR::AutomationControl*>(&controllable);
+ ARDOUR::AutomationControl* ac = dynamic_cast<ARDOUR::AutomationControl*>(controllable);
if (ac) {
control_min = ac->parameter().min();
control_max = ac->parameter().max();
{
float control_min = 0.0f;
float control_max = 1.0f;
- ARDOUR::AutomationControl* ac = dynamic_cast<ARDOUR::AutomationControl*>(&controllable);
+ ARDOUR::AutomationControl* ac = dynamic_cast<ARDOUR::AutomationControl*>(controllable);
if (ac) {
control_min = ac->parameter().min();
control_max = ac->parameter().max();
*/
if (msg->note_number == control_additional) {
- controllable.set_value (is_on ? 1 : 0);
+ controllable->set_value (is_on ? 1 : 0);
}
}
XMLNode&
MIDIControllable::get_state ()
{
- if (!controllable) {
- return XXX !what!;
- }
-
char buf[32];
- XMLNode& node (controllable->get_state ());
- snprintf (buf, sizeof(buf), "0x%x", (int) control_type);
- node.add_property ("event", buf);
- snprintf (buf, sizeof(buf), "%d", (int) control_channel);
- node.add_property ("channel", buf);
- snprintf (buf, sizeof(buf), "0x%x", (int) control_additional);
- node.add_property ("additional", buf);
- node.add_property ("feedback", (feedback ? "yes" : "no"));
+ XMLNode* node = new XMLNode ("MIDIControllable");
+
+ if (controllable) {
+ node->add_property ("uri", controllable->uri());
+ snprintf (buf, sizeof(buf), "0x%x", (int) control_type);
+ node->add_property ("event", buf);
+ snprintf (buf, sizeof(buf), "%d", (int) control_channel);
+ node->add_property ("channel", buf);
+ snprintf (buf, sizeof(buf), "0x%x", (int) control_additional);
+ node->add_property ("additional", buf);
+ node->add_property ("feedback", (feedback ? "yes" : "no"));
+ }
- return node;
+ return *node;
}
std::string _control_description;
bool feedback;
+ void init ();
void reacquire_controllable ();
void midi_receiver (MIDI::Parser &p, MIDI::byte *, size_t);