2008-09-18 20:47:49 -04:00
|
|
|
/* This file is part of Evoral.
|
2011-04-06 11:00:16 -04:00
|
|
|
* Copyright (C) 2008 David Robillard <http://drobilla.net>
|
2008-09-18 20:47:49 -04:00
|
|
|
* Copyright (C) 2000-2008 Paul Davis
|
2009-10-14 12:10:01 -04:00
|
|
|
*
|
2008-09-18 20:47:49 -04: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 12:10:01 -04:00
|
|
|
*
|
2008-09-18 20:47:49 -04: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 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.,
|
|
|
|
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <iostream>
|
2008-12-21 15:36:15 -05:00
|
|
|
#include "evoral/Control.hpp"
|
|
|
|
#include "evoral/ControlList.hpp"
|
2008-09-18 20:47:49 -04:00
|
|
|
|
|
|
|
namespace Evoral {
|
|
|
|
|
2008-09-19 02:30:49 -04:00
|
|
|
Parameter::TypeMetadata Parameter::_type_metadata;
|
|
|
|
|
2008-09-21 12:17:02 -04:00
|
|
|
Control::Control(const Parameter& parameter, boost::shared_ptr<ControlList> list)
|
|
|
|
: _parameter(parameter)
|
|
|
|
, _user_value(list ? list->default_value() : parameter.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
|
2010-07-27 10:09:16 -04:00
|
|
|
Control::set_double (double value, bool to_list, double frame)
|
2008-09-18 20:47:49 -04:00
|
|
|
{
|
|
|
|
_user_value = value;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-02-06 21:48:07 -05:00
|
|
|
if (to_list) {
|
2010-07-27 10:09:16 -04:00
|
|
|
_list->add (frame, value);
|
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 ();
|
|
|
|
|
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
|
|
|
|
|