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/io_processor.h>
27 #include <ardour/audioregion.h>
28 #include <ardour/audiosource.h>
29 #include <ardour/route_group_specialized.h>
30 #include <ardour/processor.h>
31 #include <ardour/audioplaylist.h>
32 #include <ardour/panner.h>
33 #include <ardour/utils.h>
38 using namespace ARDOUR;
41 Track::Track (Session& sess, string name, Route::Flag flag, TrackMode mode, DataType default_type)
42 : Route (sess, name, 1, -1, -1, -1, flag, default_type)
43 , _rec_enable_control (new RecEnableControllable(*this))
46 _freeze_record.state = NoFreeze;
47 _saved_meter_point = _meter_point;
51 Track::Track (Session& sess, const XMLNode& node, DataType default_type)
53 , _rec_enable_control (new RecEnableControllable(*this))
55 _freeze_record.state = NoFreeze;
57 _saved_meter_point = _meter_point;
65 Track::set_meter_point (MeterPoint p, void *src)
67 Route::set_meter_point (p, src);
77 Track::get_template ()
83 Track::toggle_monitor_input ()
85 for (PortSet::iterator i = _inputs.begin(); i != _inputs.end(); ++i) {
86 i->ensure_monitor_input(!i->monitoring_input());
91 Track::update_total_latency ()
93 nframes_t old = _own_latency;
96 _own_latency = _user_latency;
100 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
101 if ((*i)->active ()) {
102 _own_latency += (*i)->signal_latency ();
107 set_port_latency (_own_latency);
109 if (old != _own_latency) {
110 signal_latency_changed (); /* EMIT SIGNAL */
116 Track::FreezeRecord::~FreezeRecord ()
118 for (vector<FreezeRecordProcessorInfo*>::iterator i = processor_info.begin(); i != processor_info.end(); ++i) {
124 Track::freeze_state() const
126 return _freeze_record.state;
129 Track::RecEnableControllable::RecEnableControllable (Track& s)
130 : Controllable (X_("recenable")), track (s)
135 Track::RecEnableControllable::set_value (float val)
137 bool bval = ((val >= 0.5f) ? true: false);
138 track.set_record_enable (bval, this);
142 Track::RecEnableControllable::get_value (void) const
144 if (track.record_enabled()) { return 1.0f; }
149 Track::record_enabled () const
151 return _diskstream->record_enabled ();
157 bool will_record = true;
158 for (PortSet::iterator i = _inputs.begin(); i != _inputs.end() && will_record; ++i) {
167 Track::set_record_enable (bool yn, void *src)
169 if (_freeze_record.state == Frozen) {
173 if (_mix_group && src != _mix_group && _mix_group->is_active()) {
174 _mix_group->apply (&Track::set_record_enable, yn, _mix_group);
178 /* keep track of the meter point as it was before we rec-enabled */
179 if (!_diskstream->record_enabled()) {
180 _saved_meter_point = _meter_point;
183 _diskstream->set_record_enabled (yn);
185 if (_diskstream->record_enabled()) {
186 set_meter_point (MeterInput, this);
188 set_meter_point (_saved_meter_point, this);
191 _rec_enable_control->Changed ();
196 Track::set_name (const string& str)
200 if (record_enabled() && _session.actively_recording()) {
201 /* this messes things up if done while recording */
205 if (_diskstream->set_name (str)) {
209 /* save state so that the statefile fully reflects any filename changes */
211 if ((ret = IO::set_name (str)) == 0) {
212 _session.save_state ("");
219 Track::set_latency_delay (nframes_t longest_session_latency)
221 Route::set_latency_delay (longest_session_latency);
222 _diskstream->set_roll_delay (_roll_delay);