a956878348e771d733671ba281821f8d8877d9d1
[ardour.git] / libs / ardour / ardour / midi_playlist.h
1 /*
2     Copyright (C) 2006 Paul Davis 
3         Written by Dave Robillard, 2006
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_playlist_h__
21 #define __ardour_midi_playlist_h__
22
23 #include <vector>
24 #include <list>
25
26 #include <ardour/ardour.h>
27 #include <ardour/playlist.h>
28 #include <evoral/Parameter.hpp>
29
30 namespace ARDOUR
31 {
32
33 class Session;
34 class Region;
35 class MidiRegion;
36 class Source;
37 template<typename T> class MidiRingBuffer;
38
39 class MidiPlaylist : public ARDOUR::Playlist
40 {
41 public:
42         MidiPlaylist (Session&, const XMLNode&, bool hidden = false);
43         MidiPlaylist (Session&, string name, bool hidden = false);
44         MidiPlaylist (boost::shared_ptr<const MidiPlaylist> other, string name, bool hidden = false);
45         MidiPlaylist (boost::shared_ptr<const MidiPlaylist> other, nframes_t start, nframes_t cnt,
46                       string name, bool hidden = false);
47
48         ~MidiPlaylist ();
49
50         nframes_t read (MidiRingBuffer<nframes_t>& buf,
51                         nframes_t start, nframes_t cnt, uint32_t chan_n=0);
52
53         int set_state (const XMLNode&);
54         UndoAction get_memento() const;
55
56         bool destroy_region (boost::shared_ptr<Region>);
57         
58         void set_note_mode (NoteMode m) { _note_mode = m; }
59
60         std::set<Evoral::Parameter> contained_automation();
61
62 protected:
63
64         /* playlist "callbacks" */
65
66         void finalize_split_region (boost::shared_ptr<Region> original, boost::shared_ptr<Region> left, boost::shared_ptr<Region> right);
67         
68         void check_dependents (boost::shared_ptr<Region> region, bool norefresh);
69         void refresh_dependents (boost::shared_ptr<Region> region);
70         void remove_dependents (boost::shared_ptr<Region> region);
71
72 private:
73         void dump () const;
74
75         bool region_changed (Change, boost::shared_ptr<Region>);
76         
77         NoteMode _note_mode;  
78 };
79
80 } /* namespace ARDOUR */
81
82 #endif  /* __ardour_midi_playlist_h__ */
83
84