diff options
author | David Robillard <d@drobilla.net> | 2008-05-20 05:21:43 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2008-05-20 05:21:43 +0000 |
commit | 34093b89423e7d195972e68676c73853228d35f6 (patch) | |
tree | efaad4b4a3dd095f52cc90fd2af7db6c0dc33c40 | |
parent | 240f6f0c4e6f5d2770fd166f162df41906e2e230 (diff) | |
download | ingen-34093b89423e7d195972e68676c73853228d35f6.tar.gz ingen-34093b89423e7d195972e68676c73853228d35f6.tar.bz2 ingen-34093b89423e7d195972e68676c73853228d35f6.zip |
Fix direct midi in -> midi out connections in root patch with plugins present.
Fix Jack MIDI output.
Attempted fixes for LV2 UI MIDI event writing, but.. still not working?
git-svn-id: http://svn.drobilla.net/lad/ingen@1223 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r-- | src/libs/engine/DuplexPort.cpp | 36 | ||||
-rw-r--r-- | src/libs/engine/EventBuffer.cpp | 1 | ||||
-rw-r--r-- | src/libs/engine/InputPort.cpp | 11 | ||||
-rw-r--r-- | src/libs/engine/JackMidiDriver.cpp | 14 | ||||
-rw-r--r-- | src/libs/engine/PatchImpl.cpp | 24 | ||||
-rw-r--r-- | src/libs/engine/PortImpl.cpp | 1 | ||||
-rw-r--r-- | src/libs/engine/PortImpl.hpp | 3 | ||||
-rw-r--r-- | src/libs/engine/events/SetPortValueEvent.cpp | 18 |
8 files changed, 70 insertions, 38 deletions
diff --git a/src/libs/engine/DuplexPort.cpp b/src/libs/engine/DuplexPort.cpp index 7fde9d0d..71a65e4f 100644 --- a/src/libs/engine/DuplexPort.cpp +++ b/src/libs/engine/DuplexPort.cpp @@ -24,6 +24,7 @@ #include "OutputPort.hpp" #include "NodeImpl.hpp" #include "ProcessContext.hpp" +#include "EventBuffer.hpp" using namespace std; @@ -45,14 +46,22 @@ DuplexPort::pre_process(ProcessContext& context) { // <BrainHurt> - /*cerr << path() << " duplex pre: fixed buffers: " << fixed_buffers() << endl; + /*cerr << endl << "{ duplex pre" << endl; + cerr << path() << " duplex pre: fixed buffers: " << fixed_buffers() << endl; 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;*/ + if (_is_output) { for (uint32_t i=0; i < _poly; ++i) - _buffers->at(i)->prepare_write(context.nframes()); + if (!_buffers->at(i)->is_joined()) + _buffers->at(i)->prepare_write(context.nframes()); } else { @@ -62,7 +71,7 @@ DuplexPort::pre_process(ProcessContext& context) broadcast(context); } - //cerr << "} pre " << path() << endl; + //cerr << "} duplex pre " << path() << endl; // </BrainHurt> } @@ -71,20 +80,27 @@ DuplexPort::pre_process(ProcessContext& context) void DuplexPort::post_process(ProcessContext& context) { - /*cerr << path() << " duplex post: fixed buffers: " << fixed_buffers() << endl; + // <BrainHurt> + + /*cerr << endl << "{ duplex post" << endl; + cerr << path() << " duplex post: fixed buffers: " << fixed_buffers() << endl; cerr << path() << " duplex post: buffer: " << buffer(0) << endl; - cerr << path() << " duplex post: is_output: " << _is_output << " { " << endl;*/ + cerr << path() << " duplex post: is_output: " << _is_output << " { " << endl; - // <BrainHurt> + 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;*/ + if (_is_output) { InputPort::pre_process(context); // Mix down inputs broadcast(context); } - - OutputPort::pre_process(context); - // </BrainHurt> - //cerr << "} post " << path() << endl; + //cerr << "} duplex post " << path() << endl; + + // </BrainHurt> } diff --git a/src/libs/engine/EventBuffer.cpp b/src/libs/engine/EventBuffer.cpp index c9b4f249..de15c601 100644 --- a/src/libs/engine/EventBuffer.cpp +++ b/src/libs/engine/EventBuffer.cpp @@ -57,6 +57,7 @@ EventBuffer::EventBuffer(size_t capacity) //cerr << "Creating MIDI Buffer " << _buf << ", capacity = " << _buf->capacity << endl; } + EventBuffer::~EventBuffer() { free(_local_buf); diff --git a/src/libs/engine/InputPort.cpp b/src/libs/engine/InputPort.cpp index 7a90bc21..052ccde0 100644 --- a/src/libs/engine/InputPort.cpp +++ b/src/libs/engine/InputPort.cpp @@ -155,6 +155,11 @@ InputPort::is_connected_to(const OutputPort* port) const void InputPort::pre_process(ProcessContext& context) { + // If value has been set (e.g. events pushed) by the user, + // don't do anything this cycle to avoid smashing the value + if (_set_by_user) + return; + bool do_mixdown = true; if (_connections.size() == 0) { @@ -221,8 +226,8 @@ InputPort::pre_process(ProcessContext& context) assert(_poly == 1); // FIXME - //if (_connections.size() > 1) - // cerr << "WARNING: MIDI mixing not implemented, only first connection used." << endl; + if (_connections.size() > 1) + cerr << "WARNING: MIDI mixing not implemented, only first connection used." << endl; // Copy first connection _buffers->at(0)->copy( @@ -239,6 +244,8 @@ InputPort::post_process(ProcessContext& context) // Prepare for next cycle for (uint32_t i=0; i < _poly; ++i) buffer(i)->prepare_write(context.nframes()); + + _set_by_user = false; /*if (_broadcast && (_type == DataType::CONTROL)) { const Sample value = ((AudioBuffer*)(*_buffers)[0])->value_at(0); diff --git a/src/libs/engine/JackMidiDriver.cpp b/src/libs/engine/JackMidiDriver.cpp index 2cdd2489..d6808fcc 100644 --- a/src/libs/engine/JackMidiDriver.cpp +++ b/src/libs/engine/JackMidiDriver.cpp @@ -39,10 +39,10 @@ namespace Ingen { //// JackMidiPort //// JackMidiPort::JackMidiPort(JackMidiDriver* driver, DuplexPort* patch_port) -: DriverPort(patch_port), - Raul::List<JackMidiPort*>::Node(this), - _driver(driver), - _jack_port(NULL) + : DriverPort(patch_port) + , Raul::List<JackMidiPort*>::Node(this) + , _driver(driver) + , _jack_port(NULL) { assert(patch_port->poly() == 1); @@ -146,9 +146,9 @@ bool JackMidiDriver::_midi_thread_exit_flag = true; JackMidiDriver::JackMidiDriver(jack_client_t* client) -: _client(client), - _is_activated(false), - _is_enabled(false) + : _client(client) + , _is_activated(false) + , _is_enabled(false) { } diff --git a/src/libs/engine/PatchImpl.cpp b/src/libs/engine/PatchImpl.cpp index dba3d747..1625d1c3 100644 --- a/src/libs/engine/PatchImpl.cpp +++ b/src/libs/engine/PatchImpl.cpp @@ -34,12 +34,12 @@ namespace Ingen { PatchImpl::PatchImpl(Engine& engine, const string& path, uint32_t poly, PatchImpl* parent, SampleRate srate, size_t buffer_size, uint32_t internal_poly) -: NodeBase(new PatchPlugin("http://example.org/FIXME", "patch", "Ingen Patch"), - path, poly, parent, srate, buffer_size), - _engine(engine), - _internal_poly(internal_poly), - _compiled_patch(NULL), - _process(false) + : NodeBase(new PatchPlugin("http://example.org/FIXME", "patch", "Ingen Patch"), + path, poly, parent, srate, buffer_size) + , _engine(engine) + , _internal_poly(internal_poly) + , _compiled_patch(NULL) + , _process(false) { assert(internal_poly >= 1); } @@ -139,7 +139,7 @@ PatchImpl::apply_internal_poly(Raul::Maid& maid, uint32_t poly) void PatchImpl::process(ProcessContext& context) { - if (_compiled_patch == NULL || _compiled_patch->size() == 0 || !_process) + if (!_process) return; NodeBase::pre_process(context); @@ -152,10 +152,12 @@ PatchImpl::process(ProcessContext& context) << ((MidiBuffer*)_ports->at(i)->buffer(0))->event_count() << endl;*/ /* Run */ - if (_engine.process_slaves().size() > 0) - process_parallel(context); - else - process_single(context); + if (_compiled_patch && _compiled_patch->size() > 0) { + if (_engine.process_slaves().size() > 0) + process_parallel(context); + else + process_single(context); + } NodeBase::post_process(context); } diff --git a/src/libs/engine/PortImpl.cpp b/src/libs/engine/PortImpl.cpp index 04296a04..cefe93a4 100644 --- a/src/libs/engine/PortImpl.cpp +++ b/src/libs/engine/PortImpl.cpp @@ -47,6 +47,7 @@ PortImpl::PortImpl(NodeImpl* const node, , _value(value) , _fixed_buffers(false) , _broadcast(false) + , _set_by_user(false) , _last_broadcasted_value(_value.type() == Atom::FLOAT ? _value.get_float() : 0.0f) // default? , _buffers(new Raul::Array<Buffer*>(poly)) { diff --git a/src/libs/engine/PortImpl.hpp b/src/libs/engine/PortImpl.hpp index c2e2403d..ca21bb4c 100644 --- a/src/libs/engine/PortImpl.hpp +++ b/src/libs/engine/PortImpl.hpp @@ -105,6 +105,8 @@ public: void broadcast(bool b) { _broadcast = b; } bool broadcast() { return _broadcast; } + void raise_set_by_user_flag() { _set_by_user = true; } + protected: PortImpl(NodeImpl* node, const std::string& name, @@ -125,6 +127,7 @@ protected: Raul::Atom _value; bool _fixed_buffers; bool _broadcast; + bool _set_by_user; Sample _last_broadcasted_value; Raul::Array<Buffer*>* _buffers; diff --git a/src/libs/engine/events/SetPortValueEvent.cpp b/src/libs/engine/events/SetPortValueEvent.cpp index 1abec64b..dd8767d7 100644 --- a/src/libs/engine/events/SetPortValueEvent.cpp +++ b/src/libs/engine/events/SetPortValueEvent.cpp @@ -61,14 +61,14 @@ SetPortValueEvent::SetPortValueEvent(Engine& engine, const string& port_path, uint32_t data_size, const void* data) -: Event(engine, responder, timestamp), - _omni(false), - _voice_num(voice_num), - _port_path(port_path), - _data_size(data_size), - _data(malloc(data_size)), - _port(NULL), - _error(NO_ERROR) + : Event(engine, responder, timestamp) + , _omni(false) + , _voice_num(voice_num) + , _port_path(port_path) + , _data_size(data_size) + , _data(malloc(data_size)) + , _port(NULL) + , _error(NO_ERROR) { memcpy(_data, data, data_size); } @@ -112,7 +112,9 @@ SetPortValueEvent::execute(ProcessContext& context) if (ebuf) { const uint32_t frames = std::max((uint32_t)(_time - context.start()), ebuf->latest_frames()); // FIXME: type + ebuf->prepare_write(context.nframes()); ebuf->append(frames, 0, 0, _data_size, (const unsigned char*)_data); + _port->raise_set_by_user_flag(); return; } } |