2008-09-19 00:47:49 +00:00
|
|
|
/* This file is part of Evoral.
|
2011-04-06 15:00:16 +00:00
|
|
|
* Copyright (C) 2008 David Robillard <http://drobilla.net>
|
2008-09-19 00:47:49 +00:00
|
|
|
* Copyright (C) 2000-2008 Paul Davis
|
2009-10-14 16:10:01 +00:00
|
|
|
*
|
2008-09-19 00:47:49 +00:00
|
|
|
* Evoral 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.
|
2009-10-14 16:10:01 +00:00
|
|
|
*
|
2008-09-19 00:47:49 +00:00
|
|
|
* Evoral 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 details.
|
2009-10-14 16:10:01 +00:00
|
|
|
*
|
2008-09-19 00:47:49 +00:00
|
|
|
* 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.,
|
|
|
|
|
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <iostream>
|
2014-02-19 12:52:14 -05:00
|
|
|
|
2008-12-21 20:36:15 +00:00
|
|
|
#include "evoral/Control.hpp"
|
|
|
|
|
#include "evoral/ControlList.hpp"
|
2014-12-01 14:28:03 -05:00
|
|
|
#include "evoral/ParameterDescriptor.hpp"
|
|
|
|
|
#include "evoral/TypeMap.hpp"
|
2008-09-19 00:47:49 +00:00
|
|
|
|
|
|
|
|
namespace Evoral {
|
|
|
|
|
|
2014-12-01 14:28:03 -05:00
|
|
|
Control::Control(const Parameter& parameter,
|
|
|
|
|
const ParameterDescriptor& desc,
|
|
|
|
|
boost::shared_ptr<ControlList> list)
|
2008-09-21 16:17:02 +00:00
|
|
|
: _parameter(parameter)
|
2017-06-21 13:40:41 +02:00
|
|
|
, _user_value(desc.normal)
|
2008-09-19 00:47:49 +00:00
|
|
|
{
|
2010-07-12 00:41:45 +00:00
|
|
|
set_list (list);
|
2008-09-19 00:47:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Get the currently effective value (ie the one that corresponds to current output)
|
|
|
|
|
*/
|
2010-07-27 14:09:16 +00:00
|
|
|
double
|
|
|
|
|
Control::get_double (bool from_list, double frame) const
|
2008-09-19 00:47:49 +00:00
|
|
|
{
|
2010-02-07 02:48:07 +00:00
|
|
|
if (from_list) {
|
2008-09-19 00:47:49 +00:00
|
|
|
return _list->eval(frame);
|
2010-02-07 02:48:07 +00:00
|
|
|
} else {
|
2008-09-19 00:47:49 +00:00
|
|
|
return _user_value;
|
2010-02-07 02:48:07 +00:00
|
|
|
}
|
2008-09-19 00:47:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2012-07-17 03:10:40 +00:00
|
|
|
Control::set_double (double value, double frame, bool to_list)
|
2008-09-19 00:47:49 +00:00
|
|
|
{
|
|
|
|
|
_user_value = value;
|
2015-10-05 16:17:49 +02:00
|
|
|
|
2014-02-19 12:52:14 -05:00
|
|
|
/* if we're in a write pass, the automation watcher will determine the
|
|
|
|
|
values and add them to the list, so we we don't need to bother.
|
|
|
|
|
*/
|
2009-10-14 16:10:01 +00:00
|
|
|
|
2014-12-01 19:37:05 -05:00
|
|
|
if (to_list && (!_list->in_write_pass() || _list->descriptor().toggled)) {
|
2014-02-19 12:52:14 -05:00
|
|
|
_list->add (frame, value, false);
|
2010-02-07 02:48:07 +00:00
|
|
|
}
|
2008-09-19 00:47:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Control::set_list(boost::shared_ptr<ControlList> list)
|
|
|
|
|
{
|
2010-07-12 00:41:45 +00:00
|
|
|
_list_marked_dirty_connection.disconnect ();
|
2015-10-05 16:17:49 +02:00
|
|
|
|
2008-09-19 00:47:49 +00:00
|
|
|
_list = list;
|
2010-07-12 00:41:45 +00:00
|
|
|
|
|
|
|
|
if (_list) {
|
|
|
|
|
_list->Dirty.connect_same_thread (_list_marked_dirty_connection, boost::bind (&Control::list_marked_dirty, this));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Control::list_marked_dirty ()
|
|
|
|
|
{
|
|
|
|
|
ListMarkedDirty (); /* EMIT SIGNAL */
|
2008-09-19 00:47:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace Evoral
|
|
|
|
|
|