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