2008-09-18 20:47:49 -04:00
|
|
|
/* This file is part of Evoral.
|
|
|
|
* Copyright (C) 2008 Dave Robillard <http://drobilla.net>
|
|
|
|
* Copyright (C) 2000-2008 Paul Davis
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* 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)
|
|
|
|
, _list(list)
|
|
|
|
, _user_value(list ? list->default_value() : parameter.normal())
|
2008-09-18 20:47:49 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** Get the currently effective value (ie the one that corresponds to current output)
|
|
|
|
*/
|
|
|
|
float
|
2008-10-12 22:43:14 -04:00
|
|
|
Control::get_float(bool from_list, FrameTime frame) const
|
2008-09-18 20:47:49 -04:00
|
|
|
{
|
|
|
|
if (from_list)
|
|
|
|
return _list->eval(frame);
|
|
|
|
else
|
|
|
|
return _user_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2008-10-12 22:43:14 -04:00
|
|
|
Control::set_float(float value, bool to_list, FrameTime frame)
|
2008-09-18 20:47:49 -04:00
|
|
|
{
|
|
|
|
_user_value = value;
|
|
|
|
|
|
|
|
if (to_list)
|
|
|
|
_list->add(frame, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** Get the latest user-set value, which may not equal get_value() when automation
|
|
|
|
* is playing back, etc.
|
|
|
|
*
|
|
|
|
* Automation write/touch works by periodically sampling this value and adding it
|
|
|
|
* to the AutomationList.
|
|
|
|
*/
|
|
|
|
float
|
2008-09-28 17:20:43 -04:00
|
|
|
Control::user_float() const
|
2008-09-18 20:47:49 -04:00
|
|
|
{
|
|
|
|
return _user_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
Control::set_list(boost::shared_ptr<ControlList> list)
|
|
|
|
{
|
|
|
|
_list = list;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace Evoral
|
|
|
|
|