2 Copyright (C) 2000 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #include "libardour-config.h"
24 #include "ardour/automation_control.h"
25 #include "ardour/route.h"
26 #include "ardour/session.h"
31 using namespace ARDOUR;
35 Route::set_control (AutomationType type, double val, PBD::Controllable::GroupControlDisposition group_override)
37 boost::shared_ptr<RouteList> rl;
41 /* route must mediate group control */
42 set_gain (val, group_override);
47 /* route must mediate group control */
48 set_trim (val, group_override);
52 case RecEnableAutomation:
53 /* session must mediate group control */
54 rl.reset (new RouteList);
55 rl->push_back (shared_from_this());
56 _session.set_record_enabled (rl, val >= 0.5 ? true : false, Session::rt_cleanup, group_override);
61 /* session must mediate group control */
62 rl.reset (new RouteList);
63 rl->push_back (shared_from_this());
64 if (Config->get_solo_control_is_listen_control()) {
65 _session.set_listen (rl, val >= 0.5 ? true : false, Session::rt_cleanup, group_override);
67 _session.set_solo (rl, val >= 0.5 ? true : false);
74 /* session must mediate group control */
75 rl.reset (new RouteList);
76 rl->push_back (shared_from_this());
77 _session.set_mute (rl, !muted(), Session::rt_cleanup, group_override);
82 /* Not a route automation control */
83 fatal << string_compose (_("programming error: %1%2\n"), X_("illegal type of route automation control passed to Route::set_control(): "), enum_2_string(type)) << endmsg;
90 Route::RouteAutomationControl::RouteAutomationControl (const std::string& name,
92 boost::shared_ptr<AutomationList> alist,
93 boost::shared_ptr<Route> r)
94 : AutomationControl (r->session(), Evoral::Parameter (atype),
95 ParameterDescriptor (Evoral::Parameter (atype)),
101 Route::GainControllable::GainControllable (Session& s, AutomationType atype, boost::shared_ptr<Route> r)
102 : GainControl (s, Evoral::Parameter(atype))
108 Route::SoloControllable::SoloControllable (std::string name, boost::shared_ptr<Route> r)
109 : RouteAutomationControl (name, SoloAutomation, boost::shared_ptr<AutomationList>(), r)
111 boost::shared_ptr<AutomationList> gl(new AutomationList(Evoral::Parameter(SoloAutomation)));
112 gl->set_interpolation(Evoral::ControlList::Discrete);
117 Route::SoloControllable::set_value (double val, PBD::Controllable::GroupControlDisposition group_override)
120 _set_value (val, group_override);
125 Route::SoloControllable::_set_value (double val, PBD::Controllable::GroupControlDisposition group_override)
127 const bool bval = ((val >= 0.5) ? true : false);
129 boost::shared_ptr<RouteList> rl (new RouteList);
131 boost::shared_ptr<Route> r = _route.lock ();
138 if (Config->get_solo_control_is_listen_control()) {
139 _session.set_listen (rl, bval, Session::rt_cleanup, group_override);
141 _session.set_solo (rl, bval, Session::rt_cleanup, group_override);
146 Route::SoloControllable::set_value_unchecked (double val)
148 /* Used only by automation playback */
150 _set_value (val, Controllable::NoGroup);
154 Route::SoloControllable::get_value () const
156 boost::shared_ptr<Route> r = _route.lock ();
161 if (Config->get_solo_control_is_listen_control()) {
162 return r->listening_via_monitor() ? GAIN_COEFF_UNITY : GAIN_COEFF_ZERO;
164 return r->self_soloed() ? GAIN_COEFF_UNITY : GAIN_COEFF_ZERO;
168 Route::MuteControllable::MuteControllable (std::string name, boost::shared_ptr<Route> r)
169 : RouteAutomationControl (name, MuteAutomation, boost::shared_ptr<AutomationList>(), r)
172 boost::shared_ptr<AutomationList> gl(new AutomationList(Evoral::Parameter(MuteAutomation)));
173 gl->set_interpolation(Evoral::ControlList::Discrete);
178 Route::MuteControllable::set_superficial_value(bool muted)
180 /* Note we can not use AutomationControl::set_value here since it will emit
181 Changed(), but the value will not be correct to the observer. */
183 const bool to_list = _list && ((AutomationList*)_list.get ())->automation_write ();
184 const double where = _session.audible_frame ();
186 /* Note that we really need this:
187 * if (as == Touch && _list->in_new_write_pass ()) {
188 * alist->start_write_pass (_session.audible_frame ());
190 * here in the case of the user calling from a GUI or whatever.
191 * Without the ability to distinguish between user and
192 * automation-initiated changes, we lose the "touch mute"
193 * behaviour we have in AutomationController::toggled ().
195 _list->set_in_write_pass (true, false, where);
198 Control::set_double (muted, where, to_list);
202 Route::MuteControllable::set_value (double val, PBD::Controllable::GroupControlDisposition group_override)
205 _set_value (val, group_override);
210 Route::MuteControllable::set_value_unchecked (double val)
212 /* used only automation playback */
213 _set_value (val, Controllable::NoGroup);
217 Route::MuteControllable::_set_value (double val, Controllable::GroupControlDisposition group_override)
219 const bool bval = ((val >= 0.5) ? true : false);
221 boost::shared_ptr<Route> r = _route.lock ();
226 if (_list && ((AutomationList*)_list.get())->automation_playback()) {
227 // Set superficial/automation value to drive controller (and possibly record)
228 set_superficial_value (bval);
229 // Playing back automation, set route mute directly
230 r->set_mute (bval, Controllable::NoGroup);
232 // Set from user, queue mute event
233 boost::shared_ptr<RouteList> rl (new RouteList);
235 _session.set_mute (rl, bval, Session::rt_cleanup, group_override);
240 Route::MuteControllable::get_value () const
242 if (_list && ((AutomationList*)_list.get())->automation_playback()) {
243 // Playing back automation, get the value from the list
244 return AutomationControl::get_value();
247 // Not playing back automation, get the actual route mute value
248 boost::shared_ptr<Route> r = _route.lock ();
249 return (r && r->muted()) ? GAIN_COEFF_UNITY : GAIN_COEFF_ZERO;
252 Route::PhaseControllable::PhaseControllable (std::string name, boost::shared_ptr<Route> r)
253 : RouteAutomationControl (name, PhaseAutomation, boost::shared_ptr<AutomationList>(), r)
255 boost::shared_ptr<AutomationList> gl(new AutomationList(Evoral::Parameter(PhaseAutomation)));
256 gl->set_interpolation(Evoral::ControlList::Discrete);
261 Route::PhaseControllable::set_value (double v, PBD::Controllable::GroupControlDisposition /* group_override */)
263 boost::shared_ptr<Route> r = _route.lock ();
264 if (r->phase_invert().size()) {
265 if (v == 0 || (v < 1 && v > 0.9) ) {
266 r->set_phase_invert (_current_phase, false);
268 r->set_phase_invert (_current_phase, true);
274 Route::PhaseControllable::get_value () const
276 boost::shared_ptr<Route> r = _route.lock ();
277 return (double) r->phase_invert (_current_phase);
281 Route::PhaseControllable::set_channel (uint32_t c)
287 Route::PhaseControllable::channel () const
289 return _current_phase;