summaryrefslogtreecommitdiffstats
path: root/src/libs/engine/MidiBuffer.h
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2007-04-08 17:00:47 +0000
committerDavid Robillard <d@drobilla.net>2007-04-08 17:00:47 +0000
commitcd0a2541cb9b14bedf200a68ee774b506980775c (patch)
tree97a88e9fe661017e18080f106eef80b90f0ea16e /src/libs/engine/MidiBuffer.h
parentb59584b387c4b77d09ba4c791eb711597f67c8c8 (diff)
downloadingen-cd0a2541cb9b14bedf200a68ee774b506980775c.tar.gz
ingen-cd0a2541cb9b14bedf200a68ee774b506980775c.tar.bz2
ingen-cd0a2541cb9b14bedf200a68ee774b506980775c.zip
LV2 MIDI fixes.
git-svn-id: http://svn.drobilla.net/lad/ingen@417 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/libs/engine/MidiBuffer.h')
-rw-r--r--src/libs/engine/MidiBuffer.h37
1 files changed, 19 insertions, 18 deletions
diff --git a/src/libs/engine/MidiBuffer.h b/src/libs/engine/MidiBuffer.h
index 5a810bc3..79f7098b 100644
--- a/src/libs/engine/MidiBuffer.h
+++ b/src/libs/engine/MidiBuffer.h
@@ -18,7 +18,6 @@
#ifndef MIDIBUFFER_H
#define MIDIBUFFER_H
-#include <lv2ext/lv2-miditype.h>
#include <lv2ext/lv2-midifunctions.h>
#include "Buffer.h"
#include "DataType.h"
@@ -30,15 +29,18 @@ class MidiBuffer : public Buffer {
public:
MidiBuffer(size_t capacity)
: Buffer(DataType(DataType::MIDI), capacity)
- , _state(&_local_state)
- , _local_buf(lv2midi_new((uint32_t)capacity))
- , _buf(_local_buf)
+ , _buf(lv2midi_new((uint32_t)capacity))
, _joined_buf(NULL)
{
+ _local_state.midi = _buf;
+ _state = &_local_state;
+ assert(_local_state.midi);
+ reset(0);
clear();
+ assert(_local_state.midi == _buf);
}
- ~MidiBuffer() { lv2midi_free(_buf); }
+ ~MidiBuffer() { lv2midi_free(_local_state.midi); }
void prepare_read(SampleCount nframes);
void prepare_write(SampleCount nframes);
@@ -49,32 +51,31 @@ public:
uint32_t this_nframes() const { return _this_nframes; }
- inline LV2_MIDI* data() const
- { return ((_joined_buf != NULL) ? _joined_buf->data() : _buf); }
+ inline LV2_MIDIState* data()
+ { return ((_joined_buf != NULL) ? _joined_buf->data() : _state); }
- inline LV2_MIDIState* state() const
- { return ((_joined_buf != NULL) ? _joined_buf->state() : _state); }
+ inline const LV2_MIDIState* data() const
+ { return ((_joined_buf != NULL) ? _joined_buf->data() : _state); }
inline void clear()
- { lv2midi_reset_buffer(_buf); _state->position = 0; }
+ { assert(_state); assert(_state->midi); lv2midi_reset_buffer(_state->midi); _state->position = 0; }
inline void reset(SampleCount nframes)
- { lv2midi_reset_state(_state, _buf, nframes); _this_nframes = nframes; }
+ { assert(_state); assert(_state->midi); lv2midi_reset_state(_state, _state->midi, nframes); _this_nframes = nframes; }
inline double increment()
- { return lv2midi_increment(_state); }
+ { assert(_state); assert(_state->midi); return lv2midi_step(_state); }
inline double get_event(double* timestamp, uint32_t* size, unsigned char** data)
- { return lv2midi_get_event(_state, timestamp, size, data); }
+ { assert(_state); assert(_state->midi); return lv2midi_get_event(_state, timestamp, size, data); }
inline int put_event(double timestamp, uint32_t size, const unsigned char* data)
- { return lv2midi_put_event(_state, timestamp, size, data); }
+ { assert(_state); assert(_state->midi); return lv2midi_put_event(_state, timestamp, size, data); }
private:
- LV2_MIDIState _local_state;
- LV2_MIDIState* _state;
- LV2_MIDI* _local_buf;
- LV2_MIDI* _buf;
+ LV2_MIDIState _local_state;
+ LV2_MIDIState* _state;
+ LV2_MIDI* const _buf;
MidiBuffer* _joined_buf; ///< Buffer to mirror, if joined