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/route.h"
25 #include "ardour/public_diskstream.h"
36 class Track : public Route, public PublicDiskstream
39 Track (Session&, std::string name, Route::Flag f = Route::Flag (0), TrackMode m = Normal, DataType default_type = DataType::AUDIO);
44 bool set_name (const std::string& str);
46 TrackMode mode () const { return _mode; }
47 virtual int set_mode (TrackMode /*m*/) { return false; }
48 virtual bool can_use_mode (TrackMode /*m*/, bool& /*bounce_required*/) { return false; }
49 PBD::Signal0<void> TrackModeChanged;
51 virtual int no_roll (pframes_t nframes, framepos_t start_frame, framepos_t end_frame,
52 bool state_changing, bool can_record, bool rec_monitors_input);
54 int silent_roll (pframes_t nframes, framepos_t start_frame, framepos_t end_frame,
55 bool can_record, bool rec_monitors_input, bool& need_butler);
57 virtual int roll (pframes_t nframes, framepos_t start_frame, framepos_t end_frame,
58 int declick, bool can_record, bool rec_monitors_input, bool& need_butler) = 0;
60 bool needs_butler() const { return _needs_butler; }
61 void toggle_monitor_input ();
63 virtual DataType data_type () const = 0;
67 virtual void use_new_diskstream () = 0;
68 virtual void set_diskstream (boost::shared_ptr<Diskstream>);
70 framecnt_t update_total_latency();
71 void set_latency_delay (framecnt_t);
79 FreezeState freeze_state() const;
81 virtual void freeze_me (InterThreadInfo&) = 0;
82 virtual void unfreeze () = 0;
84 virtual boost::shared_ptr<Region> bounce (InterThreadInfo&) = 0;
85 virtual boost::shared_ptr<Region> bounce_range (framepos_t start, framepos_t end, InterThreadInfo&, bool enable_processing = true) = 0;
88 XMLNode& get_template();
89 virtual int set_state (const XMLNode&, int version) = 0;
90 static void zero_diskstream_id_in_xml (XMLNode&);
92 boost::shared_ptr<PBD::Controllable> rec_enable_control() { return _rec_enable_control; }
94 bool record_enabled() const;
95 void set_record_enabled (bool yn, void *src);
97 /* XXX: unfortunate that this is exposed */
98 PBD::ID const & diskstream_id () const;
100 void set_block_size (pframes_t);
102 /** @return true if the track can be bounced, or false if it cannot because
103 * it has more outputs than diskstream channels.
105 virtual bool bounceable () const = 0;
107 /* PublicDiskstream interface */
108 boost::shared_ptr<Playlist> playlist ();
109 void monitor_input (bool);
110 bool destructive () const;
111 std::list<boost::shared_ptr<Source> > & last_capture_sources ();
112 void set_capture_offset ();
113 std::list<boost::shared_ptr<Source> > steal_write_sources();
114 void reset_write_sources (bool, bool force = false);
115 float playback_buffer_load () const;
116 float capture_buffer_load () const;
118 int do_flush (RunContext, bool force = false);
119 uint32_t read_data_count() const;
120 uint32_t write_data_count() const;
121 void set_pending_overwrite (bool);
122 int seek (framepos_t, bool complete_refill = false);
123 bool hidden () const;
124 int can_internal_playback_seek (framepos_t);
125 int internal_playback_seek (framepos_t);
126 void non_realtime_input_change ();
127 void non_realtime_locate (framepos_t);
128 void non_realtime_set_speed ();
129 int overwrite_existing_buffers ();
130 framecnt_t get_captured_frames (uint32_t n = 0) const;
131 int set_loop (Location *);
132 void transport_looped (framepos_t);
133 bool realtime_set_speed (double, bool);
134 void transport_stopped_wallclock (struct tm &, time_t, bool);
135 bool pending_overwrite () const;
136 double speed () const;
137 void prepare_to_stop (framepos_t);
138 void set_slaved (bool);
139 ChanCount n_channels ();
140 framepos_t get_capture_start_frame (uint32_t n = 0) const;
141 AlignStyle alignment_style () const;
142 framepos_t current_capture_start () const;
143 framepos_t current_capture_end () const;
144 void playlist_modified ();
145 int use_playlist (boost::shared_ptr<Playlist>);
146 void set_align_style (AlignStyle);
147 int use_copy_playlist ();
148 int use_new_playlist ();
149 void adjust_playback_buffering ();
150 void adjust_capture_buffering ();
152 PBD::Signal0<void> DiskstreamChanged;
153 PBD::Signal0<void> FreezeChange;
154 PBD::Signal0<void> PlaylistChanged;
155 PBD::Signal0<void> RecordEnableChanged;
156 PBD::Signal0<void> SpeedChanged;
157 PBD::Signal0<void> AlignmentStyleChanged;
160 virtual XMLNode& state (bool full) = 0;
162 boost::shared_ptr<Diskstream> _diskstream;
163 MeterPoint _saved_meter_point;
168 struct FreezeRecordProcessorInfo {
169 FreezeRecordProcessorInfo(XMLNode& st, boost::shared_ptr<Processor> proc)
170 : state (st), processor (proc) {}
173 boost::shared_ptr<Processor> processor;
177 struct FreezeRecord {
179 : have_mementos(false)
184 boost::shared_ptr<Playlist> playlist;
185 std::vector<FreezeRecordProcessorInfo*> processor_info;
190 struct RecEnableControllable : public PBD::Controllable {
191 RecEnableControllable (Track&);
193 void set_value (double);
194 double get_value (void) const;
199 virtual void set_state_part_two () = 0;
201 FreezeRecord _freeze_record;
202 XMLNode* pending_state;
205 virtual bool send_silence () const;
207 boost::shared_ptr<RecEnableControllable> _rec_enable_control;
210 void diskstream_playlist_changed ();
211 void diskstream_record_enable_changed ();
212 void diskstream_speed_changed ();
213 void diskstream_alignment_style_changed ();
216 }; /* namespace ARDOUR*/
218 #endif /* __ardour_track_h__ */