committed INCOMPLETE 24bit filesource support
[ardour.git] / libs / ardour / ardour / audio_track.h
1 /*
2     Copyright (C) 2002-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     $Id$
19 */
20
21 #ifndef __ardour_audio_track_h__
22 #define __ardour_audio_track_h__
23
24 #include <ardour/route.h>
25
26 namespace ARDOUR {
27
28 class Session;
29 class DiskStream;
30 class AudioPlaylist;
31
32 class AudioTrack : public Route
33 {
34   public:
35         AudioTrack (Session&, string name, Route::Flag f = Route::Flag (0), TrackMode m = Normal);
36         AudioTrack (Session&, const XMLNode&);
37         ~AudioTrack ();
38         
39         int set_name (string str, void *src);
40
41         int  roll (jack_nframes_t nframes, jack_nframes_t start_frame, jack_nframes_t end_frame, 
42
43                    jack_nframes_t offset, int declick, bool can_record, bool rec_monitors_input);
44         int  no_roll (jack_nframes_t nframes, jack_nframes_t start_frame, jack_nframes_t end_frame, 
45                       jack_nframes_t offset, bool state_changing, bool can_record, bool rec_monitors_input);
46         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);
48
49         void toggle_monitor_input ();
50
51         bool can_record() const { return true; }
52         void set_record_enable (bool yn, void *src);
53
54         DiskStream& disk_stream() const { return *diskstream; }
55         int set_diskstream (DiskStream&, void *);
56         int use_diskstream (string name);
57         int use_diskstream (id_t id);
58
59         TrackMode mode() const { return _mode; }
60         void set_mode (TrackMode m);
61         sigc::signal<void> ModeChanged;
62
63         jack_nframes_t update_total_latency();
64         void set_latency_delay (jack_nframes_t);
65         
66         int export_stuff (vector<Sample*>& buffers, char * workbuf, uint32_t nbufs, jack_nframes_t nframes, jack_nframes_t end_frame);
67
68         sigc::signal<void,void*> diskstream_changed;
69
70         enum FreezeState {
71                 NoFreeze,
72                 Frozen,
73                 UnFrozen
74         };
75
76         FreezeState freeze_state() const;
77
78         sigc::signal<void> FreezeChange;
79  
80         void freeze (InterThreadInfo&);
81         void unfreeze ();
82
83         void bounce (InterThreadInfo&);
84         void bounce_range (jack_nframes_t start, jack_nframes_t end, InterThreadInfo&);
85
86         XMLNode& get_state();
87         int set_state(const XMLNode& node);
88
89         MIDI::Controllable& midi_rec_enable_control() {
90                 return _midi_rec_enable_control;
91         }
92
93         void reset_midi_control (MIDI::Port*, bool);
94         void send_all_midi_feedback ();
95
96         bool record_enabled() const;
97         void set_meter_point (MeterPoint, void* src);
98
99   protected:
100         DiskStream *diskstream;
101         MeterPoint _saved_meter_point;
102         TrackMode _mode;
103
104         void passthru_silence (jack_nframes_t start_frame, jack_nframes_t end_frame, 
105                                jack_nframes_t nframes, jack_nframes_t offset, int declick,
106                                bool meter);
107
108         uint32_t n_process_buffers ();
109
110   private:
111         struct FreezeRecordInsertInfo {
112             FreezeRecordInsertInfo(XMLNode& st) 
113                     : state (st), insert (0) {}
114
115             XMLNode  state;
116             Insert*  insert;
117             id_t     id;
118             UndoAction memento;
119         };
120
121         struct FreezeRecord {
122             FreezeRecord() {
123                     playlist = 0;
124                     have_mementos = false;
125             }
126
127             ~FreezeRecord();
128
129             AudioPlaylist* playlist;
130             vector<FreezeRecordInsertInfo*> insert_info;
131             bool have_mementos;
132             FreezeState state;
133         };
134
135         FreezeRecord _freeze_record;
136         XMLNode* pending_state;
137
138         void diskstream_record_enable_changed (void *src);
139         void diskstream_input_channel_changed (void *src);
140
141         void input_change_handler (void *src);
142
143         sigc::connection recenable_connection;
144         sigc::connection ic_connection;
145
146         XMLNode& state(bool);
147
148         int deprecated_use_diskstream_connections ();
149         void set_state_part_two ();
150         void set_state_part_three ();
151
152         struct MIDIRecEnableControl : public MIDI::Controllable {
153                 MIDIRecEnableControl (AudioTrack&, MIDI::Port *);
154                 void set_value (float);
155                 void send_feedback (bool);
156                 MIDI::byte* write_feedback (MIDI::byte* buf, int32_t& bufsize, bool val, bool force = false);
157                 AudioTrack& track;
158                 bool setting;
159                 bool last_written;
160         };
161
162         MIDIRecEnableControl _midi_rec_enable_control;
163
164         bool _destructive;
165 };
166
167 }; /* namespace ARDOUR*/
168
169 #endif /* __ardour_audio_track_h__ */