Ardour  9.0-pre0-582-g084a23a80d
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 #pragma once
23 
24 #include <optional>
25 #include <memory>
26 
27 #include "pbd/enum_convert.h"
28 
30 #include "ardour/recordable.h"
31 #include "ardour/route.h"
32 
33 namespace ARDOUR {
34 
35 class Session;
36 class Playlist;
37 class RouteGroup;
38 class Source;
39 class Region;
40 class DiskReader;
41 class DiskWriter;
42 class IO;
43 class RecordEnableControl;
44 class RecordSafeControl;
45 class MidiNoteTracker;
46 
54 class LIBARDOUR_API Track : public Route, public Recordable
55 {
56 public:
58  virtual ~Track ();
59 
60  int init ();
61 
62  bool set_name (const std::string& str);
63  int resync_take_name (std::string newname = "");
64 
65  TrackMode mode () const { return _mode; }
66 
67  bool set_processor_state (XMLNode const& node, int version, XMLProperty const* prop, ProcessorList& new_order, bool& must_configure);
68 
70 
71  bool declick_in_progress () const;
72 
73  bool can_record();
74 
75  enum FreezeState {
78  UnFrozen
79  };
80 
82 
83  virtual void freeze_me (InterThreadInfo&) = 0;
84  virtual void unfreeze () = 0;
85 
94  virtual bool bounceable (std::shared_ptr<Processor> endpoint, bool include_endpoint) const = 0;
95 
102  virtual std::shared_ptr<Region> bounce (InterThreadInfo& itt, std::string const& name);
103 
114  virtual std::shared_ptr<Region> bounce_range (samplepos_t start, samplepos_t end, InterThreadInfo& itt,
115  std::shared_ptr<Processor> endpoint, bool include_endpoint,
116  std::string const& name = "", bool prefix_track_name = false);
117 
118  virtual int export_stuff (BufferSet& bufs, samplepos_t start_sample, samplecnt_t nframes,
119  std::shared_ptr<Processor> endpoint, bool include_endpoint, bool for_export, bool for_freeze,
120  MidiNoteTracker&) = 0;
121 
122  virtual int set_state (const XMLNode&, int version);
124 
125  std::shared_ptr<AutomationControl> rec_enable_control() const { return _record_enable_control; }
126  std::shared_ptr<AutomationControl> rec_safe_control() const { return _record_safe_control; }
127 
131 
133 
135 
136  /* used by DiskReader request_overwrite_buffer(), to create
137  * a SessionEvent with weak_ptr<> reference
138  */
139  std::shared_ptr<Track> shared_ptr () {
140  return std::dynamic_pointer_cast<Track> (shared_from_this());
141  }
142 
143  std::shared_ptr<Playlist> playlist ();
146  std::list<std::shared_ptr<Source> > & last_capture_sources ();
147  std::string steal_write_source_name ();
148  void reset_write_sources (bool mark_write_complete);
149  float playback_buffer_load () const;
150  float capture_buffer_load () const;
151  int do_refill ();
152  int do_flush (RunContext, bool force = false);
154  int seek (samplepos_t, bool complete_refill = false);
159  samplecnt_t get_captured_samples (uint32_t n = 0) const;
161  void transport_stopped_wallclock (struct tm &, time_t, bool);
163  bool pending_overwrite () const;
164  void set_slaved (bool);
166  samplepos_t get_capture_start_sample (uint32_t n = 0) const;
171  void set_align_style (AlignStyle, bool force=false);
172  void set_align_choice (AlignChoice, bool force=false);
174  int use_playlist (DataType, std::shared_ptr<Playlist>, bool set_orig = true);
179  return use_new_playlist (data_type());
180  }
183 
185 
192 
193 protected:
194  XMLNode& state (bool save_template) const;
195 
197 
198  std::shared_ptr<Playlist> _playlists[DataType::num_types];
199  std::optional<MeterPoint> _saved_meter_point;
202 
203  //private: (FIXME)
205  FreezeRecordProcessorInfo(XMLNode& st, std::shared_ptr<Processor> proc)
206  : state (st), processor (proc) {}
207 
209  std::shared_ptr<Processor> processor;
211  };
212 
213  struct FreezeRecord {
215  : have_mementos(false)
216  {}
217 
219 
220  std::shared_ptr<Playlist> playlist;
221  std::vector<FreezeRecordProcessorInfo*> processor_info;
224  };
225 
226  virtual void set_state_part_two () = 0;
227 
230 
231  std::shared_ptr<AutomationControl> _record_enable_control;
232  std::shared_ptr<AutomationControl> _record_safe_control;
233 
236 
238 
241 
244 
245 private:
246  void parameter_changed (std::string const & p);
247  void input_changed ();
249 
250  std::string _diskstream_name;
252 };
253 
254 }; /* namespace ARDOUR*/
255 
256 namespace PBD {
258 }
259 
static const uint32_t num_types
Definition: data_type.h:61
std::list< std::shared_ptr< Processor > > ProcessorList
Definition: route.h:111
int use_playlist(DataType, std::shared_ptr< Playlist >, bool set_orig=true)
void reset_write_sources(bool mark_write_complete)
AlignChoice _alignment_choice
Definition: track.h:239
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:231
void set_slaved(bool)
void request_input_monitoring(bool)
void transport_looped(samplepos_t)
bool overwrite_existing_buffers()
void chan_count_changed()
int use_new_playlist(DataType)
void adjust_capture_buffering()
std::shared_ptr< AutomationControl > _record_safe_control
Definition: track.h:232
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:201
std::string steal_write_source_name()
PBD::Signal< void()> PlaylistChanged
Definition: track.h:187
int use_default_new_playlist()
Definition: track.h:178
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::optional< MeterPoint > _saved_meter_point
Definition: track.h:199
std::shared_ptr< AutomationControl > rec_safe_control() const
Definition: track.h:126
PBD::Signal< void()> AlignmentStyleChanged
Definition: track.h:190
@ NoFreeze
Definition: track.h:76
FreezeState freeze_state() const
std::shared_ptr< Track > shared_ptr()
Definition: track.h:139
PBD::Signal< void()> PlaylistAdded
Definition: track.h:188
PBD::Signal< void()> ChanCountChanged
Definition: track.h:191
bool set_name(const std::string &str)
PBD::Signal< void()> FreezeChange
Definition: track.h:186
bool pending_overwrite() const
void use_captured_audio_sources(SourceList &, CaptureInfos const &)
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:65
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:251
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:250
void set_align_style(AlignStyle, bool force=false)
static void zero_diskstream_id_in_xml(XMLNode &)
FreezeRecord _freeze_record
Definition: track.h:228
PBD::Signal< void()> SpeedChanged
Definition: track.h:189
XMLNode * pending_state
Definition: track.h:229
void non_realtime_locate(samplepos_t)
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)
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:125
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()
bool _record_prepared
Definition: track.h:200
samplepos_t current_capture_end() const
Definition: id.h:34
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:205
std::shared_ptr< Processor > processor
Definition: track.h:209
std::vector< FreezeRecordProcessorInfo * > processor_info
Definition: track.h:221
std::shared_ptr< Playlist > playlist
Definition: track.h:220