summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2007-09-30 17:36:38 +0000
committerDavid Robillard <d@drobilla.net>2007-09-30 17:36:38 +0000
commitc40ddfc0eebbcb3333d6cc9e3df7fb62ecb45941 (patch)
tree6e73d5d43284335031cee32f9225b698f315a59d
parent829075dff9fe5d0b3f243f9e40256563a5f8e09a (diff)
downloadingen-c40ddfc0eebbcb3333d6cc9e3df7fb62ecb45941.tar.gz
ingen-c40ddfc0eebbcb3333d6cc9e3df7fb62ecb45941.tar.bz2
ingen-c40ddfc0eebbcb3333d6cc9e3df7fb62ecb45941.zip
Better driver interface for input/output.
MIDI output (pass-through anyway, plugin->output is still screwy). Fix crash on failure to instantiate LV2 plugin. git-svn-id: http://svn.drobilla.net/lad/ingen@786 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r--src/libs/engine/Connection.cpp26
-rw-r--r--src/libs/engine/DSSINode.hpp2
-rw-r--r--src/libs/engine/DuplexPort.cpp8
-rw-r--r--src/libs/engine/DuplexPort.hpp2
-rw-r--r--src/libs/engine/GraphObject.hpp2
-rw-r--r--src/libs/engine/InputPort.hpp2
-rw-r--r--src/libs/engine/JackAudioDriver.cpp25
-rw-r--r--src/libs/engine/JackMidiDriver.cpp68
-rw-r--r--src/libs/engine/JackMidiDriver.hpp6
-rw-r--r--src/libs/engine/LADSPANode.hpp2
-rw-r--r--src/libs/engine/LV2Node.cpp4
-rw-r--r--src/libs/engine/LV2Node.hpp2
-rw-r--r--src/libs/engine/MidiBuffer.cpp52
-rw-r--r--src/libs/engine/MidiBuffer.hpp1
-rw-r--r--src/libs/engine/MidiControlNode.hpp2
-rw-r--r--src/libs/engine/MidiDriver.hpp24
-rw-r--r--src/libs/engine/MidiNoteNode.hpp2
-rw-r--r--src/libs/engine/MidiTriggerNode.hpp2
-rw-r--r--src/libs/engine/Node.hpp2
-rw-r--r--src/libs/engine/NodeBase.cpp5
-rw-r--r--src/libs/engine/NodeBase.hpp2
-rw-r--r--src/libs/engine/OutputPort.hpp2
-rw-r--r--src/libs/engine/Patch.hpp2
-rw-r--r--src/libs/engine/TransportNode.hpp2
-rw-r--r--src/libs/engine/events/AddPortEvent.cpp12
25 files changed, 194 insertions, 65 deletions
diff --git a/src/libs/engine/Connection.cpp b/src/libs/engine/Connection.cpp
index c2ecb2ec..47893acb 100644
--- a/src/libs/engine/Connection.cpp
+++ b/src/libs/engine/Connection.cpp
@@ -51,6 +51,9 @@ Connection::Connection(Port* src_port, Port* dst_port)
/*assert((src_port->parent_node()->poly() == dst_port->parent_node()->poly())
|| (src_port->parent_node()->poly() == 1 || dst_port->parent_node()->poly() == 1));*/
+ if (type() == DataType::MIDI)
+ _must_mix = false; // FIXME: kludge
+
if (_must_mix)
_local_buffer = BufferFactory::create(dst_port->type(), dst_port->buffer(0)->size());
@@ -81,10 +84,11 @@ Connection::set_buffer_size(size_t size)
void
Connection::prepare_poly(uint32_t poly)
{
- _must_mix = (type() == DataType::FLOAT) && (poly > 1) && (
- (_src_port->poly() != _dst_port->poly())
- || (_src_port->polyphonic() && !_dst_port->polyphonic())
- || (_src_port->parent()->polyphonic() && !_dst_port->parent()->polyphonic()) );
+ if (type() == DataType::FLOAT)
+ _must_mix = (poly > 1) && (
+ (_src_port->poly() != _dst_port->poly())
+ || (_src_port->polyphonic() && !_dst_port->polyphonic())
+ || (_src_port->parent()->polyphonic() && !_dst_port->parent()->polyphonic()) );
/*cerr << src_port()->path() << " * " << src_port()->poly()
<< " -> " << dst_port()->path() << " * " << dst_port()->poly()
@@ -118,19 +122,13 @@ Connection::process(SampleCount nframes, FrameTime start, FrameTime end)
* would avoid having to mix multiple times. Probably not a very common
* case, but it would be faster anyway. */
- // FIXME: Implement MIDI mixing
-
- if (_must_mix) {
- assert(type() == DataType::FLOAT);
+ if (_must_mix && type() == DataType::FLOAT) {
const AudioBuffer* const src_buffer = (AudioBuffer*)src_port()->buffer(0);
AudioBuffer* mix_buf = (AudioBuffer*)_local_buffer;
const size_t copy_size = std::min(src_buffer->size(), mix_buf->size());
- /*cerr << "[Connection] Mixing " << src_port()->path() << " * " << src_port()->poly()
- << " -> " << dst_port()->path() << " * " << dst_port()->poly() << endl;*/
-
// Copy src buffer to start of mix buffer
mix_buf->copy((AudioBuffer*)src_port()->buffer(0), 0, copy_size-1);
@@ -156,7 +154,13 @@ Connection::process(SampleCount nframes, FrameTime start, FrameTime end)
// Scale the buffer down.
if (src_port()->poly() > 1)
mix_buf->scale(1.0f/(float)src_port()->poly(), 0, _buffer_size-1);
+
+ } else if (_must_mix && type() == DataType::MIDI) {
+
+ cerr << "WARNING: No MIDI mixing." << endl;
+
}
+
}
diff --git a/src/libs/engine/DSSINode.hpp b/src/libs/engine/DSSINode.hpp
index 1e24836d..418be920 100644
--- a/src/libs/engine/DSSINode.hpp
+++ b/src/libs/engine/DSSINode.hpp
@@ -54,7 +54,7 @@ public:
void configure(const string& key, const string& val);
void program(int bank, int program);
- void process(ProcessContext& events, SampleCount nframes, FrameTime start, FrameTime end);
+ void process(ProcessContext& context, SampleCount nframes, FrameTime start, FrameTime end);
void set_port_buffer(uint32_t voice, uint32_t port_num, Buffer* buf);
diff --git a/src/libs/engine/DuplexPort.cpp b/src/libs/engine/DuplexPort.cpp
index f0b138ed..6c195e87 100644
--- a/src/libs/engine/DuplexPort.cpp
+++ b/src/libs/engine/DuplexPort.cpp
@@ -54,7 +54,7 @@ DuplexPort::pre_process(SampleCount nframes, FrameTime start, FrameTime end)
}
void
-DuplexPort::process(ProcessContext& events, SampleCount nframes, FrameTime start, FrameTime end)
+DuplexPort::process(ProcessContext& context, SampleCount nframes, FrameTime start, FrameTime end)
{
}
@@ -64,9 +64,9 @@ DuplexPort::post_process(SampleCount nframes, FrameTime start, FrameTime end)
{
// Think about it...
- if (_is_output)
- InputPort::pre_process(nframes, start, end);
- else
+// if (_is_output)
+// InputPort::pre_process(nframes, start, end);
+//else
OutputPort::pre_process(nframes, start, end);
}
diff --git a/src/libs/engine/DuplexPort.hpp b/src/libs/engine/DuplexPort.hpp
index 4c98ea88..c74eca84 100644
--- a/src/libs/engine/DuplexPort.hpp
+++ b/src/libs/engine/DuplexPort.hpp
@@ -45,7 +45,7 @@ public:
virtual ~DuplexPort() {}
void pre_process(SampleCount nframes, FrameTime start, FrameTime end);
- void process(ProcessContext& events, SampleCount nframes, FrameTime start, FrameTime end);
+ void process(ProcessContext& context, SampleCount nframes, FrameTime start, FrameTime end);
void post_process(SampleCount nframes, FrameTime start, FrameTime end);
bool is_input() const { return !_is_output; }
diff --git a/src/libs/engine/GraphObject.hpp b/src/libs/engine/GraphObject.hpp
index 3da9c64f..02bd2bfc 100644
--- a/src/libs/engine/GraphObject.hpp
+++ b/src/libs/engine/GraphObject.hpp
@@ -67,7 +67,7 @@ public:
inline GraphObject* parent() const { return _parent; }
inline const string& name() const { return _name; }
- virtual void process(ProcessContext& events, SampleCount nframes, FrameTime start, FrameTime end) = 0;
+ virtual void process(ProcessContext& context, SampleCount nframes, FrameTime start, FrameTime end) = 0;
/** Rename */
virtual void set_path(const Path& new_path) {
diff --git a/src/libs/engine/InputPort.hpp b/src/libs/engine/InputPort.hpp
index 6aa86b9c..a34ef394 100644
--- a/src/libs/engine/InputPort.hpp
+++ b/src/libs/engine/InputPort.hpp
@@ -57,7 +57,7 @@ public:
const Connections& connections() { return _connections; }
void pre_process(SampleCount nframes, FrameTime start, FrameTime end);
- void process(ProcessContext& events, SampleCount nframes, FrameTime start, FrameTime end);
+ void process(ProcessContext& context, SampleCount nframes, FrameTime start, FrameTime end);
void post_process(SampleCount nframes, FrameTime start, FrameTime end);
bool is_connected() const { return (_connections.size() > 0); }
diff --git a/src/libs/engine/JackAudioDriver.cpp b/src/libs/engine/JackAudioDriver.cpp
index 4f32beb4..b5748e78 100644
--- a/src/libs/engine/JackAudioDriver.cpp
+++ b/src/libs/engine/JackAudioDriver.cpp
@@ -267,24 +267,25 @@ JackAudioDriver::_process_cb(jack_nframes_t nframes)
// FIXME: all of this time stuff is screwy
- static jack_nframes_t start_of_current_cycle = 0;
- static jack_nframes_t start_of_last_cycle = 0;
-
// FIXME: support nframes != buffer_size, even though that never damn well happens
assert(nframes == _buffer_size);
// Jack can elect to not call this function for a cycle, if overloaded
// FIXME: this doesn't make sense, and the start time isn't used anyway
- start_of_current_cycle = jack_last_frame_time(_client);
- start_of_last_cycle = start_of_current_cycle - nframes;
+ const jack_nframes_t start_of_current_cycle = jack_last_frame_time(_client);
+ const jack_nframes_t start_of_last_cycle = start_of_current_cycle - nframes; // FIXME: maybe not..
+ const jack_nframes_t end_of_current_cycle = start_of_current_cycle + nframes;
// FIXME: ditto
assert(start_of_current_cycle - start_of_last_cycle == nframes);
_transport_state = jack_transport_query(_client, &_position);
+ // Process events that came in during the last cycle
+ // (Aiming for jitter-free 1 block event latency, ideally)
if (_engine.event_source())
- _engine.event_source()->process(*_engine.post_processor(), nframes, start_of_last_cycle, start_of_current_cycle);
+ _engine.event_source()->process(*_engine.post_processor(), nframes,
+ start_of_last_cycle, start_of_current_cycle);
// Set buffers of patch ports to Jack port buffers (zero-copy processing)
for (Raul::List<JackAudioPort*>::iterator i = _ports.begin(); i != _ports.end(); ++i) {
@@ -293,14 +294,16 @@ JackAudioDriver::_process_cb(jack_nframes_t nframes)
}
assert(_engine.midi_driver());
- //_engine.midi_driver()->prepare_block(start_of_last_cycle, start_of_current_cycle);
- _engine.midi_driver()->prepare_block(start_of_current_cycle, start_of_current_cycle + nframes);
-
+ _engine.midi_driver()->pre_process(_process_context, nframes,
+ start_of_current_cycle, end_of_current_cycle);
// Run root patch
if (_root_patch)
- _root_patch->process(_process_context, nframes, start_of_current_cycle,
- start_of_current_cycle + nframes);
+ _root_patch->process(_process_context, nframes,
+ start_of_current_cycle, end_of_current_cycle);
+
+ _engine.midi_driver()->post_process(_process_context, nframes,
+ start_of_current_cycle, end_of_current_cycle);
return 0;
}
diff --git a/src/libs/engine/JackMidiDriver.cpp b/src/libs/engine/JackMidiDriver.cpp
index 9abe83f6..f49794d7 100644
--- a/src/libs/engine/JackMidiDriver.cpp
+++ b/src/libs/engine/JackMidiDriver.cpp
@@ -52,7 +52,6 @@ JackMidiPort::JackMidiPort(JackMidiDriver* driver, DuplexPort* patch_port)
0);
patch_port->buffer(0)->clear();
- patch_port->fixed_buffers(true);
}
@@ -62,22 +61,25 @@ JackMidiPort::~JackMidiPort()
}
-/** Prepare events for a block.
+/** Prepare input for a block before a cycle is run, in the audio thread.
*
- * This is basically simple since Jack MIDI data is in-band with the audio thread.
+ * This is simple since Jack MIDI is in-band with audio.
*/
void
-JackMidiPort::prepare_block(const SampleCount block_start, const SampleCount block_end)
+JackMidiPort::pre_process(SampleCount block_start, SampleCount block_end)
{
- const SampleCount nframes = block_end - block_start;
- void* jack_buffer = jack_port_get_buffer(_jack_port, nframes);
- const jack_nframes_t event_count = jack_midi_get_event_count(jack_buffer);
+ if ( ! is_input() )
+ return;
assert(_patch_port->poly() == 1);
MidiBuffer* patch_buf = dynamic_cast<MidiBuffer*>(_patch_port->buffer(0));
assert(patch_buf);
+ const SampleCount nframes = block_end - block_start;
+ void* jack_buffer = jack_port_get_buffer(_jack_port, nframes);
+ const jack_nframes_t event_count = jack_midi_get_event_count(jack_buffer);
+
patch_buf->prepare_write(nframes);
// Copy events from Jack port buffer into patch port buffer
@@ -95,6 +97,44 @@ JackMidiPort::prepare_block(const SampleCount block_start, const SampleCount blo
}
+/** Prepare output for a block after a cycle is run, in the audio thread.
+ *
+ * This is simple since Jack MIDI is in-band with audio.
+ */
+void
+JackMidiPort::post_process(SampleCount block_start, SampleCount block_end)
+{
+ if (is_input())
+ return;
+
+ assert(_patch_port->poly() == 1);
+
+ MidiBuffer* patch_buf = dynamic_cast<MidiBuffer*>(_patch_port->buffer(0));
+ assert(patch_buf);
+
+ const SampleCount nframes = block_end - block_start;
+ void* jack_buffer = jack_port_get_buffer(_jack_port, nframes);
+ const jack_nframes_t event_count = patch_buf->event_count();
+
+ patch_buf->prepare_read(nframes);
+
+ jack_midi_clear_buffer(jack_buffer);
+
+ double time = 0;
+ uint32_t size = 0;
+ unsigned char* data = NULL;
+
+ // Copy events from Jack port buffer into patch port buffer
+ for (jack_nframes_t i=0; i < event_count; ++i) {
+ patch_buf->get_event(&time, &size, &data);
+ jack_midi_event_write(jack_buffer, time, data, size);
+ }
+
+ //if (event_count)
+ // cerr << "Jack MIDI wrote " << event_count << " events." << endl;
+}
+
+
//// JackMidiDriver ////
@@ -137,10 +177,20 @@ JackMidiDriver::deactivate()
/** Build flat arrays of events to be used as input for the given cycle.
*/
void
-JackMidiDriver::prepare_block(const SampleCount block_start, const SampleCount block_end)
+JackMidiDriver::pre_process(ProcessContext& context, SampleCount nframes, FrameTime start, FrameTime end)
{
for (Raul::List<JackMidiPort*>::iterator i = _in_ports.begin(); i != _in_ports.end(); ++i)
- (*i)->prepare_block(block_start, block_end);
+ (*i)->pre_process(start, end);
+}
+
+
+/** Write the output from any (top-level, exported) MIDI output ports to Jack ports.
+ */
+void
+JackMidiDriver::post_process(ProcessContext& context, SampleCount nframes, FrameTime start, FrameTime end)
+{
+ for (Raul::List<JackMidiPort*>::iterator i = _out_ports.begin(); i != _out_ports.end(); ++i)
+ (*i)->post_process(start, end);
}
diff --git a/src/libs/engine/JackMidiDriver.hpp b/src/libs/engine/JackMidiDriver.hpp
index c546fbec..21e1f3ec 100644
--- a/src/libs/engine/JackMidiDriver.hpp
+++ b/src/libs/engine/JackMidiDriver.hpp
@@ -42,7 +42,8 @@ public:
JackMidiPort(JackMidiDriver* driver, DuplexPort* port);
virtual ~JackMidiPort();
- void prepare_block(const SampleCount block_start, const SampleCount block_end);
+ void pre_process(SampleCount block_start, SampleCount block_end);
+ void post_process(SampleCount block_start, SampleCount block_end);
void set_name(const std::string& name) { jack_port_set_name(_jack_port, name.c_str()); };
@@ -76,7 +77,8 @@ public:
bool is_activated() const { return _is_activated; }
bool is_enabled() const { return _is_enabled; }
- void prepare_block(const SampleCount block_start, const SampleCount block_end);
+ void pre_process(ProcessContext& context, SampleCount nframes, FrameTime start, FrameTime end);
+ void post_process(ProcessContext& context, SampleCount nframes, FrameTime start, FrameTime end);
JackMidiPort* create_port(DuplexPort* patch_port)
{ return new JackMidiPort(this, patch_port); }
diff --git a/src/libs/engine/LADSPANode.hpp b/src/libs/engine/LADSPANode.hpp
index a4ea1031..a9a67981 100644
--- a/src/libs/engine/LADSPANode.hpp
+++ b/src/libs/engine/LADSPANode.hpp
@@ -42,7 +42,7 @@ public:
void activate();
void deactivate();
- void process(ProcessContext& events, SampleCount nframes, FrameTime start, FrameTime end);
+ void process(ProcessContext& context, SampleCount nframes, FrameTime start, FrameTime end);
void set_port_buffer(uint32_t voice, uint32_t port_num, Buffer* buf);
diff --git a/src/libs/engine/LV2Node.cpp b/src/libs/engine/LV2Node.cpp
index 88c002e5..5eea2f23 100644
--- a/src/libs/engine/LV2Node.cpp
+++ b/src/libs/engine/LV2Node.cpp
@@ -123,9 +123,9 @@ LV2Node::instantiate()
uint32_t num_ports = slv2_plugin_get_num_ports(_lv2_plugin);
assert(num_ports > 0);
- _ports = new Raul::Array<Port*>(num_ports);
+ _ports = new Raul::Array<Port*>(num_ports, NULL);
- _instances = new Raul::Array<SLV2Instance>(_polyphony);
+ _instances = new Raul::Array<SLV2Instance>(_polyphony, NULL);
uint32_t port_buffer_size = 0;
diff --git a/src/libs/engine/LV2Node.hpp b/src/libs/engine/LV2Node.hpp
index d0941b93..a2d5bafb 100644
--- a/src/libs/engine/LV2Node.hpp
+++ b/src/libs/engine/LV2Node.hpp
@@ -51,7 +51,7 @@ public:
void activate();
void deactivate();
- void process(ProcessContext& events, SampleCount nframes, FrameTime start, FrameTime end);
+ void process(ProcessContext& context, SampleCount nframes, FrameTime start, FrameTime end);
void set_port_buffer(uint32_t voice, uint32_t port_num, Buffer* buf);
diff --git a/src/libs/engine/MidiBuffer.cpp b/src/libs/engine/MidiBuffer.cpp
index 59da7646..618c7476 100644
--- a/src/libs/engine/MidiBuffer.cpp
+++ b/src/libs/engine/MidiBuffer.cpp
@@ -230,5 +230,57 @@ MidiBuffer::get_event(double* timestamp,
}
+/** Clear, and merge \a a and \a b into this buffer.
+ *
+ * FIXME: This is slow.
+ *
+ * \return true if complete merge was successful
+ */
+bool
+MidiBuffer::merge(const MidiBuffer& a, const MidiBuffer& b)
+{
+ // Die if a merge isn't necessary as it's expensive
+ assert(a.size() > 0 && b.size() > 0);
+
+ reset(_this_nframes);
+
+ a.rewind();
+ b.rewind();
+
+ double a_time;
+ uint32_t a_size;
+ unsigned char* a_data;
+
+ double b_time;
+ uint32_t b_size;
+ unsigned char* b_data;
+
+ a.get_event(&a_time, &a_size, &a_data);
+ b.get_event(&b_time, &b_size, &b_data);
+
+ while (true) {
+ if (a_data && (!b_data || (a_time < b_time))) {
+ append(a_time, a_size, a_data);
+ if (a.increment())
+ a.get_event(&a_time, &a_size, &a_data);
+ else
+ a_data = NULL;
+ } else if (b_data) {
+ append(b_time, b_size, b_data);
+ if (b.increment())
+ b.get_event(&b_time, &b_size, &b_data);
+ else
+ b_data = NULL;
+ } else {
+ break;
+ }
+ }
+
+ _latest_stamp = max(a_time, b_time);
+
+ return true;
+}
+
+
} // namespace Ingen
diff --git a/src/libs/engine/MidiBuffer.hpp b/src/libs/engine/MidiBuffer.hpp
index a7db7e77..f1948666 100644
--- a/src/libs/engine/MidiBuffer.hpp
+++ b/src/libs/engine/MidiBuffer.hpp
@@ -69,6 +69,7 @@ public:
double get_event(double* timestamp, uint32_t* size, unsigned char** data) const;
bool append(double timestamp, uint32_t size, const unsigned char* data);
+ bool merge(const MidiBuffer& a, const MidiBuffer& b);
private:
double _latest_stamp; ///< Highest timestamp of all events
diff --git a/src/libs/engine/MidiControlNode.hpp b/src/libs/engine/MidiControlNode.hpp
index d06e2288..3b09668f 100644
--- a/src/libs/engine/MidiControlNode.hpp
+++ b/src/libs/engine/MidiControlNode.hpp
@@ -41,7 +41,7 @@ class MidiControlNode : public NodeBase
public:
MidiControlNode(const std::string& path, bool polyphonic, Patch* parent, SampleRate srate, size_t buffer_size);
- void process(ProcessContext& events, SampleCount nframes, FrameTime start, FrameTime end);
+ void process(ProcessContext& context, SampleCount nframes, FrameTime start, FrameTime end);
void control(uchar control_num, uchar val, SampleCount offset);
diff --git a/src/libs/engine/MidiDriver.hpp b/src/libs/engine/MidiDriver.hpp
index acf88a3e..13b87726 100644
--- a/src/libs/engine/MidiDriver.hpp
+++ b/src/libs/engine/MidiDriver.hpp
@@ -25,6 +25,8 @@
namespace Ingen {
+class ProcessContext;
+
/** Midi driver abstract base class.
*
@@ -35,8 +37,23 @@ class MidiDriver : public Driver
public:
MidiDriver() : Driver(DataType::MIDI) {}
- /** Prepare events (however neccessary) for the specified block (realtime safe) */
- virtual void prepare_block(const SampleCount block_start, const SampleCount block_end) = 0;
+ /** Prepare input for the specified (upcoming) cycle.
+ *
+ * Realtime safe, run in audio thread before executing the graph for a cycle.
+ */
+ virtual void pre_process(ProcessContext& context,
+ SampleCount nframes,
+ FrameTime start,
+ FrameTime end) = 0;
+
+ /** Prepare output for the specified (just completed) cycle.
+ *
+ * Realtime safe, run in audio thread after executing the graph for a cycle.
+ */
+ virtual void post_process(ProcessContext& context,
+ SampleCount nframes,
+ FrameTime start,
+ FrameTime end) = 0;
};
@@ -73,7 +90,8 @@ public:
void add_port(DriverPort* port) {}
DriverPort* remove_port(const Raul::Path& path) { return NULL; }
- void prepare_block(const SampleCount block_start, const SampleCount block_end) {}
+ void pre_process(ProcessContext& context, SampleCount nframes, FrameTime start, FrameTime end) {}
+ void post_process(ProcessContext& context, SampleCount nframes, FrameTime start, FrameTime end) {}
};
diff --git a/src/libs/engine/MidiNoteNode.hpp b/src/libs/engine/MidiNoteNode.hpp
index e86102db..a73f08f7 100644
--- a/src/libs/engine/MidiNoteNode.hpp
+++ b/src/libs/engine/MidiNoteNode.hpp
@@ -45,7 +45,7 @@ public:
bool prepare_poly(uint32_t poly);
bool apply_poly(Raul::Maid& maid, uint32_t poly);
- void process(ProcessContext& events, SampleCount nframes, FrameTime start, FrameTime end);
+ void process(ProcessContext& context, SampleCount nframes, FrameTime start, FrameTime end);
void note_on(uchar note_num, uchar velocity, FrameTime time, SampleCount nframes, FrameTime start, FrameTime end);
void note_off(uchar note_num, FrameTime time, SampleCount nframes, FrameTime start, FrameTime end);
diff --git a/src/libs/engine/MidiTriggerNode.hpp b/src/libs/engine/MidiTriggerNode.hpp
index 389768f8..2e1959b9 100644
--- a/src/libs/engine/MidiTriggerNode.hpp
+++ b/src/libs/engine/MidiTriggerNode.hpp
@@ -43,7 +43,7 @@ class MidiTriggerNode : public NodeBase
public:
MidiTriggerNode(const std::string& path, bool polyphonic, Patch* parent, SampleRate srate, size_t buffer_size);
- void process(ProcessContext& events, SampleCount nframes, FrameTime start, FrameTime end);
+ void process(ProcessContext& context, SampleCount nframes, FrameTime start, FrameTime end);
void note_on(uchar note_num, uchar velocity, FrameTime time, SampleCount nframes, FrameTime start, FrameTime end);
void note_off(uchar note_num, FrameTime time, SampleCount nframes, FrameTime start, FrameTime end);
diff --git a/src/libs/engine/Node.hpp b/src/libs/engine/Node.hpp
index 8db11ad8..b305bc45 100644
--- a/src/libs/engine/Node.hpp
+++ b/src/libs/engine/Node.hpp
@@ -117,7 +117,7 @@ public:
* @a start and @a end are transport times: end is not redundant in the case
* of varispeed, where end-start != nframes.
*/
- virtual void process(ProcessContext& events, SampleCount nframes, FrameTime start, FrameTime end) = 0;
+ virtual void process(ProcessContext& context, SampleCount nframes, FrameTime start, FrameTime end) = 0;
virtual void set_port_buffer(uint32_t voice, uint32_t port_num, Buffer* buf) = 0;
diff --git a/src/libs/engine/NodeBase.cpp b/src/libs/engine/NodeBase.cpp
index 5e6176f0..54caf8f8 100644
--- a/src/libs/engine/NodeBase.cpp
+++ b/src/libs/engine/NodeBase.cpp
@@ -61,8 +61,9 @@ NodeBase::~NodeBase()
delete _providers;
delete _dependants;
- for (uint32_t i=0; i < num_ports(); ++i)
- delete _ports->at(i);
+ if (_ports)
+ for (uint32_t i=0; i < num_ports(); ++i)
+ delete _ports->at(i);
}
diff --git a/src/libs/engine/NodeBase.hpp b/src/libs/engine/NodeBase.hpp
index d43a84a6..b5dee178 100644
--- a/src/libs/engine/NodeBase.hpp
+++ b/src/libs/engine/NodeBase.hpp
@@ -70,7 +70,7 @@ public:
virtual unsigned n_inputs_ready() const { return _n_inputs_ready.get(); }
virtual void pre_process(SampleCount nframes, FrameTime start, FrameTime end);
- virtual void process(ProcessContext& events, SampleCount nframes, FrameTime start, FrameTime end) = 0;
+ virtual void process(ProcessContext& context, SampleCount nframes, FrameTime start, FrameTime end) = 0;
virtual void post_process(SampleCount nframes, FrameTime start, FrameTime end);
virtual void set_port_buffer(uint32_t voice, uint32_t port_num, Buffer* buf) {}
diff --git a/src/libs/engine/OutputPort.hpp b/src/libs/engine/OutputPort.hpp
index 8f12d252..07daf6b6 100644
--- a/src/libs/engine/OutputPort.hpp
+++ b/src/libs/engine/OutputPort.hpp
@@ -50,7 +50,7 @@ public:
{}
void pre_process(SampleCount nframes, FrameTime start, FrameTime end);
- void process(ProcessContext& events, SampleCount nframes, FrameTime start, FrameTime end);
+ void process(ProcessContext& context, SampleCount nframes, FrameTime start, FrameTime end);
void post_process(SampleCount nframes, FrameTime start, FrameTime end);
virtual ~OutputPort() {}
diff --git a/src/libs/engine/Patch.hpp b/src/libs/engine/Patch.hpp
index 75de93cb..fd95e5bb 100644
--- a/src/libs/engine/Patch.hpp
+++ b/src/libs/engine/Patch.hpp
@@ -54,7 +54,7 @@ public:
void activate();
void deactivate();
- void process(ProcessContext& events, SampleCount nframes, FrameTime start, FrameTime end);
+ void process(ProcessContext& context, SampleCount nframes, FrameTime start, FrameTime end);
void set_buffer_size(size_t size);
diff --git a/src/libs/engine/TransportNode.hpp b/src/libs/engine/TransportNode.hpp
index a12a8cfe..bf11f309 100644
--- a/src/libs/engine/TransportNode.hpp
+++ b/src/libs/engine/TransportNode.hpp
@@ -36,7 +36,7 @@ class TransportNode : public NodeBase
public:
TransportNode(const std::string& path, bool polyphonic, Patch* parent, SampleRate srate, size_t buffer_size);
- virtual void process(ProcessContext& events, SampleCount nframes, FrameTime start, FrameTime end);
+ virtual void process(ProcessContext& context, SampleCount nframes, FrameTime start, FrameTime end);
};
diff --git a/src/libs/engine/events/AddPortEvent.cpp b/src/libs/engine/events/AddPortEvent.cpp
index 28273815..d31c2169 100644
--- a/src/libs/engine/events/AddPortEvent.cpp
+++ b/src/libs/engine/events/AddPortEvent.cpp
@@ -115,15 +115,13 @@ AddPortEvent::pre_process()
if (!_patch->parent()) {
if (_type == "ingen:audio")
_driver_port = _engine.audio_driver()->create_port(
- dynamic_cast<DuplexPort*>(_patch_port));
+ dynamic_cast<DuplexPort*>(_patch_port));
else if (_type == "ingen:midi")
_driver_port = _engine.midi_driver()->create_port(
- dynamic_cast<DuplexPort*>(_patch_port));
- }
-
- if (_type == "ingen:osc" && _engine.osc_driver()) {
- _driver_port = _engine.osc_driver()->create_port(
- dynamic_cast<DuplexPort*>(_patch_port));
+ dynamic_cast<DuplexPort*>(_patch_port));
+ else if (_type == "ingen:osc" && _engine.osc_driver())
+ _driver_port = _engine.osc_driver()->create_port(
+ dynamic_cast<DuplexPort*>(_patch_port));
}
assert(_ports_array->size() == _patch->num_ports());