1 /*
2  * Copyright (C) 2006-2016 David Robillard <d@drobilla.net>
3  * Copyright (C) 2007-2017 Paul Davis <paul@linuxaudiosystems.com>
4  * Copyright (C) 2009-2012 Carl Hetherington <carl@carlh.net>
5  * Copyright (C) 2013 John Emmas <john@creativepost.co.uk>
6  * Copyright (C) 2017-2019 Robin Gareus <robin@gareus.org>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License along
19  * with this program; if not, write to the Free Software Foundation, Inc.,
20  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21  */
22 
23 #ifndef __ardour_midi_playlist_h__
24 #define __ardour_midi_playlist_h__
25 
26 #include <vector>
27 #include <list>
28 
29 #include <boost/utility.hpp>
30 
31 #include "evoral/Parameter.h"
32 
33 #include "ardour/ardour.h"
34 #include "ardour/midi_cursor.h"
35 #include "ardour/midi_model.h"
36 #include "ardour/midi_state_tracker.h"
37 #include "ardour/playlist.h"
38 #include "evoral/Note.h"
39 #include "evoral/Parameter.h"
40 #include "ardour/rt_midibuffer.h"
41 
42 namespace Evoral {
43 template<typename Time> class EventSink;
44 class                         Beats;
45 }
46 
47 namespace ARDOUR
48 {
49 
50 class BeatsSamplesConverter;
51 class MidiChannelFilter;
52 class MidiRegion;
53 class Session;
54 class Source;
55 
56 template<typename T> class MidiRingBuffer;
57 
58 class LIBARDOUR_API MidiPlaylist : public ARDOUR::Playlist
59 {
60 public:
61 	MidiPlaylist (Session&, const XMLNode&, bool hidden = false);
62 	MidiPlaylist (Session&, std::string name, bool hidden = false);
63 	MidiPlaylist (boost::shared_ptr<const MidiPlaylist> other, std::string name, bool hidden = false);
64 
65 	/** This constructor does NOT notify others (session) */
66 	MidiPlaylist (boost::shared_ptr<const MidiPlaylist> other,
67 	              samplepos_t                           start,
68 	              samplecnt_t                           cnt,
69 	              std::string                           name,
70 	              bool                                  hidden = false);
71 
72 	~MidiPlaylist ();
73 
74 	void render (MidiChannelFilter*);
75 	RTMidiBuffer* rendered();
76 
77 	int set_state (const XMLNode&, int version);
78 
79 	bool destroy_region (boost::shared_ptr<Region>);
80 	void _split_region (boost::shared_ptr<Region>, const MusicSample& position, ThawList& thawlist);
81 
set_note_mode(NoteMode m)82 	void set_note_mode (NoteMode m) { _note_mode = m; }
83 
84 	std::set<Evoral::Parameter> contained_automation();
85 
86   protected:
87 	void remove_dependents (boost::shared_ptr<Region> region);
88 	void region_going_away (boost::weak_ptr<Region> region);
89 
90   private:
91 	void dump () const;
92 
93 	NoteMode     _note_mode;
94 
95 	RTMidiBuffer _rendered;
96 };
97 
98 } /* namespace ARDOUR */
99 
100 #endif /* __ardour_midi_playlist_h__ */
101