diff options
author | David Robillard <d@drobilla.net> | 2007-04-08 17:00:47 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2007-04-08 17:00:47 +0000 |
commit | cd0a2541cb9b14bedf200a68ee774b506980775c (patch) | |
tree | 97a88e9fe661017e18080f106eef80b90f0ea16e /src/libs | |
parent | b59584b387c4b77d09ba4c791eb711597f67c8c8 (diff) | |
download | ingen-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')
-rw-r--r-- | src/libs/engine/LV2Node.cpp | 2 | ||||
-rw-r--r-- | src/libs/engine/MidiBuffer.cpp | 8 | ||||
-rw-r--r-- | src/libs/engine/MidiBuffer.h | 37 |
3 files changed, 23 insertions, 24 deletions
diff --git a/src/libs/engine/LV2Node.cpp b/src/libs/engine/LV2Node.cpp index f05a477b..4ea29d1f 100644 --- a/src/libs/engine/LV2Node.cpp +++ b/src/libs/engine/LV2Node.cpp @@ -187,7 +187,7 @@ LV2Node::set_port_buffer(size_t voice, size_t port_num, Buffer* buf) if (buf->type() == DataType::FLOAT) slv2_instance_connect_port(_instances[voice], port_num, ((AudioBuffer*)buf)->data()); else if (buf->type() == DataType::MIDI) - slv2_instance_connect_port(_instances[voice], port_num, ((MidiBuffer*)buf)->data()); + slv2_instance_connect_port(_instances[voice], port_num, ((MidiBuffer*)buf)->data()->midi); } diff --git a/src/libs/engine/MidiBuffer.cpp b/src/libs/engine/MidiBuffer.cpp index 35bda0a0..3dcb7b4c 100644 --- a/src/libs/engine/MidiBuffer.cpp +++ b/src/libs/engine/MidiBuffer.cpp @@ -38,8 +38,7 @@ MidiBuffer::join(Buffer* buf) _joined_buf = mbuf; - _buf = mbuf->data(); - _state = mbuf->state(); + _state = mbuf->data(); return true; } @@ -49,8 +48,9 @@ void MidiBuffer::unjoin() { _joined_buf = NULL; - _buf = _local_buf; _state = &_local_state; + _state->midi = _buf; + clear(); reset(_this_nframes); } @@ -71,7 +71,6 @@ void MidiBuffer::prepare_read(SampleCount nframes) { assert(!_joined_buf || data() == _joined_buf->data()); - assert(!_joined_buf || state() == _joined_buf->state()); reset(nframes); } @@ -84,7 +83,6 @@ MidiBuffer::prepare_write(SampleCount nframes) reset(nframes); assert(!_joined_buf || data() == _joined_buf->data()); - assert(!_joined_buf || state() == _joined_buf->state()); } 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 |