c68ea668a5e9ffd04137867b5b7ab3531d7d03e9
[ardour.git] / libs / ardour / ardour / midi_model.h
1
2 /*
3     Copyright (C) 2006 Paul Davis
4         Written by Dave Robillard, 2006
5
6     This program is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10
11     This program is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with this program; if not, write to the Free Software
18     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19
20 */
21
22 #ifndef __ardour_midi_model_h__ 
23 #define __ardour_midi_model_h__
24
25 #include <boost/utility.hpp>
26 #include <ardour/types.h>
27 #include <ardour/buffer.h>
28
29 namespace ARDOUR {
30
31 /** A dynamically resizable collection of MIDI events, sorted by time
32  */
33 class MidiModel : public boost::noncopyable {
34 public:
35         MidiModel(size_t size=0);
36         ~MidiModel();
37
38         void clear() { _events.clear(); }
39
40         /** Resizes vector if necessary (NOT realtime safe) */
41         void append(const MidiBuffer& data);
42         
43         /** Resizes vector if necessary (NOT realtime safe) */
44         void append(double time, size_t size, Byte* in_buffer);
45         
46         inline const MidiEvent& event_at(unsigned i) const { return _events[i]; }
47
48         inline size_t n_events() const { return _events.size(); }
49
50 private:
51         std::vector<MidiEvent> _events;
52 };
53
54 } /* namespace ARDOUR */
55
56 #endif /* __ardour_midi_model_h__ */
57