2 Copyright (C) 2006 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.
18 #include <pbd/error.h>
19 #include <sigc++/retype.h>
20 #include <sigc++/retype_return.h>
21 #include <sigc++/bind.h>
23 #include <ardour/track.h>
24 #include <ardour/diskstream.h>
25 #include <ardour/session.h>
26 #include <ardour/redirect.h>
27 #include <ardour/audioregion.h>
28 #include <ardour/audiosource.h>
29 #include <ardour/route_group_specialized.h>
30 #include <ardour/insert.h>
31 #include <ardour/audioplaylist.h>
32 #include <ardour/panner.h>
33 #include <ardour/utils.h>
34 #include <ardour/connection.h>
39 using namespace ARDOUR;
42 Track::Track (Session& sess, string name, Route::Flag flag, TrackMode mode, DataType default_type)
43 : Route (sess, name, 1, -1, -1, -1, flag, default_type)
44 , _rec_enable_control (*this)
47 _freeze_record.state = NoFreeze;
48 _saved_meter_point = _meter_point;
52 Track::Track (Session& sess, const XMLNode& node, DataType default_type)
54 _rec_enable_control (*this)
56 _freeze_record.state = NoFreeze;
58 _saved_meter_point = _meter_point;
66 Track::set_meter_point (MeterPoint p, void *src)
68 Route::set_meter_point (p, src);
78 Track::get_template ()
84 Track::toggle_monitor_input ()
86 for (vector<Port*>::iterator i = _inputs.begin(); i != _inputs.end(); ++i) {
87 (*i)->ensure_monitor_input(!(*i)->monitoring_input());
92 Track::update_total_latency ()
96 for (RedirectList::iterator i = _redirects.begin(); i != _redirects.end(); ++i) {
97 if ((*i)->active ()) {
98 _own_latency += (*i)->latency ();
102 set_port_latency (_own_latency);
108 Track::FreezeRecord::~FreezeRecord ()
110 for (vector<FreezeRecordInsertInfo*>::iterator i = insert_info.begin(); i != insert_info.end(); ++i) {
116 Track::freeze_state() const
118 return _freeze_record.state;
121 Track::RecEnableControllable::RecEnableControllable (Track& s)
122 : Controllable (X_("recenable")), track (s)
127 Track::RecEnableControllable::set_value (float val)
129 bool bval = ((val >= 0.5f) ? true: false);
130 track.set_record_enable (bval, this);
134 Track::RecEnableControllable::get_value (void) const
136 if (track.record_enabled()) { return 1.0f; }
141 Track::record_enabled () const
143 return _diskstream->record_enabled ();
149 bool will_record = true;
150 for (size_t i = 0; i < _inputs.size() && will_record; i++) {
151 if (!_inputs[i]->connected())
159 Track::set_record_enable (bool yn, void *src)
161 if (_freeze_record.state == Frozen) {
165 if (_mix_group && src != _mix_group && _mix_group->is_active()) {
166 _mix_group->apply (&Track::set_record_enable, yn, _mix_group);
170 /* keep track of the meter point as it was before we rec-enabled */
171 if (!_diskstream->record_enabled()) {
172 _saved_meter_point = _meter_point;
175 _diskstream->set_record_enabled (yn);
177 if (_diskstream->record_enabled()) {
178 set_meter_point (MeterInput, this);
180 set_meter_point (_saved_meter_point, this);
183 _rec_enable_control.Changed ();
187 Track::set_mode (TrackMode m)
192 _diskstream->set_destructive (m == Destructive);
199 Track::set_name (string str, void *src)
203 if (record_enabled() && _session.actively_recording()) {
204 /* this messes things up if done while recording */
208 if (_diskstream->set_name (str)) {
212 /* save state so that the statefile fully reflects any filename changes */
214 if ((ret = IO::set_name (str, src)) == 0) {
215 _session.save_state ("");
221 Track::set_latency_delay (nframes_t longest_session_latency)
223 Route::set_latency_delay (longest_session_latency);
224 _diskstream->set_roll_delay (_roll_delay);