2 * Copyright (C) 2006-2011 David Robillard <d@drobilla.net>
3 * Copyright (C) 2008-2018 Paul Davis <paul@linuxaudiosystems.com>
4 * Copyright (C) 2009-2012 Carl Hetherington <carl@carlh.net>
5 * Copyright (C) 2014-2019 Robin Gareus <robin@gareus.org>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #ifndef __ardour_track_h__
23 #define __ardour_track_h__
25 #include <boost/shared_ptr.hpp>
27 #include "pbd/enum_convert.h"
29 #include "ardour/interthread_info.h"
30 #include "ardour/recordable.h"
31 #include "ardour/route.h"
43 class RecordEnableControl;
44 class RecordSafeControl;
46 /** A track is an route (bus) with a recordable diskstream and
47 * related objects relevant to recording, playback and editing.
49 * Specifically a track has a playlist object that describes material
50 * to be played from disk, and modifies that object during recording and
53 class LIBARDOUR_API Track : public Route, public Recordable
56 Track (Session&, std::string name, PresentationInfo::Flag f = PresentationInfo::Flag (0), TrackMode m = Normal, DataType default_type = DataType::AUDIO);
61 bool set_name (const std::string& str);
62 void resync_track_name ();
64 TrackMode mode () const { return _mode; }
66 MeterState metering_state () const;
68 bool set_processor_state (XMLNode const & node, XMLProperty const* prop, ProcessorList& new_order, bool& must_configure);
70 bool declick_in_progress () const;
80 FreezeState freeze_state() const;
82 virtual void freeze_me (InterThreadInfo&) = 0;
83 virtual void unfreeze () = 0;
85 /** Test if the track can be bounced with the given settings.
86 * If sends/inserts/returns are present in the signal path or the given track
87 * has no audio outputs bouncing is not possible.
89 * @param endpoint the processor to tap the signal off (or nil for the top)
90 * @param include_endpoint include the given processor in the bounced audio.
91 * @return true if the track can be bounced, or false otherwise.
93 virtual bool bounceable (boost::shared_ptr<Processor> endpoint, bool include_endpoint) const = 0;
95 /** bounce track from session start to session end to new region
97 * @param itt asynchronous progress report and cancel
98 * @return a new audio region (or nil in case of error)
100 virtual boost::shared_ptr<Region> bounce (InterThreadInfo& itt) = 0;
102 /** Bounce the given range to a new audio region.
103 * @param start start time (in samples)
104 * @param end end time (in samples)
105 * @param itt asynchronous progress report and cancel
106 * @param endpoint the processor to tap the signal off (or nil for the top)
107 * @param include_endpoint include the given processor in the bounced audio.
108 * @return a new audio region (or nil in case of error)
110 virtual boost::shared_ptr<Region> bounce_range (samplepos_t start, samplepos_t end, InterThreadInfo& itt,
111 boost::shared_ptr<Processor> endpoint, bool include_endpoint) = 0;
112 virtual int export_stuff (BufferSet& bufs, samplepos_t start_sample, samplecnt_t nframes,
113 boost::shared_ptr<Processor> endpoint, bool include_endpoint, bool for_export, bool for_freeze) = 0;
115 virtual int set_state (const XMLNode&, int version);
116 static void zero_diskstream_id_in_xml (XMLNode&);
118 boost::shared_ptr<AutomationControl> rec_enable_control() const { return _record_enable_control; }
119 boost::shared_ptr<AutomationControl> rec_safe_control() const { return _record_safe_control; }
121 int prep_record_enabled (bool);
122 bool can_be_record_enabled ();
123 bool can_be_record_safe ();
125 void use_captured_sources (SourceList&, CaptureInfos const &);
127 void set_block_size (pframes_t);
129 boost::shared_ptr<Playlist> playlist ();
130 void request_input_monitoring (bool);
131 void ensure_input_monitoring (bool);
132 bool destructive () const;
133 std::list<boost::shared_ptr<Source> > & last_capture_sources ();
134 std::string steal_write_source_name ();
135 void reset_write_sources (bool, bool force = false);
136 float playback_buffer_load () const;
137 float capture_buffer_load () const;
139 int do_flush (RunContext, bool force = false);
140 void set_pending_overwrite ();
141 int seek (samplepos_t, bool complete_refill = false);
142 bool can_internal_playback_seek (samplecnt_t);
143 void internal_playback_seek (samplecnt_t);
144 void non_realtime_locate (samplepos_t);
145 bool overwrite_existing_buffers ();
146 samplecnt_t get_captured_samples (uint32_t n = 0) const;
147 void transport_looped (samplepos_t);
148 void transport_stopped_wallclock (struct tm &, time_t, bool);
149 bool pending_overwrite () const;
150 void set_slaved (bool);
151 ChanCount n_channels ();
152 samplepos_t get_capture_start_sample (uint32_t n = 0) const;
153 AlignStyle alignment_style () const;
154 AlignChoice alignment_choice () const;
155 samplepos_t current_capture_start () const;
156 samplepos_t current_capture_end () const;
157 void set_align_style (AlignStyle, bool force=false);
158 void set_align_choice (AlignChoice, bool force=false);
159 void playlist_modified ();
160 int use_playlist (DataType, boost::shared_ptr<Playlist>);
161 int find_and_use_playlist (DataType, PBD::ID const &);
162 int use_copy_playlist ();
163 int use_new_playlist (DataType);
164 int use_default_new_playlist () {
165 return use_new_playlist (data_type());
167 void adjust_playback_buffering ();
168 void adjust_capture_buffering ();
170 PBD::Signal0<void> FreezeChange;
171 PBD::Signal0<void> PlaylistChanged;
172 PBD::Signal0<void> SpeedChanged;
173 PBD::Signal0<void> AlignmentStyleChanged;
176 XMLNode& state (bool save_template);
178 boost::shared_ptr<Playlist> _playlists[DataType::num_types];
180 MeterPoint _saved_meter_point;
184 struct FreezeRecordProcessorInfo {
185 FreezeRecordProcessorInfo(XMLNode& st, boost::shared_ptr<Processor> proc)
186 : state (st), processor (proc) {}
189 boost::shared_ptr<Processor> processor;
193 struct FreezeRecord {
195 : have_mementos(false)
200 boost::shared_ptr<Playlist> playlist;
201 std::vector<FreezeRecordProcessorInfo*> processor_info;
206 virtual void set_state_part_two () = 0;
208 FreezeRecord _freeze_record;
209 XMLNode* pending_state;
212 boost::shared_ptr<AutomationControl> _record_enable_control;
213 boost::shared_ptr<AutomationControl> _record_safe_control;
215 virtual void record_enable_changed (bool, PBD::Controllable::GroupControlDisposition);
216 virtual void record_safe_changed (bool, PBD::Controllable::GroupControlDisposition);
218 virtual void monitoring_changed (bool, PBD::Controllable::GroupControlDisposition);
220 AlignChoice _alignment_choice;
221 void set_align_choice_from_io ();
222 void input_changed ();
224 void use_captured_audio_sources (SourceList&, CaptureInfos const &);
225 void use_captured_midi_sources (SourceList&, CaptureInfos const &);
228 void parameter_changed (std::string const & p);
230 std::string _diskstream_name;
233 }; /* namespace ARDOUR*/
236 DEFINE_ENUM_CONVERT(ARDOUR::Track::FreezeState);
239 #endif /* __ardour_track_h__ */