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.
19 #ifndef __ardour_track_h__
20 #define __ardour_track_h__
22 #include <boost/shared_ptr.hpp>
24 #include "pbd/enum_convert.h"
26 #include "ardour/interthread_info.h"
27 #include "ardour/recordable.h"
28 #include "ardour/route.h"
42 class RecordEnableControl;
43 class RecordSafeControl;
45 /** A track is an route (bus) with a recordable diskstream and
46 * related objects relevant to recording, playback and editing.
48 * Specifically a track has a playlist object that describes material
49 * to be played from disk, and modifies that object during recording and
52 class LIBARDOUR_API Track : public Route, public Recordable
55 Track (Session&, std::string name, PresentationInfo::Flag f = PresentationInfo::Flag (0), TrackMode m = Normal, DataType default_type = DataType::AUDIO);
60 bool set_name (const std::string& str);
61 void resync_track_name ();
63 TrackMode mode () const { return _mode; }
65 boost::shared_ptr<MonitorControl> monitoring_control() const { return _monitoring_control; }
67 MonitorState monitoring_state () const;
68 MeterState metering_state () const;
70 bool set_processor_state (XMLNode const & node, XMLProperty const* prop, ProcessorList& new_order, bool& must_configure);
72 virtual int no_roll (pframes_t nframes, samplepos_t start_sample, samplepos_t end_sample,
75 virtual int roll (pframes_t nframes, samplepos_t start_sample, samplepos_t end_sample,
76 int declick, bool& need_butler) = 0;
78 bool needs_butler() const { return _needs_butler; }
82 void set_latency_compensation (samplecnt_t);
83 void update_latency_information ();
90 FreezeState freeze_state() const;
92 virtual void freeze_me (InterThreadInfo&) = 0;
93 virtual void unfreeze () = 0;
95 /** Test if the track can be bounced with the given settings.
96 * If sends/inserts/returns are present in the signal path or the given track
97 * has no audio outputs bouncing is not possible.
99 * @param endpoint the processor to tap the signal off (or nil for the top)
100 * @param include_endpoint include the given processor in the bounced audio.
101 * @return true if the track can be bounced, or false otherwise.
103 virtual bool bounceable (boost::shared_ptr<Processor> endpoint, bool include_endpoint) const = 0;
105 /** bounce track from session start to session end to new region
107 * @param itt asynchronous progress report and cancel
108 * @return a new audio region (or nil in case of error)
110 virtual boost::shared_ptr<Region> bounce (InterThreadInfo& itt) = 0;
112 /** Bounce the given range to a new audio region.
113 * @param start start time (in samples)
114 * @param end end time (in samples)
115 * @param itt asynchronous progress report and cancel
116 * @param endpoint the processor to tap the signal off (or nil for the top)
117 * @param include_endpoint include the given processor in the bounced audio.
118 * @return a new audio region (or nil in case of error)
120 virtual boost::shared_ptr<Region> bounce_range (samplepos_t start, samplepos_t end, InterThreadInfo& itt,
121 boost::shared_ptr<Processor> endpoint, bool include_endpoint) = 0;
122 virtual int export_stuff (BufferSet& bufs, samplepos_t start_sample, samplecnt_t nframes,
123 boost::shared_ptr<Processor> endpoint, bool include_endpoint, bool for_export, bool for_freeze) = 0;
125 XMLNode& get_state();
126 XMLNode& get_template();
127 virtual int set_state (const XMLNode&, int version);
128 static void zero_diskstream_id_in_xml (XMLNode&);
130 boost::shared_ptr<AutomationControl> rec_enable_control() const { return _record_enable_control; }
131 boost::shared_ptr<AutomationControl> rec_safe_control() const { return _record_safe_control; }
133 int prep_record_enabled (bool);
134 bool can_be_record_enabled ();
135 bool can_be_record_safe ();
137 void use_captured_sources (SourceList&, CaptureInfos const &);
139 void set_block_size (pframes_t);
141 boost::shared_ptr<Playlist> playlist ();
142 void request_input_monitoring (bool);
143 void ensure_input_monitoring (bool);
144 bool destructive () const;
145 std::list<boost::shared_ptr<Source> > & last_capture_sources ();
146 std::string steal_write_source_name ();
147 void reset_write_sources (bool, bool force = false);
148 float playback_buffer_load () const;
149 float capture_buffer_load () const;
151 int do_flush (RunContext, bool force = false);
152 void set_pending_overwrite (bool);
153 int seek (samplepos_t, bool complete_refill = false);
154 int can_internal_playback_seek (samplecnt_t);
155 int internal_playback_seek (samplecnt_t);
156 void non_realtime_locate (samplepos_t);
157 void realtime_handle_transport_stopped ();
158 void non_realtime_speed_change ();
159 int overwrite_existing_buffers ();
160 samplecnt_t get_captured_samples (uint32_t n = 0) const;
161 int set_loop (ARDOUR::Location *);
162 void transport_looped (samplepos_t);
163 bool realtime_speed_change ();
164 void transport_stopped_wallclock (struct tm &, time_t, bool);
165 bool pending_overwrite () const;
166 void prepare_to_stop (samplepos_t, samplepos_t);
167 void set_slaved (bool);
168 ChanCount n_channels ();
169 samplepos_t get_capture_start_sample (uint32_t n = 0) const;
170 AlignStyle alignment_style () const;
171 AlignChoice alignment_choice () const;
172 samplepos_t current_capture_start () const;
173 samplepos_t current_capture_end () const;
174 void set_align_style (AlignStyle, bool force=false);
175 void set_align_choice (AlignChoice, bool force=false);
176 void playlist_modified ();
177 int use_playlist (DataType, boost::shared_ptr<Playlist>);
178 int find_and_use_playlist (DataType, PBD::ID const &);
179 int use_copy_playlist ();
180 int use_new_playlist (DataType);
181 int use_default_new_playlist () {
182 return use_new_playlist (data_type());
184 void adjust_playback_buffering ();
185 void adjust_capture_buffering ();
187 PBD::Signal0<void> FreezeChange;
188 PBD::Signal0<void> PlaylistChanged;
189 PBD::Signal0<void> SpeedChanged;
190 PBD::Signal0<void> AlignmentStyleChanged;
193 XMLNode& state (bool full);
195 boost::shared_ptr<Playlist> _playlists[DataType::num_types];
197 MeterPoint _saved_meter_point;
200 boost::shared_ptr<MonitorControl> _monitoring_control;
203 struct FreezeRecordProcessorInfo {
204 FreezeRecordProcessorInfo(XMLNode& st, boost::shared_ptr<Processor> proc)
205 : state (st), processor (proc) {}
208 boost::shared_ptr<Processor> processor;
212 struct FreezeRecord {
214 : have_mementos(false)
219 boost::shared_ptr<Playlist> playlist;
220 std::vector<FreezeRecordProcessorInfo*> processor_info;
225 virtual void set_state_part_two () = 0;
227 FreezeRecord _freeze_record;
228 XMLNode* pending_state;
231 void maybe_declick (BufferSet&, samplecnt_t, int);
233 boost::shared_ptr<AutomationControl> _record_enable_control;
234 boost::shared_ptr<AutomationControl> _record_safe_control;
236 virtual void record_enable_changed (bool, PBD::Controllable::GroupControlDisposition);
237 virtual void record_safe_changed (bool, PBD::Controllable::GroupControlDisposition);
239 samplecnt_t check_initial_delay (samplecnt_t nframes, samplepos_t&);
240 virtual void monitoring_changed (bool, PBD::Controllable::GroupControlDisposition);
242 AlignChoice _alignment_choice;
243 void set_align_choice_from_io ();
244 void input_changed ();
246 void use_captured_audio_sources (SourceList&, CaptureInfos const &);
247 void use_captured_midi_sources (SourceList&, CaptureInfos const &);
250 void parameter_changed (std::string const & p);
252 std::string _diskstream_name;
255 }; /* namespace ARDOUR*/
258 DEFINE_ENUM_CONVERT(ARDOUR::Track::FreezeState);
261 #endif /* __ardour_track_h__ */