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 "ardour/interthread_info.h"
25 #include "ardour/recordable.h"
26 #include "ardour/route.h"
27 #include "ardour/public_diskstream.h"
40 /** A track is an route (bus) with a recordable diskstream and
41 * related objects relevant to tracking, playback and editing.
43 * Specifically a track has regions and playlist objects.
45 class LIBARDOUR_API Track : public Route, public Recordable, public PublicDiskstream
48 Track (Session&, std::string name, PresentationInfo::Flag f = PresentationInfo::Flag (0), TrackMode m = Normal, DataType default_type = DataType::AUDIO);
53 bool set_name (const std::string& str);
54 void resync_track_name ();
56 TrackMode mode () const { return _mode; }
57 virtual int set_mode (TrackMode /*m*/) { return false; }
58 virtual bool can_use_mode (TrackMode /*m*/, bool& /*bounce_required*/) { return false; }
59 PBD::Signal0<void> TrackModeChanged;
61 boost::shared_ptr<MonitorControl> monitoring_control() const { return _monitoring_control; }
63 MonitorState monitoring_state () const;
64 MeterState metering_state () const;
66 virtual int no_roll (pframes_t nframes, framepos_t start_frame, framepos_t end_frame,
69 int silent_roll (pframes_t nframes, framepos_t start_frame, framepos_t end_frame,
72 virtual int roll (pframes_t nframes, framepos_t start_frame, framepos_t end_frame,
73 int declick, bool& need_butler) = 0;
75 bool needs_butler() const { return _needs_butler; }
77 virtual DataType data_type () const = 0;
81 void use_new_diskstream ();
82 virtual boost::shared_ptr<Diskstream> create_diskstream() = 0;
83 virtual void set_diskstream (boost::shared_ptr<Diskstream>);
85 void set_latency_compensation (framecnt_t);
93 FreezeState freeze_state() const;
95 virtual void freeze_me (InterThreadInfo&) = 0;
96 virtual void unfreeze () = 0;
98 /** Test if the track can be bounced with the given settings.
99 * If sends/inserts/returns are present in the signal path or the given track
100 * has no audio outputs bouncing is not possible.
102 * @param endpoint the processor to tap the signal off (or nil for the top)
103 * @param include_endpoint include the given processor in the bounced audio.
104 * @return true if the track can be bounced, or false otherwise.
106 virtual bool bounceable (boost::shared_ptr<Processor> endpoint, bool include_endpoint) const = 0;
108 /** bounce track from session start to session end to new region
110 * @param itt asynchronous progress report and cancel
111 * @return a new audio region (or nil in case of error)
113 virtual boost::shared_ptr<Region> bounce (InterThreadInfo& itt) = 0;
115 /** Bounce the given range to a new audio region.
116 * @param start start time (in samples)
117 * @param end end time (in samples)
118 * @param itt asynchronous progress report and cancel
119 * @param endpoint the processor to tap the signal off (or nil for the top)
120 * @param include_endpoint include the given processor in the bounced audio.
121 * @return a new audio region (or nil in case of error)
123 virtual boost::shared_ptr<Region> bounce_range (framepos_t start, framepos_t end, InterThreadInfo& itt,
124 boost::shared_ptr<Processor> endpoint, bool include_endpoint) = 0;
125 virtual int export_stuff (BufferSet& bufs, framepos_t start_frame, framecnt_t nframes,
126 boost::shared_ptr<Processor> endpoint, bool include_endpoint, bool for_export, bool for_freeze) = 0;
128 XMLNode& get_state();
129 XMLNode& get_template();
130 virtual int set_state (const XMLNode&, int version);
131 static void zero_diskstream_id_in_xml (XMLNode&);
133 boost::shared_ptr<AutomationControl> rec_enable_control() const { return _record_enable_control; }
134 boost::shared_ptr<AutomationControl> rec_safe_control() const { return _record_safe_control; }
136 int prep_record_enabled (bool);
137 bool can_be_record_enabled ();
138 bool can_be_record_safe ();
140 bool using_diskstream_id (PBD::ID) const;
142 void set_block_size (pframes_t);
144 /* PublicDiskstream interface */
145 boost::shared_ptr<Playlist> playlist ();
146 void request_input_monitoring (bool);
147 void ensure_input_monitoring (bool);
148 bool destructive () const;
149 std::list<boost::shared_ptr<Source> > & last_capture_sources ();
150 void set_capture_offset ();
151 std::string steal_write_source_name ();
152 void reset_write_sources (bool, bool force = false);
153 float playback_buffer_load () const;
154 float capture_buffer_load () const;
156 int do_flush (RunContext, bool force = false);
157 void set_pending_overwrite (bool);
158 int seek (framepos_t, bool complete_refill = false);
159 bool hidden () const;
160 int can_internal_playback_seek (framecnt_t);
161 int internal_playback_seek (framecnt_t);
162 void non_realtime_input_change ();
163 void non_realtime_locate (framepos_t);
164 void non_realtime_set_speed ();
165 int overwrite_existing_buffers ();
166 framecnt_t get_captured_frames (uint32_t n = 0) const;
167 int set_loop (Location *);
168 void transport_looped (framepos_t);
169 bool realtime_set_speed (double, bool);
170 void transport_stopped_wallclock (struct tm &, time_t, bool);
171 bool pending_overwrite () const;
172 double speed () const;
173 void prepare_to_stop (framepos_t, framepos_t);
174 void set_slaved (bool);
175 ChanCount n_channels ();
176 framepos_t get_capture_start_frame (uint32_t n = 0) const;
177 AlignStyle alignment_style () const;
178 AlignChoice alignment_choice () const;
179 framepos_t current_capture_start () const;
180 framepos_t current_capture_end () const;
181 void playlist_modified ();
182 int use_playlist (boost::shared_ptr<Playlist>);
183 void set_align_style (AlignStyle, bool force=false);
184 void set_align_choice (AlignChoice, bool force=false);
185 int use_copy_playlist ();
186 int use_new_playlist ();
187 void adjust_playback_buffering ();
188 void adjust_capture_buffering ();
190 PBD::Signal0<void> DiskstreamChanged;
191 PBD::Signal0<void> FreezeChange;
192 /* Emitted when our diskstream is set to use a different playlist */
193 PBD::Signal0<void> PlaylistChanged;
194 PBD::Signal0<void> SpeedChanged;
195 PBD::Signal0<void> AlignmentStyleChanged;
198 XMLNode& state (bool full);
200 boost::shared_ptr<Diskstream> _diskstream;
201 MeterPoint _saved_meter_point;
204 boost::shared_ptr<MonitorControl> _monitoring_control;
207 struct FreezeRecordProcessorInfo {
208 FreezeRecordProcessorInfo(XMLNode& st, boost::shared_ptr<Processor> proc)
209 : state (st), processor (proc) {}
212 boost::shared_ptr<Processor> processor;
216 struct FreezeRecord {
218 : have_mementos(false)
223 boost::shared_ptr<Playlist> playlist;
224 std::vector<FreezeRecordProcessorInfo*> processor_info;
229 virtual void set_state_part_two () = 0;
231 FreezeRecord _freeze_record;
232 XMLNode* pending_state;
235 void maybe_declick (BufferSet&, framecnt_t, int);
237 boost::shared_ptr<AutomationControl> _record_enable_control;
238 boost::shared_ptr<AutomationControl> _record_safe_control;
240 virtual void record_enable_changed (bool, PBD::Controllable::GroupControlDisposition);
241 virtual void record_safe_changed (bool, PBD::Controllable::GroupControlDisposition);
243 framecnt_t check_initial_delay (framecnt_t nframes, framepos_t&);
244 virtual void monitoring_changed (bool, PBD::Controllable::GroupControlDisposition);
248 virtual boost::shared_ptr<Diskstream> diskstream_factory (XMLNode const &) = 0;
250 void diskstream_playlist_changed ();
251 void diskstream_speed_changed ();
252 void diskstream_alignment_style_changed ();
253 void parameter_changed (std::string const & p);
255 std::string _diskstream_name;
258 }; /* namespace ARDOUR*/
260 #endif /* __ardour_track_h__ */