Merged with trunk R708
[ardour.git] / libs / ardour / ardour / track.h
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 <ardour/route.h>
23
24 namespace ARDOUR {
25
26 class Session;
27 class Diskstream;
28 class Playlist;
29 class RouteGroup;
30
31 class Track : public Route
32 {
33   public:
34         Track (Session&, string name, Route::Flag f = Route::Flag (0), TrackMode m = Normal, Buffer::Type default_type = Buffer::AUDIO);
35
36         virtual ~Track () {}
37         
38         virtual int set_name (string str, void *src) = 0;
39
40         virtual int roll (jack_nframes_t nframes, jack_nframes_t start_frame, jack_nframes_t end_frame, 
41                 jack_nframes_t offset, int declick, bool can_record, bool rec_monitors_input) = 0;
42         
43         virtual int no_roll (jack_nframes_t nframes, jack_nframes_t start_frame, jack_nframes_t end_frame, 
44                 jack_nframes_t offset, bool state_changing, bool can_record, bool rec_monitors_input) = 0;
45         
46         virtual int silent_roll (jack_nframes_t nframes, jack_nframes_t start_frame, jack_nframes_t end_frame, 
47                 jack_nframes_t offset, bool can_record, bool rec_monitors_input) = 0;
48
49         void toggle_monitor_input ();
50
51         bool can_record() const { return true; }
52         virtual void set_record_enable (bool yn, void *src) = 0;
53
54         Diskstream& diskstream() const { return *_diskstream; }
55
56         virtual int use_diskstream (string name) = 0;
57         virtual int use_diskstream (const PBD::ID& id) = 0;
58
59         TrackMode    mode() const { return _mode; }
60         virtual void set_mode (TrackMode m) = 0;
61
62         jack_nframes_t update_total_latency();
63         virtual void   set_latency_delay (jack_nframes_t) = 0;
64
65         enum FreezeState {
66                 NoFreeze,
67                 Frozen,
68                 UnFrozen
69         };
70
71         FreezeState freeze_state() const;
72  
73         virtual void freeze (InterThreadInfo&) = 0;
74         virtual void unfreeze () = 0;
75
76         virtual void bounce (InterThreadInfo&) = 0;
77         virtual void bounce_range (jack_nframes_t start, jack_nframes_t end, InterThreadInfo&) = 0;
78
79         XMLNode&    get_state();
80         XMLNode&    get_template();
81         virtual int set_state(const XMLNode& node) = 0;
82
83         PBD::Controllable& rec_enable_control() { return _rec_enable_control; }
84
85         virtual bool record_enabled() const = 0;
86         void set_meter_point (MeterPoint, void* src);
87         
88         sigc::signal<void>       ModeChanged;
89         sigc::signal<void,void*> DiskstreamChanged;
90         sigc::signal<void>       FreezeChange;
91
92   protected:
93         Track (Session& sess, const XMLNode& node, Buffer::Type default_type = Buffer::AUDIO);
94
95         virtual XMLNode& state (bool full) = 0;
96
97         virtual void passthru_silence (jack_nframes_t start_frame, jack_nframes_t end_frame, 
98                 jack_nframes_t nframes, jack_nframes_t offset, int declick, bool meter) = 0;
99
100         virtual uint32_t n_process_buffers () = 0;
101         
102         Diskstream *_diskstream;
103         MeterPoint  _saved_meter_point;
104         TrackMode   _mode;
105
106         //private: (FIXME)
107         struct FreezeRecordInsertInfo {
108             FreezeRecordInsertInfo(XMLNode& st, boost::shared_ptr<Insert> ins) 
109                     : state (st), insert (ins) {}
110
111             XMLNode                   state;
112             boost::shared_ptr<Insert> insert;
113             PBD::ID                   id;
114             UndoAction                memento;
115         };
116
117         struct FreezeRecord {
118             FreezeRecord()
119                 : playlist(0)
120                 , have_mementos(false)
121             {}
122
123             ~FreezeRecord();
124
125             Playlist*                       playlist;
126             vector<FreezeRecordInsertInfo*> insert_info;
127             bool                            have_mementos;
128             FreezeState                     state;
129         };
130
131         struct RecEnableControllable : public PBD::Controllable {
132             RecEnableControllable (Track&);
133             
134             void set_value (float);
135             float get_value (void) const;
136
137             Track& track;
138         };
139
140         //virtual void diskstream_record_enable_changed (void *src) = 0;
141         //virtual void diskstream_input_channel_changed (void *src) = 0;
142
143         //virtual void input_change_handler (void *src) = 0;
144
145         virtual void set_state_part_two () = 0;
146
147         FreezeRecord          _freeze_record;
148         XMLNode*              pending_state;
149         sigc::connection      recenable_connection;
150         sigc::connection      ic_connection;
151         RecEnableControllable _rec_enable_control;
152         bool                  _destructive;
153 };
154
155 }; /* namespace ARDOUR*/
156
157 #endif /* __ardour_track_h__ */