Ardour  8.12
track.h
Go to the documentation of this file.
1 /*
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>
6  *
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.
11  *
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.
16  *
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.
20  */
21 
22 #ifndef __ardour_track_h__
23 #define __ardour_track_h__
24 
25 #include <boost/optional.hpp>
26 #include <memory>
27 
28 #include "pbd/enum_convert.h"
29 
31 #include "ardour/recordable.h"
32 #include "ardour/route.h"
33 
34 namespace ARDOUR {
35 
36 class Session;
37 class Playlist;
38 class RouteGroup;
39 class Source;
40 class Region;
41 class DiskReader;
42 class DiskWriter;
43 class IO;
44 class RecordEnableControl;
45 class RecordSafeControl;
46 class MidiNoteTracker;
47 
55 class LIBARDOUR_API Track : public Route, public Recordable
56 {
57 public:
59  virtual ~Track ();
60 
61  int init ();
62 
63  bool set_name (const std::string& str);
64  int resync_take_name (std::string newname = "");
65 
66  TrackMode mode () const { return _mode; }
67 
68  bool set_processor_state (XMLNode const& node, int version, XMLProperty const* prop, ProcessorList& new_order, bool& must_configure);
69 
71 
72  bool declick_in_progress () const;
73 
74  bool can_record();
75 
76  enum FreezeState {
79  UnFrozen
80  };
81 
83 
84  virtual void freeze_me (InterThreadInfo&) = 0;
85  virtual void unfreeze () = 0;
86 
95  virtual bool bounceable (std::shared_ptr<Processor> endpoint, bool include_endpoint) const = 0;
96 
103  virtual std::shared_ptr<Region> bounce (InterThreadInfo& itt, std::string const& name);
104 
115  virtual std::shared_ptr<Region> bounce_range (samplepos_t start, samplepos_t end, InterThreadInfo& itt,
116  std::shared_ptr<Processor> endpoint, bool include_endpoint,
117  std::string const& name = "", bool prefix_track_name = false);
118 
119  virtual int export_stuff (BufferSet& bufs, samplepos_t start_sample, samplecnt_t nframes,
120  std::shared_ptr<Processor> endpoint, bool include_endpoint, bool for_export, bool for_freeze,
121  MidiNoteTracker&) = 0;
122 
123  virtual int set_state (const XMLNode&, int version);
125 
126  std::shared_ptr<AutomationControl> rec_enable_control() const { return _record_enable_control; }
127  std::shared_ptr<AutomationControl> rec_safe_control() const { return _record_safe_control; }
128 
132 
134 
136 
137  /* used by DiskReader request_overwrite_buffer(), to create
138  * a SessionEvent with weak_ptr<> reference
139  */
140  std::shared_ptr<Track> shared_ptr () {
141  return std::dynamic_pointer_cast<Track> (shared_from_this());
142  }
143 
144  std::shared_ptr<Playlist> playlist ();
147  std::list<std::shared_ptr<Source> > & last_capture_sources ();
148  std::string steal_write_source_name ();
149  void reset_write_sources (bool, bool force = false);
150  float playback_buffer_load () const;
151  float capture_buffer_load () const;
152  int do_refill ();
153  int do_flush (RunContext, bool force = false);
155  int seek (samplepos_t, bool complete_refill = false);
160  samplecnt_t get_captured_samples (uint32_t n = 0) const;
162  void transport_stopped_wallclock (struct tm &, time_t, bool);
164  bool pending_overwrite () const;
165  void set_slaved (bool);
167  samplepos_t get_capture_start_sample (uint32_t n = 0) const;
172  void set_align_style (AlignStyle, bool force=false);
173  void set_align_choice (AlignChoice, bool force=false);
175  int use_playlist (DataType, std::shared_ptr<Playlist>, bool set_orig = true);
180  return use_new_playlist (data_type());
181  }
184 
186 
187  PBD::Signal0<void> FreezeChange;
188  PBD::Signal0<void> PlaylistChanged;
189  PBD::Signal0<void> PlaylistAdded;
190  PBD::Signal0<void> SpeedChanged;
191  PBD::Signal0<void> AlignmentStyleChanged;
192  PBD::Signal0<void> ChanCountChanged;
193 
194 protected:
195  XMLNode& state (bool save_template) const;
196 
198 
199  std::shared_ptr<Playlist> _playlists[DataType::num_types];
200  boost::optional<MeterPoint> _saved_meter_point;
203 
204  //private: (FIXME)
206  FreezeRecordProcessorInfo(XMLNode& st, std::shared_ptr<Processor> proc)
207  : state (st), processor (proc) {}
208 
210  std::shared_ptr<Processor> processor;
212  };
213 
214  struct FreezeRecord {
216  : have_mementos(false)
217  {}
218 
220 
221  std::shared_ptr<Playlist> playlist;
222  std::vector<FreezeRecordProcessorInfo*> processor_info;
225  };
226 
227  virtual void set_state_part_two () = 0;
228 
231 
232  std::shared_ptr<AutomationControl> _record_enable_control;
233  std::shared_ptr<AutomationControl> _record_safe_control;
234 
237 
239 
242 
245 
246 private:
247  void parameter_changed (std::string const & p);
248  void input_changed ();
250 
251  std::string _diskstream_name;
253 };
254 
255 }; /* namespace ARDOUR*/
256 
257 namespace PBD {
259 }
260 
261 #endif /* __ardour_track_h__ */
static const uint32_t num_types
Definition: data_type.h:62
std::list< std::shared_ptr< Processor > > ProcessorList
Definition: route.h:112
int use_playlist(DataType, std::shared_ptr< Playlist >, bool set_orig=true)
AlignChoice _alignment_choice
Definition: track.h:240
void mark_capture_xrun()
void use_captured_sources(SourceList &, CaptureInfos const &)
void time_domain_changed()
virtual void freeze_me(InterThreadInfo &)=0
void transport_stopped_wallclock(struct tm &, time_t, bool)
bool declick_in_progress() const
int seek(samplepos_t, bool complete_refill=false)
std::shared_ptr< AutomationControl > _record_enable_control
Definition: track.h:232
void set_slaved(bool)
void request_input_monitoring(bool)
void transport_looped(samplepos_t)
bool overwrite_existing_buffers()
void chan_count_changed()
boost::optional< MeterPoint > _saved_meter_point
Definition: track.h:200
int use_new_playlist(DataType)
void adjust_capture_buffering()
PBD::Signal0< void > PlaylistChanged
Definition: track.h:188
PBD::Signal0< void > ChanCountChanged
Definition: track.h:192
std::shared_ptr< AutomationControl > _record_safe_control
Definition: track.h:233
virtual int set_state(const XMLNode &, int version)
bool can_record()
void internal_playback_seek(samplecnt_t)
samplepos_t current_capture_start() const
int find_and_use_playlist(DataType, PBD::ID const &)
TrackMode _mode
Definition: track.h:202
std::string steal_write_source_name()
int use_default_new_playlist()
Definition: track.h:179
virtual void unfreeze()=0
void update_input_meter()
virtual std::shared_ptr< Region > bounce(InterThreadInfo &itt, std::string const &name)
int use_copy_playlist()
std::shared_ptr< AutomationControl > rec_safe_control() const
Definition: track.h:127
@ NoFreeze
Definition: track.h:77
FreezeState freeze_state() const
PBD::Signal0< void > AlignmentStyleChanged
Definition: track.h:191
std::shared_ptr< Track > shared_ptr()
Definition: track.h:140
bool set_name(const std::string &str)
bool pending_overwrite() const
void use_captured_audio_sources(SourceList &, CaptureInfos const &)
void reset_write_sources(bool, bool force=false)
void adjust_playback_buffering()
virtual int export_stuff(BufferSet &bufs, samplepos_t start_sample, samplecnt_t nframes, std::shared_ptr< Processor > endpoint, bool include_endpoint, bool for_export, bool for_freeze, MidiNoteTracker &)=0
void input_changed()
void playlist_modified()
virtual void set_state_part_two()=0
bool set_processor_state(XMLNode const &node, int version, XMLProperty const *prop, ProcessorList &new_order, bool &must_configure)
TrackMode mode() const
Definition: track.h:66
AlignChoice alignment_choice() const
virtual void record_enable_changed(bool, PBD::Controllable::GroupControlDisposition)
void set_pending_overwrite(OverwriteReason)
std::shared_ptr< Playlist > playlist()
float capture_buffer_load() const
Track(Session &, std::string name, PresentationInfo::Flag f=PresentationInfo::Flag(0), TrackMode m=Normal, DataType default_type=DataType::AUDIO)
bool _pending_name_change
Definition: track.h:252
float playback_buffer_load() const
bool can_internal_playback_seek(samplecnt_t)
void use_captured_midi_sources(SourceList &, CaptureInfos const &)
std::string _diskstream_name
Definition: track.h:251
void set_align_style(AlignStyle, bool force=false)
static void zero_diskstream_id_in_xml(XMLNode &)
FreezeRecord _freeze_record
Definition: track.h:229
XMLNode * pending_state
Definition: track.h:230
void non_realtime_locate(samplepos_t)
PBD::Signal0< void > SpeedChanged
Definition: track.h:190
virtual std::shared_ptr< Region > bounce_range(samplepos_t start, samplepos_t end, InterThreadInfo &itt, std::shared_ptr< Processor > endpoint, bool include_endpoint, std::string const &name="", bool prefix_track_name=false)
virtual void record_safe_changed(bool, PBD::Controllable::GroupControlDisposition)
PBD::Signal0< void > FreezeChange
Definition: track.h:187
std::list< std::shared_ptr< Source > > & last_capture_sources()
bool can_be_record_enabled()
void set_align_choice(AlignChoice, bool force=false)
samplecnt_t get_captured_samples(uint32_t n=0) const
std::shared_ptr< AutomationControl > rec_enable_control() const
Definition: track.h:126
int do_flush(RunContext, bool force=false)
ChanCount n_channels()
AlignStyle alignment_style() const
bool can_be_record_safe()
void ensure_input_monitoring(bool)
void set_block_size(pframes_t)
virtual bool bounceable(std::shared_ptr< Processor > endpoint, bool include_endpoint) const =0
void parameter_changed(std::string const &p)
samplepos_t get_capture_start_sample(uint32_t n=0) const
XMLNode & playlist_state() const
void set_align_choice_from_io()
virtual void monitoring_changed(bool, PBD::Controllable::GroupControlDisposition)
XMLNode & state(bool save_template) const
int resync_take_name(std::string newname="")
int prep_record_enabled(bool)
virtual ~Track()
PBD::Signal0< void > PlaylistAdded
Definition: track.h:189
bool _record_prepared
Definition: track.h:201
samplepos_t current_capture_end() const
Definition: id.h:35
Definition: xml++.h:114
GtkImageIconNameData name
Definition: gtkimage.h:6
#define LIBARDOUR_API
PBD::PropertyDescriptor< timepos_t > start
uint32_t pframes_t
std::vector< std::shared_ptr< Source > > SourceList
Temporal::samplecnt_t samplecnt_t
std::vector< CaptureInfo * > CaptureInfos
Temporal::samplepos_t samplepos_t
Definition: axis_view.h:42
DEFINE_ENUM_CONVERT(ARDOUR::Track::FreezeState)
FreezeRecordProcessorInfo(XMLNode &st, std::shared_ptr< Processor > proc)
Definition: track.h:206
std::shared_ptr< Processor > processor
Definition: track.h:210
std::vector< FreezeRecordProcessorInfo * > processor_info
Definition: track.h:222
std::shared_ptr< Playlist > playlist
Definition: track.h:221