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/parameter_descriptor.h"
26 #include "ardour/route.h"
27 #include "ardour/session.h"
32 using namespace ARDOUR;
36 Route::set_control (AutomationType type, double val, PBD::Controllable::GroupControlDisposition group_override)
38 boost::shared_ptr<RouteList> rl;
42 /* route must mediate group control */
43 set_gain (val, group_override);
47 /* route must mediate group control */
48 set_trim (val, group_override);
51 case RecEnableAutomation:
52 /* session must mediate group control */
53 rl.reset (new RouteList);
54 rl->push_back (shared_from_this());
55 _session.set_record_enabled (rl, val >= 0.5 ? true : false, Session::rt_cleanup, group_override);
59 /* session must mediate group control */
60 rl.reset (new RouteList);
61 rl->push_back (shared_from_this());
62 if (Config->get_solo_control_is_listen_control()) {
63 _session.set_listen (rl, val >= 0.5 ? true : false, Session::rt_cleanup, group_override);
65 _session.set_solo (rl, val >= 0.5 ? true : false, Session::rt_cleanup, group_override);
70 /* session must mediate group control */
71 rl.reset (new RouteList);
72 rl->push_back (shared_from_this());
73 _session.set_mute (rl, val >= 0.5 ? true : false, Session::rt_cleanup, group_override);
78 /* Not a route automation control */
79 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;
86 Route::RouteAutomationControl::RouteAutomationControl (const std::string& name,
88 boost::shared_ptr<AutomationList> alist,
89 boost::shared_ptr<Route> r)
90 : AutomationControl (r->session(), Evoral::Parameter (atype),
91 ParameterDescriptor (Evoral::Parameter (atype)),
97 Route::GainControllable::GainControllable (Session& s, AutomationType atype, boost::shared_ptr<Route> r)
98 : GainControl (s, Evoral::Parameter(atype))
104 Route::SoloControllable::SoloControllable (std::string name, boost::shared_ptr<Route> r)
105 : RouteAutomationControl (name, SoloAutomation, boost::shared_ptr<AutomationList>(), r)
107 boost::shared_ptr<AutomationList> gl(new AutomationList(Evoral::Parameter(SoloAutomation)));
108 gl->set_interpolation(Evoral::ControlList::Discrete);
113 Route::SoloControllable::set_value (double val, PBD::Controllable::GroupControlDisposition group_override)
116 _set_value (val, group_override);
121 Route::SoloControllable::_set_value (double val, PBD::Controllable::GroupControlDisposition group_override)
123 boost::shared_ptr<Route> r = _route.lock ();
127 r->set_control (SoloAutomation, val, group_override);
131 Route::SoloControllable::set_value_unchecked (double val)
133 /* Used only by automation playback */
135 _set_value (val, Controllable::NoGroup);
139 Route::SoloControllable::get_value () const
141 boost::shared_ptr<Route> r = _route.lock ();
146 if (Config->get_solo_control_is_listen_control()) {
147 return r->listening_via_monitor() ? GAIN_COEFF_UNITY : GAIN_COEFF_ZERO;
149 return r->self_soloed() ? GAIN_COEFF_UNITY : GAIN_COEFF_ZERO;
153 Route::MuteControllable::MuteControllable (std::string name, boost::shared_ptr<Route> r)
154 : RouteAutomationControl (name, MuteAutomation, boost::shared_ptr<AutomationList>(), r)
157 boost::shared_ptr<AutomationList> gl(new AutomationList(Evoral::Parameter(MuteAutomation)));
158 gl->set_interpolation(Evoral::ControlList::Discrete);
163 Route::MuteControllable::set_superficial_value(bool muted)
165 /* Note we can not use AutomationControl::set_value here since it will emit
166 Changed(), but the value will not be correct to the observer. */
168 const bool to_list = _list && ((AutomationList*)_list.get ())->automation_write ();
169 const double where = _session.audible_frame ();
171 /* Note that we really need this:
172 * if (as == Touch && _list->in_new_write_pass ()) {
173 * alist->start_write_pass (_session.audible_frame ());
175 * here in the case of the user calling from a GUI or whatever.
176 * Without the ability to distinguish between user and
177 * automation-initiated changes, we lose the "touch mute"
178 * behaviour we have in AutomationController::toggled ().
180 _list->set_in_write_pass (true, false, where);
183 Control::set_double (muted, where, to_list);
187 Route::MuteControllable::set_value (double val, PBD::Controllable::GroupControlDisposition group_override)
190 _set_value (val, group_override);
195 Route::MuteControllable::set_value_unchecked (double val)
197 /* used only automation playback */
198 _set_value (val, Controllable::NoGroup);
202 Route::MuteControllable::_set_value (double val, Controllable::GroupControlDisposition group_override)
204 boost::shared_ptr<Route> r = _route.lock ();
210 if (_list && ((AutomationList*)_list.get())->automation_playback()) {
211 // Set superficial/automation value to drive controller (and possibly record)
212 const bool bval = ((val >= 0.5) ? true : false);
213 set_superficial_value (bval);
214 // Playing back automation, set route mute directly
215 r->set_mute (bval, Controllable::NoGroup);
217 r->set_control (MuteAutomation, val, group_override);
222 Route::MuteControllable::get_value () const
224 if (_list && ((AutomationList*)_list.get())->automation_playback()) {
225 // Playing back automation, get the value from the list
226 return AutomationControl::get_value();
229 // Not playing back automation, get the actual route mute value
230 boost::shared_ptr<Route> r = _route.lock ();
231 return (r && r->muted()) ? GAIN_COEFF_UNITY : GAIN_COEFF_ZERO;
234 Route::PhaseControllable::PhaseControllable (std::string name, boost::shared_ptr<Route> r)
235 : RouteAutomationControl (name, PhaseAutomation, boost::shared_ptr<AutomationList>(), r)
238 boost::shared_ptr<AutomationList> gl(new AutomationList(Evoral::Parameter(PhaseAutomation)));
239 gl->set_interpolation(Evoral::ControlList::Discrete);
244 Route::PhaseControllable::set_value (double v, PBD::Controllable::GroupControlDisposition /* group_override */)
246 boost::shared_ptr<Route> r = _route.lock ();
247 if (r->phase_invert().size()) {
248 if (v == 0 || (v < 1 && v > 0.9) ) {
249 r->set_phase_invert (_current_phase, false);
251 r->set_phase_invert (_current_phase, true);
257 Route::PhaseControllable::get_value () const
259 boost::shared_ptr<Route> r = _route.lock ();
263 return (double) r->phase_invert (_current_phase);
267 Route::PhaseControllable::set_channel (uint32_t c)
273 Route::PhaseControllable::channel () const
275 return _current_phase;
278 Route::SoloIsolateControllable::SoloIsolateControllable (std::string name, boost::shared_ptr<Route> r)
279 : RouteAutomationControl (name, SoloIsolateAutomation, boost::shared_ptr<AutomationList>(), r)
281 boost::shared_ptr<AutomationList> gl(new AutomationList(Evoral::Parameter(SoloIsolateAutomation)));
282 gl->set_interpolation(Evoral::ControlList::Discrete);
288 Route::SoloIsolateControllable::get_value () const
290 boost::shared_ptr<Route> r = _route.lock ();
292 return 0.0; /* "false" */
295 return r->solo_isolated() ? 1.0 : 0.0;
299 Route::SoloIsolateControllable::set_value (double val, PBD::Controllable::GroupControlDisposition gcd)
301 _set_value (val, gcd);
305 Route::SoloIsolateControllable::_set_value (double val, PBD::Controllable::GroupControlDisposition)
307 boost::shared_ptr<Route> r = _route.lock ();
312 /* no group semantics yet */
313 r->set_solo_isolated (val >= 0.5 ? true : false);
316 Route::SoloSafeControllable::SoloSafeControllable (std::string name, boost::shared_ptr<Route> r)
317 : RouteAutomationControl (name, SoloSafeAutomation, boost::shared_ptr<AutomationList>(), r)
319 boost::shared_ptr<AutomationList> gl(new AutomationList(Evoral::Parameter(SoloSafeAutomation)));
320 gl->set_interpolation(Evoral::ControlList::Discrete);
325 Route::SoloSafeControllable::set_value (double val, PBD::Controllable::GroupControlDisposition gcd)
327 _set_value (val, gcd);
331 Route::SoloSafeControllable::_set_value (double val, PBD::Controllable::GroupControlDisposition)
333 boost::shared_ptr<Route> r = _route.lock ();
338 /* no group semantics yet */
339 r->set_solo_safe (val >= 0.5 ? true : false);
343 Route::SoloSafeControllable::get_value () const
345 boost::shared_ptr<Route> r = _route.lock ();
347 return 0.0; /* "false" */
350 return r->solo_safe() ? 1.0 : 0.0;