#include <iomanip>
#include <sstream>
+#include "ardour/automation_control.h"
+
#include "controls.h"
#include "types.h"
-#include "mackie_midi_builder.h"
#include "surface.h"
#include "control_group.h"
-
#include "button.h"
#include "led.h"
-#include "ledring.h"
#include "pot.h"
#include "fader.h"
#include "jog.h"
#include "meter.h"
-using namespace Mackie;
using namespace std;
+using namespace ArdourSurface;
+using namespace Mackie;
+
+using ARDOUR::AutomationControl;
void Group::add (Control& control)
{
_controls.push_back (&control);
}
-Control::Control (int id, int ordinal, std::string name, Group & group)
+Control::Control (int id, std::string name, Group & group)
: _id (id)
- , _ordinal (ordinal)
, _name (name)
, _group (group)
, _in_use (false)
_in_use = in_use;
}
-ostream & Mackie::operator << (ostream & os, const Mackie::Control & control)
+void
+Control::set_control (boost::shared_ptr<AutomationControl> ac)
{
- os << typeid (control).name();
- os << " { ";
- os << "name: " << control.name();
- os << ", ";
- os << "id: " << "0x" << setw(4) << setfill('0') << hex << control.id() << setfill(' ');
- os << ", ";
- os << "type: " << "0x" << setw(2) << setfill('0') << hex << control.type() << setfill(' ');
- os << ", ";
- os << "raw_id: " << "0x" << setw(2) << setfill('0') << hex << control.raw_id() << setfill(' ');
- os << ", ";
- os << "ordinal: " << dec << control.ordinal();
- os << ", ";
- os << "group: " << control.group().name();
- os << " }";
-
- return os;
+ normal_ac = ac;
}
-Control*
-Button::factory (Surface& surface, int id, int ordinal, const char* name, Group& group)
+void
+Control::set_value (float val)
{
- Button* b = new Button (id, ordinal, name, group);
- surface.buttons[id] = b;
- surface.controls.push_back (b);
- group.add (*b);
- return b;
+ if (normal_ac) {
+ normal_ac->set_value (normal_ac->interface_to_internal (val), PBD::Controllable::NoGroup);
+ }
}
-Control*
-Fader::factory (Surface& surface, int id, int ordinal, const char* name, Group& group)
+float
+Control::get_value ()
{
- Fader* f = new Fader (id, ordinal, name, group);
- surface.faders[id] = f;
- surface.controls.push_back (f);
- group.add (*f);
- return f;
+ if (!normal_ac) {
+ return 0.0f;
+ }
+ return normal_ac->internal_to_interface (normal_ac->get_value());
}
-Control*
-Pot::factory (Surface& surface, int id, int ordinal, const char* name, Group& group)
+void
+Control::start_touch (double when)
{
- Pot* p = new Pot (id, ordinal, name, group);
- surface.pots[id] = p;
- surface.controls.push_back (p);
- group.add (*p);
- return p;
+ if (normal_ac) {
+ return normal_ac->start_touch (when);
+ }
}
-Control*
-Led::factory (Surface& surface, int id, int ordinal, const char* name, Group& group)
+void
+Control::stop_touch (bool mark, double when)
{
- Led* l = new Led (id, ordinal, name, group);
- surface.leds[id] = l;
- surface.controls.push_back (l);
- group.add (*l);
- return l;
+ if (normal_ac) {
+ return normal_ac->stop_touch (mark, when);
+ }
}
-Control*
-Jog::factory (Surface& surface, int id, int ordinal, const char* name, Group& group)
+ostream & operator << (ostream & os, const ArdourSurface::Mackie::Control & control)
{
- Jog* j = new Jog (id, ordinal, name, group);
- surface.controls.push_back (j);
- surface.controls_by_name["jog"] = j;
- group.add (*j);
- return j;
+ os << typeid (control).name();
+ os << " { ";
+ os << "name: " << control.name();
+ os << ", ";
+ os << "id: " << "0x" << setw(2) << setfill('0') << hex << control.id() << setfill(' ');
+ os << ", ";
+ os << "group: " << control.group().name();
+ os << " }";
+
+ return os;
}