summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2009-05-11 19:31:17 +0000
committerDavid Robillard <d@drobilla.net>2009-05-11 19:31:17 +0000
commitcb5287d0379287c461a0ac5b950161244a7fa53b (patch)
tree135aa05d505614ab3a503a3df96324b8a3026126
parent698c38587bd4f0133a132dc363098ff8298ec47b (diff)
downloadingen-cb5287d0379287c461a0ac5b950161244a7fa53b.tar.gz
ingen-cb5287d0379287c461a0ac5b950161244a7fa53b.tar.bz2
ingen-cb5287d0379287c461a0ac5b950161244a7fa53b.zip
Fix subpatch MIDI IO.
Fixes tickets #323 and #332. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@1974 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r--src/engine/ConnectionImpl.cpp16
-rw-r--r--src/engine/DuplexPort.cpp19
-rw-r--r--src/engine/EventBuffer.cpp4
-rw-r--r--src/engine/InternalController.cpp4
-rw-r--r--src/engine/InternalNote.cpp16
-rw-r--r--src/engine/InternalTrigger.cpp4
-rw-r--r--src/engine/JackMidiDriver.cpp3
7 files changed, 36 insertions, 30 deletions
diff --git a/src/engine/ConnectionImpl.cpp b/src/engine/ConnectionImpl.cpp
index b9d5e2af..79361295 100644
--- a/src/engine/ConnectionImpl.cpp
+++ b/src/engine/ConnectionImpl.cpp
@@ -23,9 +23,6 @@
#include "AudioBuffer.hpp"
#include "ProcessContext.hpp"
-/*#include <iostream>
-using namespace std;*/
-
namespace Ingen {
@@ -77,9 +74,9 @@ ConnectionImpl::set_mode()
_mode = COPY;
else if (must_extend())
_mode = EXTEND;
-
- if (type() == DataType::EVENT)
- _mode = DIRECT; // FIXME: kludge
+
+ if (_mode == MIX && type() == DataType::EVENT)
+ _mode = COPY;
}
@@ -166,16 +163,15 @@ ConnectionImpl::process(ProcessContext& context)
* would avoid having to mix multiple times. Probably not a very common
* case, but it would be faster anyway. */
- /*cerr << src_port()->path() << " * " << src_port()->poly()
+ /*std::cerr << src_port()->path() << " * " << src_port()->poly()
<< " -> " << dst_port()->path() << " * " << dst_port()->poly()
- << "\t\tmode: " << (int)_mode << endl;*/
+ << "\t\tmode: " << (int)_mode << std::endl;*/
if (_mode == COPY) {
assert(src_port()->poly() == dst_port()->poly());
const size_t copy_size = std::min(src_port()->buffer_size(), dst_port()->buffer_size());
- for (uint32_t i=0; i < src_port()->poly(); ++i) {
+ for (uint32_t i=0; i < src_port()->poly(); ++i)
dst_port()->buffer(i)->copy(src_port()->buffer(i), 0, copy_size-1);
- }
} else if (_mode == MIX) {
assert(type() == DataType::AUDIO || type() == DataType::CONTROL);
diff --git a/src/engine/DuplexPort.cpp b/src/engine/DuplexPort.cpp
index 3ede6969..9c1f4be6 100644
--- a/src/engine/DuplexPort.cpp
+++ b/src/engine/DuplexPort.cpp
@@ -32,7 +32,7 @@ namespace Ingen {
DuplexPort::DuplexPort(
- NodeImpl* parent,
+ NodeImpl* parent,
const string& name,
uint32_t index,
uint32_t poly,
@@ -60,15 +60,9 @@ DuplexPort::pre_process(ProcessContext& context)
cerr << path() << " duplex pre: buffer: " << buffer(0) << endl;
cerr << path() << " duplex pre: is_output: " << _is_output << " { " << endl;*/
- /*if (type() == DataType::EVENT)
- for (uint32_t i=0; i < _poly; ++i)
- cerr << path() << " (" << buffer(i) << ") # events: "
- << ((EventBuffer*)buffer(i))->event_count()
- << ", joined: " << _buffers->at(i)->is_joined() << endl;*/
-
for (Connections::iterator c = _connections.begin(); c != _connections.end(); ++c)
(*c)->process(context);
-
+
if (_is_output) {
for (uint32_t i=0; i < _poly; ++i)
@@ -84,7 +78,14 @@ DuplexPort::pre_process(ProcessContext& context)
broadcast(context);
}
-
+
+ /*if (type() == DataType::EVENT)
+ for (uint32_t i=0; i < _poly; ++i)
+ cerr << path() << " (" << buffer(i) << ") # events: "
+ << ((EventBuffer*)buffer(i))->event_count()
+ << ", joined: " << _buffers->at(i)->is_joined()
+ << ", is_output: " << _is_output << endl;*/
+
//cerr << "} duplex pre " << path() << endl;
// </BrainHurt>
diff --git a/src/engine/EventBuffer.cpp b/src/engine/EventBuffer.cpp
index 222aaf31..29291f81 100644
--- a/src/engine/EventBuffer.cpp
+++ b/src/engine/EventBuffer.cpp
@@ -96,12 +96,14 @@ EventBuffer::copy(const Buffer* src_buf, size_t start_sample, size_t end_sample)
const EventBuffer* src = dynamic_cast<const EventBuffer*>(src_buf);
assert(src);
assert(_buf->capacity() >= src->_buf->capacity());
+ assert(src->_buf != _buf);
- clear();
+ //clear();
src->rewind();
memcpy(_buf, src->_buf, src->_buf->size());
_this_nframes = end_sample - start_sample;
+ assert(event_count() == src->event_count());
}
diff --git a/src/engine/InternalController.cpp b/src/engine/InternalController.cpp
index b8b75671..e2dede41 100644
--- a/src/engine/InternalController.cpp
+++ b/src/engine/InternalController.cpp
@@ -79,7 +79,9 @@ ControllerNode::process(ProcessContext& context)
uint8_t* buf = NULL;
EventBuffer* const midi_in = (EventBuffer*)_midi_in_port->buffer(0);
- assert(midi_in->this_nframes() == context.nframes());
+ //assert(midi_in->this_nframes() == context.nframes());
+
+ midi_in->rewind();
while (midi_in->get_event(&frames, &subframes, &type, &size, &buf)) {
// FIXME: type
diff --git a/src/engine/InternalNote.cpp b/src/engine/InternalNote.cpp
index 838d0ba7..f5b22c1a 100644
--- a/src/engine/InternalNote.cpp
+++ b/src/engine/InternalNote.cpp
@@ -114,18 +114,18 @@ NoteNode::apply_poly(Raul::Maid& maid, uint32_t poly)
void
NoteNode::process(ProcessContext& context)
{
+ EventBuffer* const midi_in = (EventBuffer*)_midi_in_port->buffer(0);
NodeBase::pre_process(context);
- uint32_t frames = 0;
- uint32_t subframes = 0;
- uint16_t type = 0;
- uint16_t size = 0;
- unsigned char* buf = NULL;
+ uint32_t frames = 0;
+ uint32_t subframes = 0;
+ uint16_t type = 0;
+ uint16_t size = 0;
+ uint8_t* buf = NULL;
- EventBuffer* const midi_in = (EventBuffer*)_midi_in_port->buffer(0);
- assert(midi_in->this_nframes() == context.nframes());
+ //assert(midi_in->this_nframes() == context.nframes());
- //cerr << path() << " # input events: " << midi_in->event_count() << endl;
+ midi_in->rewind();
if (midi_in->event_count() > 0)
while (midi_in->get_event(&frames, &subframes, &type, &size, &buf)) {
diff --git a/src/engine/InternalTrigger.cpp b/src/engine/InternalTrigger.cpp
index 9ff74b40..623b0bc2 100644
--- a/src/engine/InternalTrigger.cpp
+++ b/src/engine/InternalTrigger.cpp
@@ -74,7 +74,9 @@ TriggerNode::process(ProcessContext& context)
uint8_t* buf = NULL;
EventBuffer* const midi_in = (EventBuffer*)_midi_in_port->buffer(0);
- assert(midi_in->this_nframes() == context.nframes());
+ //assert(midi_in->this_nframes() == context.nframes());
+
+ midi_in->rewind();
while (midi_in->get_event(&frames, &subframes, &type, &size, &buf)) {
const FrameTime time = context.start() + (FrameTime)frames;
diff --git a/src/engine/JackMidiDriver.cpp b/src/engine/JackMidiDriver.cpp
index 9f2f25d5..9551b6be 100644
--- a/src/engine/JackMidiDriver.cpp
+++ b/src/engine/JackMidiDriver.cpp
@@ -189,7 +189,10 @@ JackMidiDriver::activate()
void
JackMidiDriver::deactivate()
{
+ for (Raul::List<JackMidiPort*>::iterator i = _ports.begin(); i != _ports.end(); ++i)
+ (*i)->unregister();
_is_activated = false;
+ _ports.clear();
}