2019-08-02 23:10:55 -04:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2008-2016 David Robillard <d@drobilla.net>
|
|
|
|
* Copyright (C) 2010-2014 Paul Davis <paul@linuxaudiosystems.com>
|
|
|
|
* Copyright (C) 2010 Carl Hetherington <carl@carlh.net>
|
|
|
|
* Copyright (C) 2015-2017 Robin Gareus <robin@gareus.org>
|
2009-10-14 12:10:01 -04:00
|
|
|
*
|
2019-08-02 23:10:55 -04:00
|
|
|
* 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.
|
2009-10-14 12:10:01 -04:00
|
|
|
*
|
2019-08-02 23:10:55 -04:00
|
|
|
* 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.
|
2009-10-14 12:10:01 -04:00
|
|
|
*
|
2008-09-18 20:47:49 -04: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.,
|
2019-08-02 23:10:55 -04:00
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2008-09-18 20:47:49 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <iostream>
|
2014-02-19 12:52:14 -05:00
|
|
|
|
2019-10-25 15:13:51 -04:00
|
|
|
#include "evoral/Control.h"
|
|
|
|
#include "evoral/ControlList.h"
|
|
|
|
#include "evoral/ParameterDescriptor.h"
|
|
|
|
#include "evoral/TypeMap.h"
|
2008-09-18 20:47:49 -04: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 12:17:02 -04:00
|
|
|
: _parameter(parameter)
|
2017-06-21 07:40:41 -04:00
|
|
|
, _user_value(desc.normal)
|
2008-09-18 20:47:49 -04:00
|
|
|
{
|
2010-07-11 20:41:45 -04:00
|
|
|
set_list (list);
|
2008-09-18 20:47:49 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** Get the currently effective value (ie the one that corresponds to current output)
|
|
|
|
*/
|
2010-07-27 10:09:16 -04:00
|
|
|
double
|
|
|
|
Control::get_double (bool from_list, double frame) const
|
2008-09-18 20:47:49 -04:00
|
|
|
{
|
2010-02-06 21:48:07 -05:00
|
|
|
if (from_list) {
|
2008-09-18 20:47:49 -04:00
|
|
|
return _list->eval(frame);
|
2010-02-06 21:48:07 -05:00
|
|
|
} else {
|
2008-09-18 20:47:49 -04:00
|
|
|
return _user_value;
|
2010-02-06 21:48:07 -05:00
|
|
|
}
|
2008-09-18 20:47:49 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2012-07-16 23:10:40 -04:00
|
|
|
Control::set_double (double value, double frame, bool to_list)
|
2008-09-18 20:47:49 -04:00
|
|
|
{
|
|
|
|
_user_value = value;
|
2015-10-05 10:17:49 -04: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 12:10:01 -04: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-06 21:48:07 -05:00
|
|
|
}
|
2008-09-18 20:47:49 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
Control::set_list(boost::shared_ptr<ControlList> list)
|
|
|
|
{
|
2010-07-11 20:41:45 -04:00
|
|
|
_list_marked_dirty_connection.disconnect ();
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2008-09-18 20:47:49 -04:00
|
|
|
_list = list;
|
2010-07-11 20:41:45 -04: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-18 20:47:49 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace Evoral
|
|
|
|
|