diff options
Diffstat (limited to 'src/libs/engine')
-rw-r--r-- | src/libs/engine/LV2Node.cpp | 13 | ||||
-rw-r--r-- | src/libs/engine/MidiBuffer.cpp | 20 | ||||
-rw-r--r-- | src/libs/engine/MidiBuffer.h | 23 |
3 files changed, 33 insertions, 23 deletions
diff --git a/src/libs/engine/LV2Node.cpp b/src/libs/engine/LV2Node.cpp index 4ea29d1f..459d3c78 100644 --- a/src/libs/engine/LV2Node.cpp +++ b/src/libs/engine/LV2Node.cpp @@ -93,7 +93,9 @@ LV2Node::instantiate() SLV2PortClass port_class = slv2_port_get_class(_lv2_plugin, id); - if (port_class == SLV2_AUDIO_INPUT || port_class == SLV2_AUDIO_OUTPUT) + // FIXME: MIDI buffer size? + if (port_class == SLV2_AUDIO_INPUT || port_class == SLV2_AUDIO_OUTPUT + || port_class == SLV2_MIDI_INPUT || port_class == SLV2_MIDI_OUTPUT) port_buffer_size = _buffer_size; else port_buffer_size = 1; @@ -184,10 +186,13 @@ LV2Node::set_port_buffer(size_t voice, size_t port_num, Buffer* buf) { assert(voice < _poly); - if (buf->type() == DataType::FLOAT) + 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()->midi); + } else if (buf->type() == DataType::MIDI) { + cerr << "Connecting " << path() << ":" << port_num << " -> " << + ((MidiBuffer*)buf)->data() << endl; + slv2_instance_connect_port(_instances[voice], port_num, ((MidiBuffer*)buf)->data()); + } } diff --git a/src/libs/engine/MidiBuffer.cpp b/src/libs/engine/MidiBuffer.cpp index 3dcb7b4c..9842b28c 100644 --- a/src/libs/engine/MidiBuffer.cpp +++ b/src/libs/engine/MidiBuffer.cpp @@ -15,13 +15,29 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -//#include <iostream> +#include <iostream> #include "MidiBuffer.h" using namespace std; namespace Ingen { +MidiBuffer::MidiBuffer(size_t capacity) + : Buffer(DataType(DataType::MIDI), capacity) + , _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); + + cerr << "Creating MIDI Buffer " << _buf << ", capacity = " << _buf->capacity << endl; +} + + /** Use another buffer's data instead of the local one. * @@ -38,7 +54,7 @@ MidiBuffer::join(Buffer* buf) _joined_buf = mbuf; - _state = mbuf->data(); + _state = mbuf->_state; return true; } diff --git a/src/libs/engine/MidiBuffer.h b/src/libs/engine/MidiBuffer.h index 79f7098b..54a245df 100644 --- a/src/libs/engine/MidiBuffer.h +++ b/src/libs/engine/MidiBuffer.h @@ -27,19 +27,8 @@ namespace Ingen { class MidiBuffer : public Buffer { public: - MidiBuffer(size_t capacity) - : Buffer(DataType(DataType::MIDI), capacity) - , _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(size_t capacity); + ~MidiBuffer() { lv2midi_free(_local_state.midi); } void prepare_read(SampleCount nframes); @@ -51,11 +40,11 @@ public: uint32_t this_nframes() const { return _this_nframes; } - inline LV2_MIDIState* data() - { return ((_joined_buf != NULL) ? _joined_buf->data() : _state); } + inline LV2_MIDI* data() + { return ((_joined_buf != NULL) ? _joined_buf->data() : _state->midi); } - inline const LV2_MIDIState* data() const - { return ((_joined_buf != NULL) ? _joined_buf->data() : _state); } + inline const LV2_MIDI* data() const + { return ((_joined_buf != NULL) ? _joined_buf->data() : _state->midi); } inline void clear() { assert(_state); assert(_state->midi); lv2midi_reset_buffer(_state->midi); _state->position = 0; } |