diff options
author | David Robillard <d@drobilla.net> | 2007-10-13 20:35:29 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2007-10-13 20:35:29 +0000 |
commit | cf63c971c2a8ee8cc2ddcddb52ce8135cd29619b (patch) | |
tree | caea057e24a2d498b8fc88a44867891e1ec3766c /src/libs/engine/MidiBuffer.cpp | |
parent | 4d440f54870cd3934a49bab1ae98fad3f13f00d4 (diff) | |
download | ingen-cf63c971c2a8ee8cc2ddcddb52ce8135cd29619b.tar.gz ingen-cf63c971c2a8ee8cc2ddcddb52ce8135cd29619b.tar.bz2 ingen-cf63c971c2a8ee8cc2ddcddb52ce8135cd29619b.zip |
Fix sub-patch MIDI I/O.
Make buffer 'joining' (zero-copy connections) significantly less retarded.
git-svn-id: http://svn.drobilla.net/lad/ingen@882 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/libs/engine/MidiBuffer.cpp')
-rw-r--r-- | src/libs/engine/MidiBuffer.cpp | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/src/libs/engine/MidiBuffer.cpp b/src/libs/engine/MidiBuffer.cpp index 618c7476..929ac840 100644 --- a/src/libs/engine/MidiBuffer.cpp +++ b/src/libs/engine/MidiBuffer.cpp @@ -31,7 +31,6 @@ namespace Ingen { MidiBuffer::MidiBuffer(size_t capacity) : Buffer(DataType(DataType::MIDI), capacity) , _latest_stamp(0) - , _joined_buf(NULL) { if (capacity > UINT32_MAX) { cerr << "MIDI buffer size " << capacity << " too large, aborting." << endl; @@ -98,20 +97,11 @@ MidiBuffer::unjoin() } -bool -MidiBuffer::is_joined_to(Buffer* buf) const -{ - MidiBuffer* mbuf = dynamic_cast<MidiBuffer*>(buf); - if (mbuf) - return (data() == mbuf->data()); - - return false; -} - - void MidiBuffer::prepare_read(SampleCount nframes) { + //cerr << "\t" << this << " prepare_read: " << event_count() << endl; + rewind(); _this_nframes = nframes; } @@ -120,6 +110,7 @@ MidiBuffer::prepare_read(SampleCount nframes) void MidiBuffer::prepare_write(SampleCount nframes) { + //cerr << "\t" << this << " prepare_write: " << event_count() << endl; reset(nframes); } @@ -214,17 +205,19 @@ MidiBuffer::get_event(double* timestamp, uint32_t* size, unsigned char** data) const { - if (_position >= _buf->size) { - _position = _buf->size; + const LV2_MIDI* buf = this->data(); + + if (_position >= buf->size) { + _position = buf->size; *timestamp = _this_nframes; *size = 0; *data = NULL; return _this_nframes; } - *timestamp = *(double*)(_buf->data + _position); - *size = *(uint32_t*)(_buf->data + _position + sizeof(double)); - *data = _buf->data + _position + sizeof(double) + sizeof(uint32_t); + *timestamp = *(double*)(buf->data + _position); + *size = *(uint32_t*)(buf->data + _position + sizeof(double)); + *data = buf->data + _position + sizeof(double) + sizeof(uint32_t); return *timestamp; } |