2012-04-08 10:11:00 -04:00
|
|
|
/*
|
2008-06-02 17:41:35 -04:00
|
|
|
Copyright (C) 2006,2007 John Anderson
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
#include <iomanip>
|
|
|
|
#include <sstream>
|
|
|
|
|
2012-04-12 17:02:43 -04:00
|
|
|
#include "ardour/automation_control.h"
|
|
|
|
|
2012-04-08 10:11:00 -04:00
|
|
|
#include "controls.h"
|
|
|
|
#include "types.h"
|
|
|
|
#include "surface.h"
|
2012-04-09 09:59:35 -04:00
|
|
|
#include "control_group.h"
|
|
|
|
#include "button.h"
|
|
|
|
#include "led.h"
|
|
|
|
#include "pot.h"
|
|
|
|
#include "fader.h"
|
|
|
|
#include "jog.h"
|
|
|
|
#include "meter.h"
|
|
|
|
|
2012-04-08 10:11:00 -04:00
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
using namespace std;
|
2015-04-15 20:37:20 -04:00
|
|
|
using namespace ArdourSurface;
|
|
|
|
using namespace Mackie;
|
|
|
|
|
2012-04-12 17:02:43 -04:00
|
|
|
using ARDOUR::AutomationControl;
|
2008-06-02 17:41:35 -04:00
|
|
|
|
2012-04-08 10:11:00 -04:00
|
|
|
void Group::add (Control& control)
|
2008-06-02 17:41:35 -04:00
|
|
|
{
|
2012-04-08 10:11:00 -04:00
|
|
|
_controls.push_back (&control);
|
2008-06-02 17:41:35 -04:00
|
|
|
}
|
|
|
|
|
2012-04-10 10:27:44 -04:00
|
|
|
Control::Control (int id, std::string name, Group & group)
|
2012-04-08 10:11:00 -04:00
|
|
|
: _id (id)
|
|
|
|
, _name (name)
|
|
|
|
, _group (group)
|
|
|
|
, _in_use (false)
|
2008-12-12 17:55:03 -05:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-05-04 05:22:32 -04:00
|
|
|
/** @return true if the control is in use, or false otherwise.
|
|
|
|
Buttons are `in use' when they are held down.
|
|
|
|
Faders with touch support are `in use' when they are being touched.
|
|
|
|
Pots, or faders without touch support, are `in use' from the first move
|
|
|
|
event until a timeout after the last move event.
|
|
|
|
*/
|
|
|
|
bool
|
|
|
|
Control::in_use () const
|
2008-12-12 17:55:03 -05:00
|
|
|
{
|
|
|
|
return _in_use;
|
|
|
|
}
|
|
|
|
|
2011-05-04 05:22:32 -04:00
|
|
|
void
|
|
|
|
Control::set_in_use (bool in_use)
|
2008-12-12 17:55:03 -05:00
|
|
|
{
|
2011-05-04 05:22:32 -04:00
|
|
|
_in_use = in_use;
|
2008-12-12 17:55:03 -05:00
|
|
|
}
|
|
|
|
|
2012-04-12 17:02:43 -04:00
|
|
|
void
|
2012-04-16 15:05:27 -04:00
|
|
|
Control::set_control (boost::shared_ptr<AutomationControl> ac)
|
2012-04-12 17:02:43 -04:00
|
|
|
{
|
|
|
|
normal_ac = ac;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-04-16 15:05:27 -04:00
|
|
|
Control::set_value (float val)
|
2012-04-12 17:02:43 -04:00
|
|
|
{
|
2012-04-21 22:15:24 -04:00
|
|
|
if (normal_ac) {
|
|
|
|
normal_ac->set_value (normal_ac->interface_to_internal (val));
|
|
|
|
}
|
2012-04-12 17:02:43 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
float
|
2012-04-16 15:05:27 -04:00
|
|
|
Control::get_value ()
|
2012-04-12 17:02:43 -04:00
|
|
|
{
|
2012-04-21 22:15:24 -04:00
|
|
|
if (!normal_ac) {
|
|
|
|
return 0.0f;
|
|
|
|
}
|
2012-04-16 15:05:27 -04:00
|
|
|
return normal_ac->internal_to_interface (normal_ac->get_value());
|
2012-04-12 17:02:43 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-04-16 15:05:27 -04:00
|
|
|
Control::start_touch (double when)
|
2012-04-12 17:02:43 -04:00
|
|
|
{
|
2012-04-21 22:15:24 -04:00
|
|
|
if (normal_ac) {
|
|
|
|
return normal_ac->start_touch (when);
|
|
|
|
}
|
2012-04-12 17:02:43 -04:00
|
|
|
}
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2012-04-12 17:02:43 -04:00
|
|
|
void
|
2014-11-23 14:01:46 -05:00
|
|
|
Control::stop_touch (bool mark, double when)
|
2012-04-12 17:02:43 -04:00
|
|
|
{
|
2012-04-21 22:15:24 -04:00
|
|
|
if (normal_ac) {
|
2014-11-25 02:11:44 -05:00
|
|
|
return normal_ac->stop_touch (mark, when);
|
2012-04-21 22:15:24 -04:00
|
|
|
}
|
2012-04-12 17:02:43 -04:00
|
|
|
}
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2015-04-15 20:37:20 -04:00
|
|
|
ostream & operator << (ostream & os, const ArdourSurface::Mackie::Control & control)
|
|
|
|
{
|
|
|
|
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 << " }";
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2015-04-15 20:37:20 -04:00
|
|
|
return os;
|
|
|
|
}
|
|
|
|
|