Pan automation/serialization fixes.
[ardour.git] / libs / ardour / ardour / midi_track.h
1 /*
2     Copyright (C) 2006 Paul Davis 
3         Written by Dave Robillard
4  
5     This program is free software; you can redistribute it and/or modify
6     it under the terms of the GNU General Public License as published by
7     the Free Software Foundation; either version 2 of the License, or
8     (at your option) any later version.
9  
10     This program is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13     GNU General Public License for more details.
14  
15     You should have received a copy of the GNU General Public License
16     along with this program; if not, write to the Free Software
17     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19
20 #ifndef __ardour_midi_track_h__
21 #define __ardour_midi_track_h__
22
23 #include <ardour/track.h>
24 #include <ardour/midi_ring_buffer.h>
25
26 namespace ARDOUR
27 {
28
29 class Session;
30 class MidiDiskstream;
31 class MidiPlaylist;
32 class RouteGroup;
33
34 class MidiTrack : public Track
35 {
36 public:
37         MidiTrack (Session&, string name, Route::Flag f = Route::Flag (0), TrackMode m = Normal);
38         MidiTrack (Session&, const XMLNode&);
39         ~MidiTrack ();
40         
41         int roll (nframes_t nframes, nframes_t start_frame, nframes_t end_frame, 
42                 nframes_t offset, int declick, bool can_record, bool rec_monitors_input);
43         
44         int no_roll (nframes_t nframes, nframes_t start_frame, nframes_t end_frame, 
45                 nframes_t offset, bool state_changing, bool can_record, bool rec_monitors_input);
46         
47         int silent_roll (nframes_t nframes, nframes_t start_frame, nframes_t end_frame, 
48                 nframes_t offset, bool can_record, bool rec_monitors_input);
49
50         void process_output_buffers (BufferSet& bufs,
51                                      nframes_t start_frame, nframes_t end_frame,
52                                      nframes_t nframes, nframes_t offset, bool with_redirects, int declick,
53                                      bool meter);
54
55         boost::shared_ptr<MidiDiskstream> midi_diskstream() const;
56
57         int use_diskstream (string name);
58         int use_diskstream (const PBD::ID& id);
59
60         int set_mode (TrackMode m);
61
62         void set_latency_delay (nframes_t);
63
64         int export_stuff (BufferSet& bufs,
65                 nframes_t nframes, nframes_t end_frame);
66
67         void freeze (InterThreadInfo&);
68         void unfreeze ();
69
70         void bounce (InterThreadInfo&);
71         void bounce_range (nframes_t start, nframes_t end, InterThreadInfo&);
72
73         int set_state(const XMLNode& node);
74
75         bool write_immediate_event(size_t size, const Byte* buf);
76         
77         struct MidiControl : public AutomationControl {
78             MidiControl(boost::shared_ptr<MidiTrack> route, boost::shared_ptr<AutomationList> al)
79                         : AutomationControl (route->session(), al, al->param_id().to_string())
80                         , _route (route)
81                 {}
82          
83             void set_value (float val);
84    
85                 boost::weak_ptr<MidiTrack> _route;
86         };
87
88 protected:
89         XMLNode& state (bool full);
90         
91         int _set_state (const XMLNode&, bool call_base);
92
93 private:
94         int set_diskstream (boost::shared_ptr<MidiDiskstream> ds);
95         void set_state_part_two ();
96         void set_state_part_three ();
97
98         MidiRingBuffer _immediate_events;
99 };
100
101 } /* namespace ARDOUR*/
102
103 #endif /* __ardour_midi_track_h__ */