2 Copyright (C) 2009 Paul Davis
5 This program is free software; you can redistribute it and/or modify it
6 under the terms of the GNU General Public License as published by the Free
7 Software Foundation; either version 2 of the License, or (at your option)
10 This program is distributed in the hope that it will be useful, but WITHOUT
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 675 Mass Ave, Cambridge, MA 02139, USA.
20 #ifndef __ardour_lv2_event_buffer_h__
21 #define __ardour_lv2_event_buffer_h__
23 #include "lv2ext/lv2_event.h"
24 #include "lv2ext/lv2_event_helpers.h"
29 class LV2EventBuffer {
31 LV2EventBuffer(size_t capacity);
34 inline LV2_Event_Buffer* data() { return _data; }
35 inline const LV2_Event_Buffer* data() const { return _data; }
37 inline void rewind() const { lv2_event_begin(&_iter, _data); }
41 _latest_subframes = 0;
42 _data->event_count = 0;
47 inline size_t event_count() const { return _data->event_count; }
48 inline uint32_t capacity() const { return _data->capacity; }
49 inline uint32_t size() const { return _data->size; }
50 inline uint32_t latest_frames() const { return _latest_frames; }
51 inline uint32_t latest_subframes() const { return _latest_subframes; }
53 bool increment() const;
55 bool is_valid() const;
57 bool get_event(uint32_t* frames,
61 uint8_t** data) const;
63 bool append(uint32_t frames,
69 bool append(const LV2_Event_Buffer* buf);
72 LV2_Event_Buffer* _data; ///< Contents
73 mutable LV2_Event_Iterator _iter; ///< Iterator into _data
74 uint32_t _latest_frames; ///< Latest time of all events (frames)
75 uint32_t _latest_subframes; ///< Latest time of all events (subframes)
81 #endif // __ardour_lv2_event_buffer_h__