ardour
track.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2006 Paul Davis
3 
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.
8 
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.
13 
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.
17 */
18 
19 #ifndef __ardour_track_h__
20 #define __ardour_track_h__
21 
22 #include <boost/shared_ptr.hpp>
23 
25 #include "ardour/route.h"
27 
28 namespace ARDOUR {
29 
30 class Session;
31 class Playlist;
32 class RouteGroup;
33 class Source;
34 class Region;
35 class Diskstream;
36 class IO;
37 
38 class LIBARDOUR_API Track : public Route, public PublicDiskstream
39 {
40  public:
41  Track (Session&, std::string name, Route::Flag f = Route::Flag (0), TrackMode m = Normal, DataType default_type = DataType::AUDIO);
42  virtual ~Track ();
43 
44  int init ();
45 
46  bool set_name (const std::string& str);
47  void resync_track_name ();
48 
49  TrackMode mode () const { return _mode; }
50  virtual int set_mode (TrackMode /*m*/) { return false; }
51  virtual bool can_use_mode (TrackMode /*m*/, bool& /*bounce_required*/) { return false; }
52  PBD::Signal0<void> TrackModeChanged;
53 
54  virtual void set_monitoring (MonitorChoice);
55  MonitorChoice monitoring_choice() const { return _monitoring; }
56  MonitorState monitoring_state () const;
57  PBD::Signal0<void> MonitoringChanged;
58 
59  MeterState metering_state () const;
60 
61  virtual int no_roll (pframes_t nframes, framepos_t start_frame, framepos_t end_frame,
62  bool state_changing);
63 
64  int silent_roll (pframes_t nframes, framepos_t start_frame, framepos_t end_frame,
65  bool& need_butler);
66 
67  virtual int roll (pframes_t nframes, framepos_t start_frame, framepos_t end_frame,
68  int declick, bool& need_butler) = 0;
69 
70  bool needs_butler() const { return _needs_butler; }
71 
72  virtual DataType data_type () const = 0;
73 
74  bool can_record();
75 
76  void use_new_diskstream ();
77  virtual boost::shared_ptr<Diskstream> create_diskstream() = 0;
78  virtual void set_diskstream (boost::shared_ptr<Diskstream>);
79 
80  void set_latency_compensation (framecnt_t);
81 
82  enum FreezeState {
85  UnFrozen
86  };
87 
88  FreezeState freeze_state() const;
89 
90  virtual void freeze_me (InterThreadInfo&) = 0;
91  virtual void unfreeze () = 0;
92 
95  virtual bool bounceable (boost::shared_ptr<Processor> endpoint, bool include_endpoint) const = 0;
96  virtual boost::shared_ptr<Region> bounce (InterThreadInfo&) = 0;
98  boost::shared_ptr<Processor> endpoint, bool include_endpoint) = 0;
99  virtual int export_stuff (BufferSet& bufs, framepos_t start_frame, framecnt_t nframes,
100  boost::shared_ptr<Processor> endpoint, bool include_endpoint, bool for_export, bool for_freeze) = 0;
101 
102  XMLNode& get_state();
103  XMLNode& get_template();
104  virtual int set_state (const XMLNode&, int version);
105  static void zero_diskstream_id_in_xml (XMLNode&);
106 
108 
109  bool record_enabled() const;
110  void set_record_enabled (bool yn, void *src);
111  void prep_record_enabled (bool yn, void *src);
112 
113  bool using_diskstream_id (PBD::ID) const;
114 
115  void set_block_size (pframes_t);
116 
117  /* PublicDiskstream interface */
118  boost::shared_ptr<Playlist> playlist ();
119  void request_input_monitoring (bool);
120  void ensure_input_monitoring (bool);
121  bool destructive () const;
122  std::list<boost::shared_ptr<Source> > & last_capture_sources ();
123  void set_capture_offset ();
124  std::string steal_write_source_name ();
125  void reset_write_sources (bool, bool force = false);
126  float playback_buffer_load () const;
127  float capture_buffer_load () const;
128  int do_refill ();
129  int do_flush (RunContext, bool force = false);
130  void set_pending_overwrite (bool);
131  int seek (framepos_t, bool complete_refill = false);
132  bool hidden () const;
133  int can_internal_playback_seek (framecnt_t);
134  int internal_playback_seek (framecnt_t);
135  void non_realtime_input_change ();
136  void non_realtime_locate (framepos_t);
137  void non_realtime_set_speed ();
138  int overwrite_existing_buffers ();
139  framecnt_t get_captured_frames (uint32_t n = 0) const;
140  int set_loop (Location *);
141  void transport_looped (framepos_t);
142  bool realtime_set_speed (double, bool);
143  void transport_stopped_wallclock (struct tm &, time_t, bool);
144  bool pending_overwrite () const;
145  double speed () const;
146  void prepare_to_stop (framepos_t, framepos_t);
147  void set_slaved (bool);
148  ChanCount n_channels ();
149  framepos_t get_capture_start_frame (uint32_t n = 0) const;
150  AlignStyle alignment_style () const;
151  AlignChoice alignment_choice () const;
152  framepos_t current_capture_start () const;
153  framepos_t current_capture_end () const;
154  void playlist_modified ();
155  int use_playlist (boost::shared_ptr<Playlist>);
156  void set_align_style (AlignStyle, bool force=false);
157  void set_align_choice (AlignChoice, bool force=false);
158  int use_copy_playlist ();
159  int use_new_playlist ();
160  void adjust_playback_buffering ();
161  void adjust_capture_buffering ();
162 
163  PBD::Signal0<void> DiskstreamChanged;
164  PBD::Signal0<void> FreezeChange;
165  /* Emitted when our diskstream is set to use a different playlist */
166  PBD::Signal0<void> PlaylistChanged;
167  PBD::Signal0<void> RecordEnableChanged;
168  PBD::Signal0<void> SpeedChanged;
169  PBD::Signal0<void> AlignmentStyleChanged;
170 
171  protected:
172  XMLNode& state (bool full);
173 
179 
180  //private: (FIXME)
183  : state (st), processor (proc) {}
184 
188  };
189 
190  struct FreezeRecord {
192  : have_mementos(false)
193  {}
194 
195  ~FreezeRecord();
196 
198  std::vector<FreezeRecordProcessorInfo*> processor_info;
201  };
202 
205 
206  void set_value (double);
207  double get_value (void) const;
208 
210  };
211 
212  virtual void set_state_part_two () = 0;
213 
217 
218  void maybe_declick (BufferSet&, framecnt_t, int);
219 
221 
222  framecnt_t check_initial_delay (framecnt_t nframes, framepos_t&);
223 
224 private:
225 
226  virtual boost::shared_ptr<Diskstream> diskstream_factory (XMLNode const &) = 0;
227 
228  void diskstream_playlist_changed ();
229  void diskstream_record_enable_changed ();
230  void diskstream_speed_changed ();
231  void diskstream_alignment_style_changed ();
232  void parameter_changed (std::string const & p);
233 
234  std::string _diskstream_name;
235 };
236 
237 }; /* namespace ARDOUR*/
238 
239 #endif /* __ardour_track_h__ */
PBD::Signal0< void > TrackModeChanged
Definition: track.h:52
FreezeRecord _freeze_record
Definition: track.h:214
bool _destructive
Definition: track.h:216
PBD::Signal0< void > DiskstreamChanged
Definition: track.h:163
AlignStyle
Definition: types.h:163
LIBARDOUR_API PBD::PropertyDescriptor< bool > hidden
Definition: route_group.h:50
PBD::Signal0< void > FreezeChange
Definition: track.h:164
MeterState
Definition: types.h:399
MeterPoint _saved_meter_point
Definition: track.h:175
uint32_t pframes_t
Definition: types.h:61
boost::weak_ptr< Track > track
Definition: track.h:209
tuple f
Definition: signals.py:35
virtual int set_mode(TrackMode)
Definition: track.h:50
MonitorChoice
Definition: types.h:386
RunContext
Definition: types.h:492
LIBARDOUR_API PBD::PropertyDescriptor< framepos_t > start
Definition: region.cc:63
boost::shared_ptr< AutomationControl > rec_enable_control()
Definition: track.h:107
bool _needs_butler
Definition: track.h:177
Definition: id.h:32
boost::shared_ptr< Playlist > playlist
Definition: track.h:197
PBD::Signal0< void > AlignmentStyleChanged
Definition: track.h:169
XMLNode * pending_state
Definition: track.h:215
TrackMode
Definition: types.h:198
boost::shared_ptr< RecEnableControl > _rec_enable_control
Definition: track.h:220
int64_t framecnt_t
Definition: types.h:76
std::vector< FreezeRecordProcessorInfo * > processor_info
Definition: track.h:198
boost::shared_ptr< Processor > processor
Definition: track.h:186
Definition: amp.h:29
MonitorState
Definition: types.h:393
PBD::Signal0< void > SpeedChanged
Definition: track.h:168
int64_t framepos_t
Definition: types.h:66
MonitorChoice _monitoring
Definition: track.h:178
PBD::Signal0< void > PlaylistChanged
Definition: track.h:166
#define LIBARDOUR_API
FreezeRecordProcessorInfo(XMLNode &st, boost::shared_ptr< Processor > proc)
Definition: track.h:182
const char * name
MonitorChoice monitoring_choice() const
Definition: track.h:55
TrackMode _mode
Definition: track.h:176
Definition: xml++.h:95
PBD::Signal0< void > MonitoringChanged
Definition: track.h:57
std::string _diskstream_name
Definition: track.h:234
PBD::Signal0< void > RecordEnableChanged
Definition: track.h:167
TrackMode mode() const
Definition: track.h:49
boost::shared_ptr< Diskstream > _diskstream
Definition: track.h:174
bool needs_butler() const
Definition: track.h:70
static LilvNode * get_value(LilvWorld *world, const LilvNode *subject, const LilvNode *predicate)
Definition: lv2_plugin.cc:971
MeterPoint
Definition: types.h:174
AlignChoice
Definition: types.h:168
LIBARDOUR_API bool init(bool with_vst, bool try_optimization, const char *localedir)
Definition: globals.cc:376
virtual bool can_use_mode(TrackMode, bool &)
Definition: track.h:51