git-svn-id: svn://localhost/ardour2/branches/3.0@11972 d708f5d6-7413-0410-9779-e7cbd77b26cf
140 lines
3.1 KiB
C++
140 lines
3.1 KiB
C++
/*
|
|
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>
|
|
|
|
#include "ardour/automation_control.h"
|
|
|
|
#include "controls.h"
|
|
#include "types.h"
|
|
#include "surface.h"
|
|
#include "control_group.h"
|
|
#include "button.h"
|
|
#include "led.h"
|
|
#include "pot.h"
|
|
#include "fader.h"
|
|
#include "jog.h"
|
|
#include "meter.h"
|
|
|
|
|
|
using namespace Mackie;
|
|
using namespace std;
|
|
using ARDOUR::AutomationControl;
|
|
|
|
void Group::add (Control& control)
|
|
{
|
|
_controls.push_back (&control);
|
|
}
|
|
|
|
Control::Control (int id, std::string name, Group & group)
|
|
: _id (id)
|
|
, _name (name)
|
|
, _group (group)
|
|
, _in_use (false)
|
|
{
|
|
}
|
|
|
|
/** @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
|
|
{
|
|
return _in_use;
|
|
}
|
|
|
|
void
|
|
Control::set_in_use (bool in_use)
|
|
{
|
|
_in_use = in_use;
|
|
}
|
|
|
|
ostream & Mackie::operator << (ostream & os, const 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 << " }";
|
|
|
|
return os;
|
|
}
|
|
|
|
void
|
|
Control::set_normal_control (boost::shared_ptr<AutomationControl> ac)
|
|
{
|
|
normal_ac = ac;
|
|
}
|
|
|
|
void
|
|
Control::set_modified_control (boost::shared_ptr<AutomationControl> ac)
|
|
{
|
|
modified_ac = ac;
|
|
}
|
|
|
|
void
|
|
Control::set_value (float val, bool modified)
|
|
{
|
|
if (modified && modified_ac) {
|
|
modified_ac->set_value (modified_ac->interface_to_internal (val));
|
|
} else if (normal_ac) {
|
|
normal_ac->set_value (normal_ac->interface_to_internal (val));
|
|
}
|
|
}
|
|
|
|
float
|
|
Control::get_value (bool modified)
|
|
{
|
|
if (modified && modified_ac) {
|
|
return modified_ac->internal_to_interface (modified_ac->get_value());
|
|
} else if (normal_ac) {
|
|
return normal_ac->internal_to_interface (normal_ac->get_value());
|
|
}
|
|
|
|
return 0.0;
|
|
}
|
|
|
|
void
|
|
Control::start_touch (double when, bool modified)
|
|
{
|
|
if (modified && modified_ac) {
|
|
return modified_ac->start_touch (when);
|
|
} else if (normal_ac) {
|
|
return normal_ac->start_touch (when);
|
|
}
|
|
}
|
|
|
|
void
|
|
Control::stop_touch (double when, bool mark, bool modified)
|
|
{
|
|
if (modified && modified_ac) {
|
|
return modified_ac->stop_touch (when, mark);
|
|
} else if (normal_ac) {
|
|
return normal_ac->stop_touch (when, mark);
|
|
}
|
|
}
|
|
|