summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/libs/client/OSCClientReceiver.cpp2
-rw-r--r--src/libs/engine/AudioDriver.hpp3
-rw-r--r--src/libs/engine/Connection.cpp5
-rw-r--r--src/libs/engine/Connection.hpp2
-rw-r--r--src/libs/engine/DSSINode.cpp21
-rw-r--r--src/libs/engine/DSSINode.hpp2
-rw-r--r--src/libs/engine/DuplexPort.cpp13
-rw-r--r--src/libs/engine/DuplexPort.hpp5
-rw-r--r--src/libs/engine/Engine.cpp4
-rw-r--r--src/libs/engine/Engine.hpp1
-rw-r--r--src/libs/engine/Event.cpp48
-rw-r--r--src/libs/engine/Event.hpp22
-rw-r--r--src/libs/engine/EventSink.hpp15
-rw-r--r--src/libs/engine/EventSource.hpp5
-rw-r--r--src/libs/engine/GraphObject.hpp2
-rw-r--r--src/libs/engine/InputPort.cpp24
-rw-r--r--src/libs/engine/InputPort.hpp5
-rw-r--r--src/libs/engine/JackAudioDriver.cpp23
-rw-r--r--src/libs/engine/JackAudioDriver.hpp2
-rw-r--r--src/libs/engine/JackMidiDriver.cpp25
-rw-r--r--src/libs/engine/JackMidiDriver.hpp8
-rw-r--r--src/libs/engine/LADSPANode.cpp13
-rw-r--r--src/libs/engine/LADSPANode.hpp2
-rw-r--r--src/libs/engine/LV2Node.cpp11
-rw-r--r--src/libs/engine/LV2Node.hpp2
-rw-r--r--src/libs/engine/Makefile.am18
-rw-r--r--src/libs/engine/MidiControlNode.cpp15
-rw-r--r--src/libs/engine/MidiControlNode.hpp2
-rw-r--r--src/libs/engine/MidiDriver.hpp17
-rw-r--r--src/libs/engine/MidiNoteNode.cpp69
-rw-r--r--src/libs/engine/MidiNoteNode.hpp14
-rw-r--r--src/libs/engine/MidiTriggerNode.cpp35
-rw-r--r--src/libs/engine/MidiTriggerNode.hpp6
-rw-r--r--src/libs/engine/Node.hpp2
-rw-r--r--src/libs/engine/NodeBase.cpp8
-rw-r--r--src/libs/engine/NodeBase.hpp6
-rw-r--r--src/libs/engine/OutputPort.cpp16
-rw-r--r--src/libs/engine/OutputPort.hpp5
-rw-r--r--src/libs/engine/Patch.cpp20
-rw-r--r--src/libs/engine/Patch.hpp6
-rw-r--r--src/libs/engine/Port.hpp5
-rw-r--r--src/libs/engine/PostProcessor.cpp25
-rw-r--r--src/libs/engine/PostProcessor.hpp8
-rw-r--r--src/libs/engine/ProcessContext.hpp25
-rw-r--r--src/libs/engine/ProcessSlave.cpp4
-rw-r--r--src/libs/engine/ProcessSlave.hpp28
-rw-r--r--src/libs/engine/QueuedEvent.hpp20
-rw-r--r--src/libs/engine/QueuedEventSource.cpp19
-rw-r--r--src/libs/engine/QueuedEventSource.hpp2
-rw-r--r--src/libs/engine/TransportNode.cpp6
-rw-r--r--src/libs/engine/TransportNode.hpp2
-rw-r--r--src/libs/engine/events/AddNodeEvent.cpp4
-rw-r--r--src/libs/engine/events/AddNodeEvent.hpp2
-rw-r--r--src/libs/engine/events/AddPortEvent.cpp4
-rw-r--r--src/libs/engine/events/AddPortEvent.hpp2
-rw-r--r--src/libs/engine/events/AllNotesOffEvent.cpp4
-rw-r--r--src/libs/engine/events/AllNotesOffEvent.hpp2
-rw-r--r--src/libs/engine/events/ClearPatchEvent.cpp4
-rw-r--r--src/libs/engine/events/ClearPatchEvent.hpp2
-rw-r--r--src/libs/engine/events/ConnectionEvent.cpp4
-rw-r--r--src/libs/engine/events/ConnectionEvent.hpp2
-rw-r--r--src/libs/engine/events/CreatePatchEvent.cpp4
-rw-r--r--src/libs/engine/events/CreatePatchEvent.hpp2
-rw-r--r--src/libs/engine/events/DSSIConfigureEvent.cpp4
-rw-r--r--src/libs/engine/events/DSSIConfigureEvent.hpp2
-rw-r--r--src/libs/engine/events/DSSIControlEvent.cpp4
-rw-r--r--src/libs/engine/events/DSSIControlEvent.hpp2
-rw-r--r--src/libs/engine/events/DSSIProgramEvent.cpp4
-rw-r--r--src/libs/engine/events/DSSIProgramEvent.hpp2
-rw-r--r--src/libs/engine/events/DSSIUpdateEvent.cpp4
-rw-r--r--src/libs/engine/events/DSSIUpdateEvent.hpp2
-rw-r--r--src/libs/engine/events/DeactivateEvent.cpp4
-rw-r--r--src/libs/engine/events/DeactivateEvent.hpp2
-rw-r--r--src/libs/engine/events/DestroyEvent.cpp8
-rw-r--r--src/libs/engine/events/DestroyEvent.hpp2
-rw-r--r--src/libs/engine/events/DisablePatchEvent.cpp4
-rw-r--r--src/libs/engine/events/DisablePatchEvent.hpp2
-rw-r--r--src/libs/engine/events/DisablePortMonitoringEvent.cpp4
-rw-r--r--src/libs/engine/events/DisablePortMonitoringEvent.hpp2
-rw-r--r--src/libs/engine/events/DisconnectNodeEvent.cpp6
-rw-r--r--src/libs/engine/events/DisconnectNodeEvent.hpp2
-rw-r--r--src/libs/engine/events/DisconnectPortEvent.cpp6
-rw-r--r--src/libs/engine/events/DisconnectPortEvent.hpp2
-rw-r--r--src/libs/engine/events/DisconnectionEvent.cpp4
-rw-r--r--src/libs/engine/events/DisconnectionEvent.hpp2
-rw-r--r--src/libs/engine/events/EnablePatchEvent.cpp4
-rw-r--r--src/libs/engine/events/EnablePatchEvent.hpp2
-rw-r--r--src/libs/engine/events/EnablePortMonitoringEvent.cpp4
-rw-r--r--src/libs/engine/events/EnablePortMonitoringEvent.hpp2
-rw-r--r--src/libs/engine/events/Makefile.am6
-rw-r--r--src/libs/engine/events/MidiLearnEvent.cpp4
-rw-r--r--src/libs/engine/events/MidiLearnEvent.hpp2
-rw-r--r--src/libs/engine/events/NoteOffEvent.cpp11
-rw-r--r--src/libs/engine/events/NoteOffEvent.hpp2
-rw-r--r--src/libs/engine/events/NoteOnEvent.cpp11
-rw-r--r--src/libs/engine/events/NoteOnEvent.hpp2
-rw-r--r--src/libs/engine/events/RenameEvent.cpp4
-rw-r--r--src/libs/engine/events/RenameEvent.hpp2
-rw-r--r--src/libs/engine/events/RequestObjectEvent.cpp7
-rw-r--r--src/libs/engine/events/RequestObjectEvent.hpp2
-rw-r--r--src/libs/engine/events/RequestPluginEvent.cpp7
-rw-r--r--src/libs/engine/events/RequestPluginEvent.hpp2
-rw-r--r--src/libs/engine/events/RequestPortValueEvent.cpp7
-rw-r--r--src/libs/engine/events/RequestPortValueEvent.hpp2
-rw-r--r--src/libs/engine/events/SendPortValueEvent.cpp18
-rw-r--r--src/libs/engine/events/SendPortValueEvent.hpp5
-rw-r--r--src/libs/engine/events/SetMetadataEvent.cpp4
-rw-r--r--src/libs/engine/events/SetMetadataEvent.hpp2
-rw-r--r--src/libs/engine/events/SetPolyphonicEvent.cpp4
-rw-r--r--src/libs/engine/events/SetPolyphonicEvent.hpp2
-rw-r--r--src/libs/engine/events/SetPolyphonyEvent.cpp4
-rw-r--r--src/libs/engine/events/SetPolyphonyEvent.hpp2
-rw-r--r--src/libs/engine/events/SetPortValueEvent.cpp11
-rw-r--r--src/libs/engine/events/SetPortValueEvent.hpp2
-rw-r--r--src/libs/engine/events/SetPortValueQueuedEvent.cpp11
-rw-r--r--src/libs/engine/events/SetPortValueQueuedEvent.hpp2
116 files changed, 486 insertions, 422 deletions
diff --git a/src/libs/client/OSCClientReceiver.cpp b/src/libs/client/OSCClientReceiver.cpp
index d6ce3f81..63bf5b69 100644
--- a/src/libs/client/OSCClientReceiver.cpp
+++ b/src/libs/client/OSCClientReceiver.cpp
@@ -39,7 +39,7 @@ OSCClientReceiver::OSCClientReceiver(int listen_port)
// _receiving_node_num_ports(0),
// _num_received_ports(0)
{
- start(true);
+ start(false);
}
diff --git a/src/libs/engine/AudioDriver.hpp b/src/libs/engine/AudioDriver.hpp
index 51373532..8b4c0831 100644
--- a/src/libs/engine/AudioDriver.hpp
+++ b/src/libs/engine/AudioDriver.hpp
@@ -29,6 +29,7 @@ namespace Ingen {
class Patch;
class AudioDriver;
class Port;
+class ProcessContext;
/** Audio driver abstract base class.
@@ -51,6 +52,8 @@ public:
virtual SampleCount frame_time() const = 0;
virtual bool is_realtime() const = 0;
+
+ virtual ProcessContext& context() = 0;
};
diff --git a/src/libs/engine/Connection.cpp b/src/libs/engine/Connection.cpp
index 47893acb..fedd2198 100644
--- a/src/libs/engine/Connection.cpp
+++ b/src/libs/engine/Connection.cpp
@@ -23,6 +23,7 @@
#include "Port.hpp"
#include "BufferFactory.hpp"
#include "AudioBuffer.hpp"
+#include "ProcessContext.hpp"
namespace Ingen {
@@ -110,10 +111,10 @@ Connection::apply_poly(Raul::Maid& maid, uint32_t poly)
void
-Connection::process(SampleCount nframes, FrameTime start, FrameTime end)
+Connection::process(ProcessContext& context)
{
// FIXME: nframes parameter not used
- assert(_buffer_size == 1 || _buffer_size == nframes);
+ assert(_buffer_size == 1 || _buffer_size == context.nframes());
/* Thought: A poly output port can be connected to multiple mono input
* ports, which means this mix down would have to happen many times.
diff --git a/src/libs/engine/Connection.hpp b/src/libs/engine/Connection.hpp
index 44cbcccb..4a077a87 100644
--- a/src/libs/engine/Connection.hpp
+++ b/src/libs/engine/Connection.hpp
@@ -54,7 +54,7 @@ public:
bool pending_disconnection() { return _pending_disconnection; }
void pending_disconnection(bool b) { _pending_disconnection = b; }
- void process(SampleCount nframes, FrameTime start, FrameTime end);
+ void process(ProcessContext& context);
/** Get the buffer for a particular voice.
* A Connection is smart - it knows the destination port requesting the
diff --git a/src/libs/engine/DSSINode.cpp b/src/libs/engine/DSSINode.cpp
index af9be208..1140d9bb 100644
--- a/src/libs/engine/DSSINode.cpp
+++ b/src/libs/engine/DSSINode.cpp
@@ -15,14 +15,15 @@
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "DSSINode.hpp"
#include <map>
-#include <set>
+//#include <set>
+#include "DSSINode.hpp"
#include "ClientBroadcaster.hpp"
#include "interface/ClientInterface.hpp"
#include "InputPort.hpp"
#include "types.hpp"
#include "AudioBuffer.hpp"
+#include "ProcessContext.hpp"
using namespace std;
@@ -172,26 +173,26 @@ DSSINode::has_midi_input() const
void
-DSSINode::process(ProcessContext& context, SampleCount nframes, FrameTime start, FrameTime end)
+DSSINode::process(ProcessContext& context)
{
- NodeBase::pre_process(nframes, start, end);
+ NodeBase::pre_process(context);
if (_dssi_descriptor->run_synth) {
- convert_events(nframes);
- _dssi_descriptor->run_synth(_instances[0], nframes,
+ convert_events(context.nframes());
+ _dssi_descriptor->run_synth(_instances[0], context.nframes(),
_alsa_events, _encoded_events);
} else if (_dssi_descriptor->run_multiple_synths) {
- convert_events(nframes);
+ convert_events(context.nframes());
// I hate this stupid function
snd_seq_event_t* events[1] = { _alsa_events };
long unsigned events_sizes[1] = { _encoded_events };
- _dssi_descriptor->run_multiple_synths(1, _instances, nframes,
+ _dssi_descriptor->run_multiple_synths(1, _instances, context.nframes(),
events, events_sizes);
} else {
- LADSPANode::process(context, nframes, start, end);
+ LADSPANode::process(context);
}
- NodeBase::post_process(nframes, start, end);
+ NodeBase::post_process(context);
}
diff --git a/src/libs/engine/DSSINode.hpp b/src/libs/engine/DSSINode.hpp
index 418be920..4cf034b5 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& context, SampleCount nframes, FrameTime start, FrameTime end);
+ void process(ProcessContext& context);
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 6c195e87..6297a9be 100644
--- a/src/libs/engine/DuplexPort.cpp
+++ b/src/libs/engine/DuplexPort.cpp
@@ -40,12 +40,12 @@ DuplexPort::DuplexPort(Node* parent, const string& name, uint32_t index, uint32_
void
-DuplexPort::pre_process(SampleCount nframes, FrameTime start, FrameTime end)
+DuplexPort::pre_process(ProcessContext& context)
{
// Think about it...
// if (_is_output) {
- InputPort::pre_process(nframes, start, end);
+ InputPort::pre_process(context);
// } else {
//for (uint32_t i=0; i < _poly; ++i)
// _buffers->at(i)->rewind();
@@ -53,21 +53,16 @@ DuplexPort::pre_process(SampleCount nframes, FrameTime start, FrameTime end)
// }
}
-void
-DuplexPort::process(ProcessContext& context, SampleCount nframes, FrameTime start, FrameTime end)
-{
-}
-
void
-DuplexPort::post_process(SampleCount nframes, FrameTime start, FrameTime end)
+DuplexPort::post_process(ProcessContext& context)
{
// Think about it...
// if (_is_output)
// InputPort::pre_process(nframes, start, end);
//else
- OutputPort::pre_process(nframes, start, end);
+ OutputPort::pre_process(context);
}
diff --git a/src/libs/engine/DuplexPort.hpp b/src/libs/engine/DuplexPort.hpp
index c74eca84..0af45c1e 100644
--- a/src/libs/engine/DuplexPort.hpp
+++ b/src/libs/engine/DuplexPort.hpp
@@ -44,9 +44,8 @@ public:
DuplexPort(Node* parent, const std::string& name, uint32_t index, uint32_t poly, DataType type, size_t buffer_size, bool is_output);
virtual ~DuplexPort() {}
- void pre_process(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);
+ void pre_process(ProcessContext& context);
+ void post_process(ProcessContext& context);
bool is_input() const { return !_is_output; }
bool is_output() const { return _is_output; }
diff --git a/src/libs/engine/Engine.cpp b/src/libs/engine/Engine.cpp
index f79ccfd1..afbd8db1 100644
--- a/src/libs/engine/Engine.cpp
+++ b/src/libs/engine/Engine.cpp
@@ -55,7 +55,7 @@ Engine::Engine(Ingen::Shared::World* world)
, _midi_driver(NULL)
, _osc_driver(NULL)
, _maid(new Raul::Maid(maid_queue_size))
- , _post_processor(new PostProcessor(/**_maid, */post_processor_queue_size))
+ , _post_processor(new PostProcessor(*this, /**_maid, */post_processor_queue_size))
, _broadcaster(new ClientBroadcaster())
, _object_store(new ObjectStore())
, _node_factory(new NodeFactory(world))
@@ -233,7 +233,7 @@ Engine::activate(size_t parallelism)
_process_slaves.clear();
_process_slaves.reserve(parallelism);
for (size_t i=0; i < parallelism - 1; ++i)
- _process_slaves.push_back(new ProcessSlave(_audio_driver->is_realtime()));
+ _process_slaves.push_back(new ProcessSlave(*this, _audio_driver->is_realtime()));
root_patch->enable();
diff --git a/src/libs/engine/Engine.hpp b/src/libs/engine/Engine.hpp
index d4f3c972..eb1f014b 100644
--- a/src/libs/engine/Engine.hpp
+++ b/src/libs/engine/Engine.hpp
@@ -98,6 +98,7 @@ public:
typedef std::vector<ProcessSlave*> ProcessSlaves;
inline const ProcessSlaves& process_slaves() const { return _process_slaves; }
+ inline ProcessSlaves& process_slaves() { return _process_slaves; }
private:
ProcessSlaves _process_slaves;
diff --git a/src/libs/engine/Event.cpp b/src/libs/engine/Event.cpp
new file mode 100644
index 00000000..1db466ce
--- /dev/null
+++ b/src/libs/engine/Event.cpp
@@ -0,0 +1,48 @@
+/* This file is part of Ingen.
+ * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
+ *
+ * Ingen is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU General Public License as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option) any later
+ * version.
+ *
+ * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "Event.hpp"
+#include "ThreadManager.hpp"
+#include "ProcessContext.hpp"
+
+namespace Ingen {
+
+
+void
+Event::execute(ProcessContext& context)
+{
+ assert(ThreadManager::current_thread_id() == THREAD_PROCESS);
+ assert(!_executed);
+ assert(_time <= context.end());
+
+ // Missed the event, jitter, damnit.
+ if (_time < context.start())
+ _time = context.start();
+
+ _executed = true;
+}
+
+
+void
+Event::post_process()
+{
+ assert(ThreadManager::current_thread_id() == THREAD_POST_PROCESS);
+}
+
+
+} // namespace Ingen
+
diff --git a/src/libs/engine/Event.hpp b/src/libs/engine/Event.hpp
index fe0112d3..5860da2a 100644
--- a/src/libs/engine/Event.hpp
+++ b/src/libs/engine/Event.hpp
@@ -22,12 +22,12 @@
#include <raul/SharedPtr.hpp>
#include <raul/Deletable.hpp>
#include "types.hpp"
-#include "ThreadManager.hpp"
namespace Ingen {
class Engine;
class Responder;
+class ProcessContext;
/** Base class for all events (both realtime and QueuedEvent).
@@ -47,27 +47,13 @@ public:
virtual ~Event() {}
/** Execute this event in the audio thread (MUST be realtime safe). */
- virtual void execute(SampleCount nframes, FrameTime start, FrameTime end)
- {
- assert(ThreadManager::current_thread_id() == THREAD_PROCESS);
- assert(!_executed);
- assert(_time <= end);
-
- // Missed the event, jitter, damnit.
- if (_time < start)
- _time = start;
-
- _executed = true;
- }
+ virtual void execute(ProcessContext& context);
/** Perform any actions after execution (ie send replies to commands)
* (no realtime requirements). */
- virtual void post_process()
- {
- assert(ThreadManager::current_thread_id() == THREAD_POST_PROCESS);
- }
+ virtual void post_process();
- inline SampleCount time() { return _time; }
+ inline SampleCount time() const { return _time; }
protected:
Event(Engine& engine, SharedPtr<Responder> responder, FrameTime time)
diff --git a/src/libs/engine/EventSink.hpp b/src/libs/engine/EventSink.hpp
index 27407684..b7753a79 100644
--- a/src/libs/engine/EventSink.hpp
+++ b/src/libs/engine/EventSink.hpp
@@ -20,12 +20,15 @@
#include <list>
#include <utility>
-#include <raul/DoubleBuffer.hpp>
+#include <raul/RingBuffer.hpp>
+#include "events/SendPortValueEvent.hpp"
#include "types.hpp"
namespace Ingen {
class Port;
+class Engine;
+class SendPortValueEvent;
/** Sink for events generated in the audio thread.
@@ -39,16 +42,18 @@ class Port;
class EventSink
{
public:
- EventSink(size_t capacity) : _capacity(capacity) {}
+ EventSink(Engine& engine, size_t capacity) : _engine(engine), _events(capacity) {}
/* FIXME: Figure out variable sized event queues and make this a generic
* interface (ie don't add a method for every event type, crap..) */
- void control_change(Port* port, float val);
+ void control_change(Port* port, FrameTime time, float val);
+
+ bool read_control_change(SendPortValueEvent& ev);
private:
- size_t _capacity;
- //Raul::List<std::pair<Port*, Raul::DoubleBuffer<float> > > _ports;
+ Engine& _engine;
+ Raul::RingBuffer<uchar> _events;
};
diff --git a/src/libs/engine/EventSource.hpp b/src/libs/engine/EventSource.hpp
index 803fa8c9..68532d16 100644
--- a/src/libs/engine/EventSource.hpp
+++ b/src/libs/engine/EventSource.hpp
@@ -47,10 +47,7 @@ public:
virtual void activate() = 0;
virtual void deactivate() = 0;
- virtual void process(PostProcessor& dest,
- SampleCount nframes,
- FrameTime cycle_start,
- FrameTime cycle_end) = 0;
+ virtual void process(PostProcessor& dest, ProcessContext& context) = 0;
protected:
size_t _capacity;
diff --git a/src/libs/engine/GraphObject.hpp b/src/libs/engine/GraphObject.hpp
index 02bd2bfc..f2089f42 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& context, SampleCount nframes, FrameTime start, FrameTime end) = 0;
+ virtual void process(ProcessContext& context) = 0;
/** Rename */
virtual void set_path(const Path& new_path) {
diff --git a/src/libs/engine/InputPort.cpp b/src/libs/engine/InputPort.cpp
index 4f2147c4..6cc7beb4 100644
--- a/src/libs/engine/InputPort.cpp
+++ b/src/libs/engine/InputPort.cpp
@@ -79,8 +79,10 @@ InputPort::add_connection(Raul::ListNode<Connection*>* const c)
}
// Automatically monitor connected control inputs
- if (_type == DataType::FLOAT && _buffer_size == 1)
+ if (_type == DataType::FLOAT && _buffer_size == 1) {
+ cerr << path() << " monitor enable" << endl;
_monitor = true;
+ }
}
@@ -147,18 +149,18 @@ InputPort::is_connected_to(const OutputPort* port) const
* FIXME: nframes parameter not used,
*/
void
-InputPort::pre_process(SampleCount nframes, FrameTime start, FrameTime end)
+InputPort::pre_process(ProcessContext& context)
{
bool do_mixdown = true;
if (_connections.size() == 0) {
for (uint32_t i=0; i < _poly; ++i)
- _buffers->at(i)->prepare_read(nframes);
+ _buffers->at(i)->prepare_read(context.nframes());
return;
}
for (Connections::iterator c = _connections.begin(); c != _connections.end(); ++c)
- (*c)->process(nframes, start, end);
+ (*c)->process(context);
if ( ! _fixed_buffers) {
// If only one connection, try to use buffer directly (zero copy)
@@ -173,7 +175,7 @@ InputPort::pre_process(SampleCount nframes, FrameTime start, FrameTime end)
}
for (uint32_t i=0; i < _poly; ++i)
- _buffers->at(i)->prepare_read(nframes);
+ _buffers->at(i)->prepare_read(context.nframes());
//cerr << path() << " poly = " << _poly << ", mixdown: " << do_mixdown << endl;
@@ -216,24 +218,20 @@ InputPort::pre_process(SampleCount nframes, FrameTime start, FrameTime end)
void
-InputPort::process(ProcessContext& context, SampleCount nframes, FrameTime start, FrameTime end)
+InputPort::post_process(ProcessContext& context)
{
if (_monitor && _type == DataType::FLOAT && _buffer_size == 1) {
const Sample value = ((AudioBuffer*)(*_buffers)[0])->value_at(0);
if (value != _last_reported_value) {
- context.event_sink().control_change(this, ((AudioBuffer*)(*_buffers)[0])->value_at(0));
+ context.event_sink().control_change(this, context.start(),
+ ((AudioBuffer*)(*_buffers)[0])->value_at(0));
_last_reported_value = value;
}
}
-}
-
-void
-InputPort::post_process(SampleCount nframes, FrameTime start, FrameTime end)
-{
// Prepare for next cycle
for (uint32_t i=0; i < _poly; ++i)
- _buffers->at(i)->prepare_write(nframes);
+ _buffers->at(i)->prepare_write(context.nframes());
}
diff --git a/src/libs/engine/InputPort.hpp b/src/libs/engine/InputPort.hpp
index a34ef394..ca62470b 100644
--- a/src/libs/engine/InputPort.hpp
+++ b/src/libs/engine/InputPort.hpp
@@ -56,9 +56,8 @@ public:
typedef Raul::List<Connection*> Connections;
const Connections& connections() { return _connections; }
- void pre_process(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);
+ void pre_process(ProcessContext& context);
+ void post_process(ProcessContext& context);
bool is_connected() const { return (_connections.size() > 0); }
bool is_connected_to(const OutputPort* port) const;
diff --git a/src/libs/engine/JackAudioDriver.cpp b/src/libs/engine/JackAudioDriver.cpp
index b5748e78..c8a26510 100644
--- a/src/libs/engine/JackAudioDriver.cpp
+++ b/src/libs/engine/JackAudioDriver.cpp
@@ -35,6 +35,7 @@
#include "DuplexPort.hpp"
#include "EventSource.hpp"
#include "AudioBuffer.hpp"
+#include "ProcessSlave.hpp"
/*#ifdef HAVE_LASH
#include "LashDriver.hpp"
#endif*/
@@ -100,6 +101,7 @@ JackAudioDriver::JackAudioDriver(Engine& engine,
_sample_rate(jack_client ? jack_get_sample_rate(jack_client) : 0),
_is_activated(false),
_local_client(true), // FIXME
+ _process_context(engine),
_root_patch(NULL)
{
if (!_client) {
@@ -280,12 +282,18 @@ JackAudioDriver::_process_cb(jack_nframes_t nframes)
assert(start_of_current_cycle - start_of_last_cycle == nframes);
_transport_state = jack_transport_query(_client, &_position);
+
+ _process_context.set_time_slice(nframes, start_of_current_cycle, end_of_current_cycle);
+
+ for (Engine::ProcessSlaves::iterator i = _engine.process_slaves().begin();
+ i != _engine.process_slaves().end(); ++i) {
+ (*i)->context().set_time_slice(nframes, start_of_current_cycle, end_of_current_cycle);
+ }
// 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(), _process_context);
// Set buffers of patch ports to Jack port buffers (zero-copy processing)
for (Raul::List<JackAudioPort*>::iterator i = _ports.begin(); i != _ports.end(); ++i) {
@@ -294,16 +302,15 @@ JackAudioDriver::_process_cb(jack_nframes_t nframes)
}
assert(_engine.midi_driver());
- _engine.midi_driver()->pre_process(_process_context, nframes,
- start_of_current_cycle, end_of_current_cycle);
+ _engine.midi_driver()->pre_process(_process_context);
// Run root patch
if (_root_patch)
- _root_patch->process(_process_context, nframes,
- start_of_current_cycle, end_of_current_cycle);
+ _root_patch->process(_process_context);
- _engine.midi_driver()->post_process(_process_context, nframes,
- start_of_current_cycle, end_of_current_cycle);
+ _engine.midi_driver()->post_process(_process_context);
+
+ _engine.post_processor()->set_end_time(_process_context.end());
return 0;
}
diff --git a/src/libs/engine/JackAudioDriver.hpp b/src/libs/engine/JackAudioDriver.hpp
index 28007d77..f2678800 100644
--- a/src/libs/engine/JackAudioDriver.hpp
+++ b/src/libs/engine/JackAudioDriver.hpp
@@ -94,6 +94,8 @@ public:
Patch* root_patch() { return _root_patch; }
void set_root_patch(Patch* patch) { _root_patch = patch; }
+ ProcessContext& context() { return _process_context; }
+
/** Transport state for this frame.
* Intended to only be called from the audio thread. */
inline const jack_position_t* position() { return &_position; }
diff --git a/src/libs/engine/JackMidiDriver.cpp b/src/libs/engine/JackMidiDriver.cpp
index f49794d7..730f5d80 100644
--- a/src/libs/engine/JackMidiDriver.cpp
+++ b/src/libs/engine/JackMidiDriver.cpp
@@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
+() */
#include <iostream>
#include <cstdlib>
@@ -26,6 +26,7 @@
#include "AudioDriver.hpp"
#include "MidiBuffer.hpp"
#include "DuplexPort.hpp"
+#include "ProcessContext.hpp"
#include "jack_compat.h"
/*#ifdef HAVE_LASH
#include "LashDriver.hpp"
@@ -66,7 +67,7 @@ JackMidiPort::~JackMidiPort()
* This is simple since Jack MIDI is in-band with audio.
*/
void
-JackMidiPort::pre_process(SampleCount block_start, SampleCount block_end)
+JackMidiPort::pre_process(ProcessContext& context)
{
if ( ! is_input() )
return;
@@ -76,11 +77,10 @@ JackMidiPort::pre_process(SampleCount block_start, SampleCount block_end)
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);
+ void* jack_buffer = jack_port_get_buffer(_jack_port, context.nframes());
const jack_nframes_t event_count = jack_midi_get_event_count(jack_buffer);
- patch_buf->prepare_write(nframes);
+ patch_buf->prepare_write(context.nframes());
// Copy events from Jack port buffer into patch port buffer
for (jack_nframes_t i=0; i < event_count; ++i) {
@@ -102,7 +102,7 @@ JackMidiPort::pre_process(SampleCount block_start, SampleCount block_end)
* This is simple since Jack MIDI is in-band with audio.
*/
void
-JackMidiPort::post_process(SampleCount block_start, SampleCount block_end)
+JackMidiPort::post_process(ProcessContext& context)
{
if (is_input())
return;
@@ -112,11 +112,10 @@ JackMidiPort::post_process(SampleCount block_start, SampleCount block_end)
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);
+ void* jack_buffer = jack_port_get_buffer(_jack_port, context.nframes());
const jack_nframes_t event_count = patch_buf->event_count();
- patch_buf->prepare_read(nframes);
+ patch_buf->prepare_read(context.nframes());
jack_midi_clear_buffer(jack_buffer);
@@ -177,20 +176,20 @@ JackMidiDriver::deactivate()
/** Build flat arrays of events to be used as input for the given cycle.
*/
void
-JackMidiDriver::pre_process(ProcessContext& context, SampleCount nframes, FrameTime start, FrameTime end)
+JackMidiDriver::pre_process(ProcessContext& context)
{
for (Raul::List<JackMidiPort*>::iterator i = _in_ports.begin(); i != _in_ports.end(); ++i)
- (*i)->pre_process(start, end);
+ (*i)->pre_process(context);
}
/** 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)
+JackMidiDriver::post_process(ProcessContext& context)
{
for (Raul::List<JackMidiPort*>::iterator i = _out_ports.begin(); i != _out_ports.end(); ++i)
- (*i)->post_process(start, end);
+ (*i)->post_process(context);
}
diff --git a/src/libs/engine/JackMidiDriver.hpp b/src/libs/engine/JackMidiDriver.hpp
index 21e1f3ec..ce83266f 100644
--- a/src/libs/engine/JackMidiDriver.hpp
+++ b/src/libs/engine/JackMidiDriver.hpp
@@ -42,8 +42,8 @@ public:
JackMidiPort(JackMidiDriver* driver, DuplexPort* port);
virtual ~JackMidiPort();
- void pre_process(SampleCount block_start, SampleCount block_end);
- void post_process(SampleCount block_start, SampleCount block_end);
+ void pre_process(ProcessContext& context);
+ void post_process(ProcessContext& context);
void set_name(const std::string& name) { jack_port_set_name(_jack_port, name.c_str()); };
@@ -77,8 +77,8 @@ public:
bool is_activated() const { return _is_activated; }
bool is_enabled() const { return _is_enabled; }
- void pre_process(ProcessContext& context, SampleCount nframes, FrameTime start, FrameTime end);
- void post_process(ProcessContext& context, SampleCount nframes, FrameTime start, FrameTime end);
+ void pre_process(ProcessContext& context);
+ void post_process(ProcessContext& context);
JackMidiPort* create_port(DuplexPort* patch_port)
{ return new JackMidiPort(this, patch_port); }
diff --git a/src/libs/engine/LADSPANode.cpp b/src/libs/engine/LADSPANode.cpp
index b2725131..88ad5738 100644
--- a/src/libs/engine/LADSPANode.cpp
+++ b/src/libs/engine/LADSPANode.cpp
@@ -15,15 +15,16 @@
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "LADSPANode.hpp"
#include <iostream>
#include <cassert>
-#include <stdint.h>
#include <cmath>
+#include <stdint.h>
+#include "LADSPANode.hpp"
#include "AudioBuffer.hpp"
#include "InputPort.hpp"
#include "OutputPort.hpp"
#include "Plugin.hpp"
+#include "ProcessContext.hpp"
namespace Ingen {
@@ -188,14 +189,14 @@ LADSPANode::deactivate()
void
-LADSPANode::process(ProcessContext& context, SampleCount nframes, FrameTime start, FrameTime end)
+LADSPANode::process(ProcessContext& context)
{
- NodeBase::pre_process(nframes, start, end);
+ NodeBase::pre_process(context);
for (uint32_t i=0; i < _polyphony; ++i)
- _descriptor->run(_instances[i], nframes);
+ _descriptor->run(_instances[i], context.nframes());
- NodeBase::post_process(nframes, start, end);
+ NodeBase::post_process(context);
}
diff --git a/src/libs/engine/LADSPANode.hpp b/src/libs/engine/LADSPANode.hpp
index a9a67981..46b03792 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& context, SampleCount nframes, FrameTime start, FrameTime end);
+ void process(ProcessContext& context);
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 5eea2f23..99d074e1 100644
--- a/src/libs/engine/LV2Node.cpp
+++ b/src/libs/engine/LV2Node.cpp
@@ -15,12 +15,12 @@
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include <raul/Maid.hpp>
#include <iostream>
#include <cassert>
#include <float.h>
#include <stdint.h>
#include <cmath>
+#include <raul/Maid.hpp>
#include "LV2Node.hpp"
#include "InputPort.hpp"
#include "OutputPort.hpp"
@@ -28,6 +28,7 @@
#include "AudioBuffer.hpp"
#include "MidiBuffer.hpp"
#include "OSCBuffer.hpp"
+#include "ProcessContext.hpp"
namespace Ingen {
@@ -241,14 +242,14 @@ LV2Node::deactivate()
void
-LV2Node::process(ProcessContext& context, SampleCount nframes, FrameTime start, FrameTime end)
+LV2Node::process(ProcessContext& context)
{
- NodeBase::pre_process(nframes, start, end);
+ NodeBase::pre_process(context);
for (uint32_t i=0; i < _polyphony; ++i)
- slv2_instance_run((*_instances)[i], nframes);
+ slv2_instance_run((*_instances)[i], context.nframes());
- NodeBase::post_process(nframes, start, end);
+ NodeBase::post_process(context);
}
diff --git a/src/libs/engine/LV2Node.hpp b/src/libs/engine/LV2Node.hpp
index a2d5bafb..db72ffda 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& context, SampleCount nframes, FrameTime start, FrameTime end);
+ void process(ProcessContext& context);
void set_port_buffer(uint32_t voice, uint32_t port_num, Buffer* buf);
diff --git a/src/libs/engine/Makefile.am b/src/libs/engine/Makefile.am
index 5a5879d5..5607f3db 100644
--- a/src/libs/engine/Makefile.am
+++ b/src/libs/engine/Makefile.am
@@ -37,7 +37,10 @@ libingen_engine_la_SOURCES = \
DuplexPort.hpp \
Engine.cpp \
Engine.hpp \
+ Event.cpp \
Event.hpp \
+ EventSink.cpp \
+ EventSink.hpp \
EventSource.hpp \
GraphObject.cpp \
GraphObject.hpp \
@@ -89,6 +92,7 @@ libingen_engine_la_SOURCES = \
ProcessSlave.cpp \
QueuedEngineInterface.cpp \
QueuedEngineInterface.hpp \
+ QueuedEvent.cpp \
QueuedEvent.hpp \
QueuedEventSource.cpp \
QueuedEventSource.hpp \
@@ -102,8 +106,6 @@ libingen_engine_la_SOURCES = \
events.hpp \
events/AddNodeEvent.cpp \
events/AddNodeEvent.hpp \
- events/AddPortEvent.cpp \
- events/AddPortEvent.hpp \
events/AllNotesOffEvent.cpp \
events/AllNotesOffEvent.hpp \
events/ClearPatchEvent.cpp \
@@ -126,6 +128,8 @@ libingen_engine_la_SOURCES = \
events/DisconnectionEvent.hpp \
events/EnablePatchEvent.cpp \
events/EnablePatchEvent.hpp \
+ events/EnablePortMonitoringEvent.cpp \
+ events/EnablePortMonitoringEvent.hpp \
events/LoadPluginsEvent.cpp \
events/LoadPluginsEvent.hpp \
events/MidiLearnEvent.cpp \
@@ -151,14 +155,16 @@ libingen_engine_la_SOURCES = \
events/RequestPluginsEvent.hpp \
events/RequestPortValueEvent.cpp \
events/RequestPortValueEvent.hpp \
+ events/SendPortValueEvent.cpp \
+ events/SendPortValueEvent.hpp \
events/SetMetadataEvent.cpp \
events/SetMetadataEvent.hpp \
+ events/SetPolyphonicEvent.cpp \
+ events/SetPolyphonicEvent.hpp \
+ events/SetPolyphonyEvent.cpp \
+ events/SetPolyphonyEvent.hpp \
events/SetPortValueEvent.cpp \
events/SetPortValueEvent.hpp \
- events/SetPolyphonyEvent.hpp \
- events/SetPolyphonyEvent.cpp \
- events/SetPolyphonicEvent.hpp \
- events/SetPolyphonicEvent.cpp \
events/SetPortValueQueuedEvent.cpp \
events/SetPortValueQueuedEvent.hpp \
events/UnregisterClientEvent.cpp \
diff --git a/src/libs/engine/MidiControlNode.cpp b/src/libs/engine/MidiControlNode.cpp
index a2db6696..2e4fca1a 100644
--- a/src/libs/engine/MidiControlNode.cpp
+++ b/src/libs/engine/MidiControlNode.cpp
@@ -15,16 +15,17 @@
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "MidiControlNode.hpp"
#include <math.h>
#include <raul/midi_events.h>
+#include "MidiControlNode.hpp"
#include "PostProcessor.hpp"
#include "MidiLearnEvent.hpp"
#include "InputPort.hpp"
#include "OutputPort.hpp"
#include "Plugin.hpp"
-#include "util.hpp"
#include "AudioBuffer.hpp"
+#include "ProcessContext.hpp"
+#include "util.hpp"
namespace Ingen {
@@ -71,18 +72,18 @@ MidiControlNode::MidiControlNode(const string& path, bool polyphonic, Patch* par
void
-MidiControlNode::process(ProcessContext& context, SampleCount nframes, FrameTime start, FrameTime end)
+MidiControlNode::process(ProcessContext& context)
{
- NodeBase::pre_process(nframes, start, end);
+ NodeBase::pre_process(context);
double timestamp = 0;
uint32_t size = 0;
unsigned char* buffer = NULL;
MidiBuffer* const midi_in = (MidiBuffer*)_midi_in_port->buffer(0);
- assert(midi_in->this_nframes() == nframes);
+ assert(midi_in->this_nframes() == context.nframes());
- while (midi_in->get_event(&timestamp, &size, &buffer) < nframes) {
+ while (midi_in->get_event(&timestamp, &size, &buffer) < context.nframes()) {
if (size >= 3 && (buffer[0] & 0xF0) == MIDI_CMD_CONTROL)
control(buffer[1], buffer[2], (SampleCount)timestamp);
@@ -90,7 +91,7 @@ MidiControlNode::process(ProcessContext& context, SampleCount nframes, FrameTime
midi_in->increment();
}
- NodeBase::post_process(nframes, start, end);
+ NodeBase::post_process(context);
}
diff --git a/src/libs/engine/MidiControlNode.hpp b/src/libs/engine/MidiControlNode.hpp
index 3b09668f..0bee3db9 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& context, SampleCount nframes, FrameTime start, FrameTime end);
+ void process(ProcessContext& context);
void control(uchar control_num, uchar val, SampleCount offset);
diff --git a/src/libs/engine/MidiDriver.hpp b/src/libs/engine/MidiDriver.hpp
index 13b87726..b4d7b1f1 100644
--- a/src/libs/engine/MidiDriver.hpp
+++ b/src/libs/engine/MidiDriver.hpp
@@ -18,10 +18,11 @@
#ifndef MIDIDRIVER_H
#define MIDIDRIVER_H
+#include <iostream>
#include "types.hpp"
#include "Driver.hpp"
-#include <iostream>
#include "MidiBuffer.hpp"
+#include "ProcessContext.hpp"
namespace Ingen {
@@ -41,19 +42,13 @@ public:
*
* 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;
+ virtual void pre_process(ProcessContext& context) = 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;
+ virtual void post_process(ProcessContext& context) = 0;
};
@@ -90,8 +85,8 @@ public:
void add_port(DriverPort* port) {}
DriverPort* remove_port(const Raul::Path& path) { return NULL; }
- void pre_process(ProcessContext& context, SampleCount nframes, FrameTime start, FrameTime end) {}
- void post_process(ProcessContext& context, SampleCount nframes, FrameTime start, FrameTime end) {}
+ void pre_process(ProcessContext& context) {}
+ void post_process(ProcessContext& context) {}
};
diff --git a/src/libs/engine/MidiNoteNode.cpp b/src/libs/engine/MidiNoteNode.cpp
index bfab7ed0..c4f53e58 100644
--- a/src/libs/engine/MidiNoteNode.cpp
+++ b/src/libs/engine/MidiNoteNode.cpp
@@ -28,6 +28,7 @@
#include "Plugin.hpp"
#include "AudioDriver.hpp"
#include "Patch.hpp"
+#include "ProcessContext.hpp"
#include "util.hpp"
using std::cerr; using std::cout; using std::endl;
@@ -119,44 +120,44 @@ MidiNoteNode::apply_poly(Raul::Maid& maid, uint32_t poly)
void
-MidiNoteNode::process(ProcessContext& context, SampleCount nframes, FrameTime start, FrameTime end)
+MidiNoteNode::process(ProcessContext& context)
{
- NodeBase::pre_process(nframes, start, end);
+ NodeBase::pre_process(context);
double timestamp = 0;
uint32_t size = 0;
unsigned char* buffer = NULL;
MidiBuffer* const midi_in = (MidiBuffer*)_midi_in_port->buffer(0);
- assert(midi_in->this_nframes() == nframes);
+ assert(midi_in->this_nframes() == context.nframes());
if (midi_in->event_count() > 0)
- while (midi_in->get_event(&timestamp, &size, &buffer) < nframes) {
+ while (midi_in->get_event(&timestamp, &size, &buffer) < context.nframes()) {
- const FrameTime time = start + (FrameTime)timestamp;
+ const FrameTime time = context.start() + (FrameTime)timestamp;
if (size >= 3) {
switch (buffer[0] & 0xF0) {
case MIDI_CMD_NOTE_ON:
if (buffer[2] == 0)
- note_off(buffer[1], time, nframes, start, end);
+ note_off(buffer[1], time, context);
else
- note_on(buffer[1], buffer[2], time, nframes, start, end);
+ note_on(buffer[1], buffer[2], time, context);
break;
case MIDI_CMD_NOTE_OFF:
- note_off(buffer[1], time, nframes, start, end);
+ note_off(buffer[1], time, context);
break;
case MIDI_CMD_CONTROL:
switch (buffer[1]) {
case MIDI_CTL_ALL_NOTES_OFF:
case MIDI_CTL_ALL_SOUNDS_OFF:
- all_notes_off(time, nframes, start, end);
+ all_notes_off(time, context);
break;
case MIDI_CTL_SUSTAIN:
if (buffer[2] > 63)
- sustain_on(time, nframes, start, end);
+ sustain_on(time, context);
else
- sustain_off(time, nframes, start, end);
+ sustain_off(time, context);
break;
case MIDI_CMD_BENDER:
// ?
@@ -178,15 +179,15 @@ MidiNoteNode::process(ProcessContext& context, SampleCount nframes, FrameTime st
break;
}
- NodeBase::post_process(nframes, start, end);
+ NodeBase::post_process(context);
}
void
-MidiNoteNode::note_on(uchar note_num, uchar velocity, FrameTime time, SampleCount nframes, FrameTime start, FrameTime end)
+MidiNoteNode::note_on(uchar note_num, uchar velocity, FrameTime time, ProcessContext& context)
{
- assert(time >= start && time <= end);
- assert(time - start < _buffer_size);
+ assert(time >= context.start() && time <= context.end());
+ assert(time - context.start() < _buffer_size);
assert(note_num <= 127);
Key* key = &_keys[note_num];
@@ -244,7 +245,7 @@ MidiNoteNode::note_on(uchar note_num, uchar velocity, FrameTime time, SampleCoun
// FIXME FIXME FIXME
- SampleCount offset = time - start;
+ SampleCount offset = time - context.start();
// one-sample jitter hack to avoid having to deal with trigger sample "next time"
if (offset == (SampleCount)(_buffer_size-1))
@@ -266,10 +267,10 @@ MidiNoteNode::note_on(uchar note_num, uchar velocity, FrameTime time, SampleCoun
void
-MidiNoteNode::note_off(uchar note_num, FrameTime time, SampleCount nframes, FrameTime start, FrameTime end)
+MidiNoteNode::note_off(uchar note_num, FrameTime time, ProcessContext& context)
{
- assert(time >= start && time <= end);
- assert(time - start < _buffer_size);
+ assert(time >= context.start() && time <= context.end());
+ assert(time - context.start() < _buffer_size);
Key* key = &_keys[note_num];
@@ -282,7 +283,7 @@ MidiNoteNode::note_off(uchar note_num, FrameTime time, SampleCount nframes, Fram
if ( ! _sustain) {
//cerr << "... free voice " << key->voice << endl;
- free_voice(key->voice, time, nframes, start, end);
+ free_voice(key->voice, time, context);
} else {
//cerr << "... hold voice " << key->voice << endl;
(*_voices)[key->voice].state = Voice::HOLDING;
@@ -300,10 +301,10 @@ MidiNoteNode::note_off(uchar note_num, FrameTime time, SampleCount nframes, Fram
void
-MidiNoteNode::free_voice(uint32_t voice, FrameTime time, SampleCount nframes, FrameTime start, FrameTime end)
+MidiNoteNode::free_voice(uint32_t voice, FrameTime time, ProcessContext& context)
{
- assert(time >= start && time <= end);
- assert(time - start < _buffer_size);
+ assert(time >= context.start() && time <= context.end());
+ assert(time - context.start() < _buffer_size);
// Find a key to reassign to the freed voice (the newest, if there is one)
Key* replace_key = NULL;
@@ -323,7 +324,7 @@ MidiNoteNode::free_voice(uint32_t voice, FrameTime time, SampleCount nframes, Fr
assert(replace_key->state == Key::ON_UNASSIGNED);
// Change the freq but leave the gate high and don't retrigger
- ((AudioBuffer*)_freq_port->buffer(voice))->set(note_to_freq(replace_key_num), time - start);
+ ((AudioBuffer*)_freq_port->buffer(voice))->set(note_to_freq(replace_key_num), time - context.start());
replace_key->state = Key::ON_ASSIGNED;
replace_key->voice = voice;
@@ -333,24 +334,24 @@ MidiNoteNode::free_voice(uint32_t voice, FrameTime time, SampleCount nframes, Fr
} else {
// No new note for voice, deactivate (set gate low)
//cerr << "[MidiNoteNode] Note off. Key " << (int)note_num << ", Voice " << voice << " Killed" << endl;
- ((AudioBuffer*)_gate_port->buffer(voice))->set(0.0f, time - start);
+ ((AudioBuffer*)_gate_port->buffer(voice))->set(0.0f, time - context.start());
(*_voices)[voice].state = Voice::FREE;
}
}
void
-MidiNoteNode::all_notes_off(FrameTime time, SampleCount nframes, FrameTime start, FrameTime end)
+MidiNoteNode::all_notes_off(FrameTime time, ProcessContext& context)
{
- assert(time >= start && time <= end);
- assert(time - start < _buffer_size);
+ assert(time >= context.start() && time <= context.end());
+ assert(time - context.start() < _buffer_size);
//cerr << "Note off starting at sample " << offset << endl;
// FIXME: set all keys to Key::OFF?
for (uint32_t i=0; i < _polyphony; ++i) {
- ((AudioBuffer*)_gate_port->buffer(i))->set(0.0f, time - start);
+ ((AudioBuffer*)_gate_port->buffer(i))->set(0.0f, time - context.start());
(*_voices)[i].state = Voice::FREE;
}
}
@@ -367,23 +368,23 @@ MidiNoteNode::note_to_freq(int num)
void
-MidiNoteNode::sustain_on(FrameTime time, SampleCount nframes, FrameTime start, FrameTime end)
+MidiNoteNode::sustain_on(FrameTime time, ProcessContext& context)
{
_sustain = true;
}
void
-MidiNoteNode::sustain_off(FrameTime time, SampleCount nframes, FrameTime start, FrameTime end)
+MidiNoteNode::sustain_off(FrameTime time, ProcessContext& context)
{
- assert(time >= start && time <= end);
- assert(time - start < _buffer_size);
+ assert(time >= context.start() && time <= context.end());
+ assert(time - context.start() < _buffer_size);
_sustain = false;
for (uint32_t i=0; i < _polyphony; ++i)
if ((*_voices)[i].state == Voice::HOLDING)
- free_voice(i, time, nframes, start, end);
+ free_voice(i, time, context);
}
diff --git a/src/libs/engine/MidiNoteNode.hpp b/src/libs/engine/MidiNoteNode.hpp
index a73f08f7..1030bec5 100644
--- a/src/libs/engine/MidiNoteNode.hpp
+++ b/src/libs/engine/MidiNoteNode.hpp
@@ -45,14 +45,14 @@ public:
bool prepare_poly(uint32_t poly);
bool apply_poly(Raul::Maid& maid, uint32_t poly);
- void process(ProcessContext& context, SampleCount nframes, FrameTime start, FrameTime end);
+ void process(ProcessContext& context);
- 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);
- void all_notes_off(FrameTime time, SampleCount nframes, FrameTime start, FrameTime end);
+ void note_on(uchar note_num, uchar velocity, FrameTime time, ProcessContext& context);
+ void note_off(uchar note_num, FrameTime time, ProcessContext& context);
+ void all_notes_off(FrameTime time, ProcessContext& context);
- void sustain_on(FrameTime time, SampleCount nframes, FrameTime start, FrameTime end);
- void sustain_off(FrameTime time, SampleCount nframes, FrameTime start, FrameTime end);
+ void sustain_on(FrameTime time, ProcessContext& context);
+ void sustain_off(FrameTime time, ProcessContext& context);
private:
/** Key, one for each key on the keyboard */
@@ -70,7 +70,7 @@ private:
};
float note_to_freq(int num);
- void free_voice(uint32_t voice, FrameTime time, SampleCount nframes, FrameTime start, FrameTime end);
+ void free_voice(uint32_t voice, FrameTime time, ProcessContext& context);
Raul::Array<Voice>* _voices;
Raul::Array<Voice>* _prepared_voices;
diff --git a/src/libs/engine/MidiTriggerNode.cpp b/src/libs/engine/MidiTriggerNode.cpp
index 7a889d43..04363b3d 100644
--- a/src/libs/engine/MidiTriggerNode.cpp
+++ b/src/libs/engine/MidiTriggerNode.cpp
@@ -22,6 +22,7 @@
#include "InputPort.hpp"
#include "OutputPort.hpp"
#include "Plugin.hpp"
+#include "ProcessContext.hpp"
#include "util.hpp"
namespace Ingen {
@@ -59,31 +60,31 @@ MidiTriggerNode::MidiTriggerNode(const string& path, bool polyphonic, Patch* par
void
-MidiTriggerNode::process(ProcessContext& context, SampleCount nframes, FrameTime start, FrameTime end)
+MidiTriggerNode::process(ProcessContext& context)
{
- NodeBase::pre_process(nframes, start, end);
+ NodeBase::pre_process(context);
double timestamp = 0;
uint32_t size = 0;
unsigned char* buffer = NULL;
MidiBuffer* const midi_in = (MidiBuffer*)_midi_in_port->buffer(0);
- assert(midi_in->this_nframes() == nframes);
+ assert(midi_in->this_nframes() == context.nframes());
- while (midi_in->get_event(&timestamp, &size, &buffer) < nframes) {
+ while (midi_in->get_event(&timestamp, &size, &buffer) < context.nframes()) {
- const FrameTime time = start + (FrameTime)timestamp;
+ const FrameTime time = context.start() + (FrameTime)timestamp;
if (size >= 3) {
switch (buffer[0] & 0xF0) {
case MIDI_CMD_NOTE_ON:
if (buffer[2] == 0)
- note_off(buffer[1], time, nframes, start, end);
+ note_off(buffer[1], time, context);
else
- note_on(buffer[1], buffer[2], time, nframes, start, end);
+ note_on(buffer[1], buffer[2], time, context);
break;
case MIDI_CMD_NOTE_OFF:
- note_off(buffer[1], time, nframes, start, end);
+ note_off(buffer[1], time, context);
break;
case MIDI_CMD_CONTROL:
if (buffer[1] == MIDI_CTL_ALL_NOTES_OFF
@@ -97,15 +98,15 @@ MidiTriggerNode::process(ProcessContext& context, SampleCount nframes, FrameTime
midi_in->increment();
}
- NodeBase::post_process(nframes, start, end);
+ NodeBase::post_process(context);
}
void
-MidiTriggerNode::note_on(uchar note_num, uchar velocity, FrameTime time, SampleCount nframes, FrameTime start, FrameTime end)
+MidiTriggerNode::note_on(uchar note_num, uchar velocity, FrameTime time, ProcessContext& context)
{
- assert(time >= start && time <= end);
- assert(time - start < _buffer_size);
+ assert(time >= context.start() && time <= context.end());
+ assert(time - context.start() < _buffer_size);
//std::cerr << "Note on starting at sample " << offset << std::endl;
@@ -113,7 +114,7 @@ MidiTriggerNode::note_on(uchar note_num, uchar velocity, FrameTime time, SampleC
if (filter_note >= 0.0 && filter_note < 127.0 && (note_num == (uchar)filter_note)){
// FIXME FIXME FIXME
- SampleCount offset = time - start;
+ SampleCount offset = time - context.start();
// See comments in MidiNoteNode::note_on (FIXME)
if (offset == (SampleCount)(_buffer_size-1))
@@ -128,13 +129,13 @@ MidiTriggerNode::note_on(uchar note_num, uchar velocity, FrameTime time, SampleC
void
-MidiTriggerNode::note_off(uchar note_num, FrameTime time, SampleCount nframes, FrameTime start, FrameTime end)
+MidiTriggerNode::note_off(uchar note_num, FrameTime time, ProcessContext& context)
{
- assert(time >= start && time <= end);
- assert(time - start < _buffer_size);
+ assert(time >= context.start() && time <= context.end());
+ assert(time - context.start() < _buffer_size);
if (note_num == lrintf(((AudioBuffer*)_note_port->buffer(0))->value_at(0)))
- ((AudioBuffer*)_gate_port->buffer(0))->set(0.0f, time - start);
+ ((AudioBuffer*)_gate_port->buffer(0))->set(0.0f, time - context.start());
}
diff --git a/src/libs/engine/MidiTriggerNode.hpp b/src/libs/engine/MidiTriggerNode.hpp
index 2e1959b9..46bd4c6d 100644
--- a/src/libs/engine/MidiTriggerNode.hpp
+++ b/src/libs/engine/MidiTriggerNode.hpp
@@ -43,10 +43,10 @@ class MidiTriggerNode : public NodeBase
public:
MidiTriggerNode(const std::string& path, bool polyphonic, Patch* parent, SampleRate srate, size_t buffer_size);
- void process(ProcessContext& context, SampleCount nframes, FrameTime start, FrameTime end);
+ void process(ProcessContext& context);
- 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);
+ void note_on(uchar note_num, uchar velocity, FrameTime time, ProcessContext& context);
+ void note_off(uchar note_num, FrameTime time, ProcessContext& context);
private:
InputPort* _midi_in_port;
diff --git a/src/libs/engine/Node.hpp b/src/libs/engine/Node.hpp
index b305bc45..b1cefe65 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& context, SampleCount nframes, FrameTime start, FrameTime end) = 0;
+ virtual void process(ProcessContext& context) = 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 54caf8f8..f5d8d11a 100644
--- a/src/libs/engine/NodeBase.cpp
+++ b/src/libs/engine/NodeBase.cpp
@@ -174,24 +174,24 @@ NodeBase::signal_input_ready()
/** Prepare to run a cycle (in the audio thread)
*/
void
-NodeBase::pre_process(SampleCount nframes, FrameTime start, FrameTime end)
+NodeBase::pre_process(ProcessContext& context)
{
// Mix down any ports with multiple inputs
if (_ports)
for (size_t i=0; i < _ports->size(); ++i)
- _ports->at(i)->pre_process(nframes, start, end);
+ _ports->at(i)->pre_process(context);
}
/** Prepare to run a cycle (in the audio thread)
*/
void
-NodeBase::post_process(SampleCount nframes, FrameTime start, FrameTime end)
+NodeBase::post_process(ProcessContext& context)
{
/* Write output ports */
if (_ports)
for (size_t i=0; i < _ports->size(); ++i)
- _ports->at(i)->post_process(nframes, start, end);
+ _ports->at(i)->post_process(context);
}
diff --git a/src/libs/engine/NodeBase.hpp b/src/libs/engine/NodeBase.hpp
index b5dee178..d81b90a1 100644
--- a/src/libs/engine/NodeBase.hpp
+++ b/src/libs/engine/NodeBase.hpp
@@ -69,9 +69,9 @@ public:
virtual void wait_for_input(size_t num_providers);
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& context, SampleCount nframes, FrameTime start, FrameTime end) = 0;
- virtual void post_process(SampleCount nframes, FrameTime start, FrameTime end);
+ virtual void pre_process(ProcessContext& context);
+ virtual void process(ProcessContext& context) = 0;
+ virtual void post_process(ProcessContext& context);
virtual void set_port_buffer(uint32_t voice, uint32_t port_num, Buffer* buf) {}
diff --git a/src/libs/engine/OutputPort.cpp b/src/libs/engine/OutputPort.cpp
index b7da8956..260f3038 100644
--- a/src/libs/engine/OutputPort.cpp
+++ b/src/libs/engine/OutputPort.cpp
@@ -23,27 +23,23 @@ namespace Ingen {
void
-OutputPort::pre_process(SampleCount nframes, FrameTime start, FrameTime end)
+OutputPort::pre_process(ProcessContext& context)
{
for (uint32_t i=0; i < _poly; ++i)
- _buffers->at(i)->prepare_write(nframes);
+ _buffers->at(i)->prepare_write(context.nframes());
}
void
-OutputPort::process(ProcessContext& context, SampleCount nframes, FrameTime start, FrameTime end)
+OutputPort::post_process(ProcessContext& context)
{
if (_monitor && _type == DataType::FLOAT && _buffer_size == 1) {
- context.event_sink().control_change(this, ((AudioBuffer*)(*_buffers)[0])->value_at(0));
+ context.event_sink().control_change(this, context.start(),
+ ((AudioBuffer*)(*_buffers)[0])->value_at(0));
}
-}
-
-void
-OutputPort::post_process(SampleCount nframes, FrameTime start, FrameTime end)
-{
for (uint32_t i=0; i < _poly; ++i)
- _buffers->at(i)->prepare_read(nframes);
+ _buffers->at(i)->prepare_read(context.nframes());
}
diff --git a/src/libs/engine/OutputPort.hpp b/src/libs/engine/OutputPort.hpp
index 07daf6b6..bd42f07d 100644
--- a/src/libs/engine/OutputPort.hpp
+++ b/src/libs/engine/OutputPort.hpp
@@ -49,9 +49,8 @@ public:
: Port(parent, name, index, poly, type, buffer_size)
{}
- void pre_process(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);
+ void pre_process(ProcessContext& context);
+ void post_process(ProcessContext& context);
virtual ~OutputPort() {}
diff --git a/src/libs/engine/Patch.cpp b/src/libs/engine/Patch.cpp
index 80d59768..b717142a 100644
--- a/src/libs/engine/Patch.cpp
+++ b/src/libs/engine/Patch.cpp
@@ -147,25 +147,25 @@ Patch::apply_internal_poly(Raul::Maid& maid, uint32_t poly)
* Calls all Nodes in (roughly, if parallel) the order _compiled_patch specifies.
*/
void
-Patch::process(ProcessContext& context, SampleCount nframes, FrameTime start, FrameTime end)
+Patch::process(ProcessContext& context)
{
if (_compiled_patch == NULL || _compiled_patch->size() == 0 || !_process)
return;
- NodeBase::pre_process(nframes, start, end);
+ NodeBase::pre_process(context);
/* Run */
if (_engine.process_slaves().size() > 0)
- process_parallel(context, nframes, start, end);
+ process_parallel(context);
else
- process_single(context, nframes, start, end);
+ process_single(context);
- NodeBase::post_process(nframes, start, end);
+ NodeBase::post_process(context);
}
void
-Patch::process_parallel(ProcessContext& context, SampleCount nframes, FrameTime start, FrameTime end)
+Patch::process_parallel(ProcessContext& context)
{
size_t n_slaves = _engine.process_slaves().size();
@@ -181,7 +181,7 @@ Patch::process_parallel(ProcessContext& context, SampleCount nframes, FrameTime
(*cp)[i].node()->reset_input_ready();
for (size_t i=0; i < n_slaves; ++i)
- _engine.process_slaves()[i]->whip(cp, i+1, nframes, start, end);
+ _engine.process_slaves()[i]->whip(cp, i+1, context);
}
@@ -201,7 +201,7 @@ Patch::process_parallel(ProcessContext& context, SampleCount nframes, FrameTime
if (n.node()->process_lock()) {
if (n.node()->n_inputs_ready() == n.n_providers()) {
- n.node()->process(context, nframes, start, end);
+ n.node()->process(context);
/* Signal dependants their input is ready */
for (size_t i=0; i < n.dependants().size(); ++i)
@@ -233,12 +233,12 @@ Patch::process_parallel(ProcessContext& context, SampleCount nframes, FrameTime
void
-Patch::process_single(ProcessContext& context, SampleCount nframes, FrameTime start, FrameTime end)
+Patch::process_single(ProcessContext& context)
{
CompiledPatch* const cp = _compiled_patch;
for (size_t i=0; i < cp->size(); ++i)
- (*cp)[i].node()->process(context, nframes, start, end);
+ (*cp)[i].node()->process(context);
}
diff --git a/src/libs/engine/Patch.hpp b/src/libs/engine/Patch.hpp
index fd95e5bb..6bd07768 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& context, SampleCount nframes, FrameTime start, FrameTime end);
+ void process(ProcessContext& context);
void set_buffer_size(size_t size);
@@ -113,8 +113,8 @@ public:
private:
inline void compile_recursive(Node* n, CompiledPatch* output) const;
- void process_parallel(ProcessContext& context, SampleCount nframes, FrameTime start, FrameTime end);
- void process_single(ProcessContext& context, SampleCount nframes, FrameTime start, FrameTime end);
+ void process_parallel(ProcessContext& context);
+ void process_single(ProcessContext& context);
Engine& _engine;
uint32_t _internal_poly;
diff --git a/src/libs/engine/Port.hpp b/src/libs/engine/Port.hpp
index f02d6ba4..35bf0f9b 100644
--- a/src/libs/engine/Port.hpp
+++ b/src/libs/engine/Port.hpp
@@ -67,8 +67,9 @@ public:
Buffer* buffer(uint32_t voice) const { return _buffers->at(voice); }
/** Called once per process cycle */
- virtual void pre_process(SampleCount nframes, FrameTime start, FrameTime end) = 0;
- virtual void post_process(SampleCount nframes, FrameTime start, FrameTime end) {};
+ virtual void pre_process(ProcessContext& context) = 0;
+ virtual void process(ProcessContext& context) {};
+ virtual void post_process(ProcessContext& context) = 0;
/** Empty buffer contents completely (ie silence) */
virtual void clear_buffers();
diff --git a/src/libs/engine/PostProcessor.cpp b/src/libs/engine/PostProcessor.cpp
index ccf3b0a5..d1b09271 100644
--- a/src/libs/engine/PostProcessor.cpp
+++ b/src/libs/engine/PostProcessor.cpp
@@ -20,16 +20,22 @@
#include <pthread.h>
#include <raul/SRSWQueue.hpp>
//#include <raul/Maid.hpp>
+#include "events/SendPortValueEvent.hpp"
#include "Event.hpp"
#include "PostProcessor.hpp"
+#include "Engine.hpp"
+#include "AudioDriver.hpp"
+#include "ProcessContext.hpp"
-using std::cerr; using std::cout; using std::endl;
+using namespace std;
namespace Ingen {
-PostProcessor::PostProcessor(size_t queue_size)
- : _events(queue_size)
+PostProcessor::PostProcessor(Engine& engine, size_t queue_size)
+ : _engine(engine)
+ , _max_time(0)
+ , _events(queue_size)
{
}
@@ -37,8 +43,21 @@ PostProcessor::PostProcessor(size_t queue_size)
void
PostProcessor::process()
{
+ /* Process any audio thread generated events */
+ /* FIXME: process events from all thread if parallel */
+ /* TODO: obviously this needs work to be generic */
+ SendPortValueEvent ev(_engine, 0, NULL, false, 0, 0.0f);
+ while (_engine.audio_driver()->context().event_sink().read_control_change(ev)) {
+ ev.post_process();
+ }
+
+ FrameTime end_time = _max_time.get();
+
+ /* Process normal events */
while ( ! _events.empty()) {
Event* const ev = _events.front();
+ if (ev->time() > end_time)
+ break;
_events.pop();
assert(ev);
ev->post_process();
diff --git a/src/libs/engine/PostProcessor.hpp b/src/libs/engine/PostProcessor.hpp
index 114a8bef..cc19cdbe 100644
--- a/src/libs/engine/PostProcessor.hpp
+++ b/src/libs/engine/PostProcessor.hpp
@@ -28,6 +28,7 @@
namespace Ingen {
class Event;
+class Engine;
/** Processor for Events after leaving the audio thread.
@@ -44,7 +45,7 @@ class Event;
class PostProcessor //: public Raul::Slave
{
public:
- PostProcessor(/*Raul::Maid& maid, */size_t queue_size);
+ PostProcessor(Engine& engine, /*Raul::Maid& maid, */size_t queue_size);
/** Push an event on to the process queue, realtime-safe, not thread-safe. */
inline void push(Event* const ev) { _events.push(ev); }
@@ -52,7 +53,12 @@ public:
/** Post-process and delete all pending events */
void process();
+ /** Set the latest event time that should be post-processed */
+ void set_end_time(FrameTime time) { _max_time = time; }
+
private:
+ Engine& _engine;
+ Raul::AtomicInt _max_time;
//Raul::Maid& _maid;
Raul::SRSWQueue<Event*> _events;
//virtual void _whipped();
diff --git a/src/libs/engine/ProcessContext.hpp b/src/libs/engine/ProcessContext.hpp
index 4d5f733f..c85c9ff6 100644
--- a/src/libs/engine/ProcessContext.hpp
+++ b/src/libs/engine/ProcessContext.hpp
@@ -29,17 +29,34 @@ namespace Ingen {
* process in the audio thread, e.g. the available thread pool, sink for
* events (generated in the audio thread, not user initiated events), etc.
*
+ * Note the distinction between nframes and start/end. If transport speed
+ * != 1.0, end-start != nframes (though currently that is never the case, it
+ * may be in the future with sequencerey things).
+ *
* \ingroup engine
*/
class ProcessContext
{
public:
- ProcessContext() : _event_sink(1024) {} // FIXME: size?
-
- EventSink& event_sink() { return _event_sink; }
+ ProcessContext(Engine& engine) : _event_sink(engine, 1024) {} // FIXME: size?
+
+ void set_time_slice(SampleCount nframes, FrameTime start, FrameTime end) {
+ _nframes = nframes;
+ _start = start;
+ _end = end;
+ }
+
+ inline SampleCount nframes() const { return _nframes; }
+ inline FrameTime start() const { return _start; }
+ inline FrameTime end() const { return _end; }
+ inline const EventSink& event_sink() const { return _event_sink; }
+ inline EventSink& event_sink() { return _event_sink; }
private:
- EventSink _event_sink;
+ SampleCount _nframes; ///< Number of actual time (Jack) frames this cycle
+ FrameTime _start; ///< Start frame of this cycle, timeline relative
+ FrameTime _end; ///< End frame of this cycle, timeline relative
+ EventSink _event_sink; ///< Sink for events generated in the audio thread
};
diff --git a/src/libs/engine/ProcessSlave.cpp b/src/libs/engine/ProcessSlave.cpp
index d8f2e575..4a4107d0 100644
--- a/src/libs/engine/ProcessSlave.cpp
+++ b/src/libs/engine/ProcessSlave.cpp
@@ -25,7 +25,7 @@ using namespace std;
namespace Ingen {
-size_t ProcessSlave::_next_id = 0;
+uint32_t ProcessSlave::_next_id = 0;
void
@@ -49,7 +49,7 @@ ProcessSlave::_whipped()
n.node()->wait_for_input(n.n_providers());
- n.node()->process(_process_context, _nframes, _start, _end);
+ n.node()->process(_process_context);
/* Signal dependants their input is ready */
for (size_t i=0; i < n.dependants().size(); ++i)
diff --git a/src/libs/engine/ProcessSlave.hpp b/src/libs/engine/ProcessSlave.hpp
index c341fe64..87a190a2 100644
--- a/src/libs/engine/ProcessSlave.hpp
+++ b/src/libs/engine/ProcessSlave.hpp
@@ -35,8 +35,12 @@ class CompiledPatch;
class ProcessSlave : protected Raul::Slave {
public:
- ProcessSlave(bool realtime)
- : _id(_next_id++), _index(0), _state(STATE_FINISHED), _compiled_patch(NULL)
+ ProcessSlave(Engine& engine, bool realtime)
+ : _id(_next_id++)
+ , _index(0)
+ , _state(STATE_FINISHED)
+ , _compiled_patch(NULL)
+ , _process_context(engine)
{
std::stringstream ss;
ss << "Process Slave ";
@@ -53,15 +57,12 @@ public:
stop();
}
- inline void whip(CompiledPatch* compiled_patch, size_t start_index,
- SampleCount nframes, FrameTime start, FrameTime end) {
+ inline void whip(CompiledPatch* compiled_patch, uint32_t start_index, ProcessContext& context) {
assert(_state == STATE_FINISHED);
_index = start_index;
_state = STATE_RUNNING;
- _nframes = nframes;
- _start = start;
- _end = end;
_compiled_patch = compiled_patch;
+ _process_context.set_time_slice(context.nframes(), context.start(), context.end());
Raul::Slave::whip();
}
@@ -71,24 +72,23 @@ public:
_state.compare_and_exchange(STATE_RUNNING, STATE_FINISH_SIGNALLED);
}
- size_t id() const { return _id; }
+ inline uint32_t id() const { return _id; }
+ inline const ProcessContext& context() const { return _process_context; }
+ inline ProcessContext& context() { return _process_context; }
private:
void _whipped();
- static size_t _next_id;
+ static uint32_t _next_id;
static const int STATE_RUNNING = 0;
static const int STATE_FINISH_SIGNALLED = 1;
static const int STATE_FINISHED = 2;
- size_t _id;
- size_t _index;
+ uint32_t _id;
+ uint32_t _index;
Raul::AtomicInt _state;
- SampleCount _nframes;
- FrameTime _start;
- FrameTime _end;
CompiledPatch* _compiled_patch;
ProcessContext _process_context;
};
diff --git a/src/libs/engine/QueuedEvent.hpp b/src/libs/engine/QueuedEvent.hpp
index 69baefe4..e616d269 100644
--- a/src/libs/engine/QueuedEvent.hpp
+++ b/src/libs/engine/QueuedEvent.hpp
@@ -44,25 +44,9 @@ class QueuedEvent : public Event
public:
/** Process this event into a realtime-suitable event.
*/
- virtual void pre_process() {
- assert(ThreadManager::current_thread_id() == THREAD_PRE_PROCESS);
- assert(_pre_processed == false);
- _pre_processed = true;
- }
-
- virtual void execute(SampleCount nframes, FrameTime start, FrameTime end) {
- assert(_pre_processed);
- assert(_time <= end);
-
- // Didn't prepare in time. QueuedEvents aren't (necessarily) sample accurate
- // so just run at the beginning of this cycle
- if (_time <= start)
- _time = start;
-
- Event::execute(nframes, start, end);
- }
+ virtual void pre_process();
- virtual void post_process() {}
+ virtual void execute(ProcessContext& context);
/** If this event blocks the prepare phase of other slow events */
bool is_blocking() { return _blocking; }
diff --git a/src/libs/engine/QueuedEventSource.cpp b/src/libs/engine/QueuedEventSource.cpp
index 634b94da..5dcaf255 100644
--- a/src/libs/engine/QueuedEventSource.cpp
+++ b/src/libs/engine/QueuedEventSource.cpp
@@ -15,14 +15,15 @@
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <sys/mman.h>
+#include <iostream>
#include "QueuedEventSource.hpp"
#include "QueuedEvent.hpp"
#include "PostProcessor.hpp"
#include "ThreadManager.hpp"
-#include <sys/mman.h>
-#include <iostream>
-using std::cout; using std::cerr; using std::endl;
+#include "ProcessContext.hpp"
+using namespace std;
namespace Ingen {
@@ -77,7 +78,7 @@ QueuedEventSource::push_queued(QueuedEvent* const ev)
* Executed events will be pushed to @a dest.
*/
void
-QueuedEventSource::process(PostProcessor& dest, SampleCount nframes, FrameTime cycle_start, FrameTime cycle_end)
+QueuedEventSource::process(PostProcessor& dest, ProcessContext& context)
{
assert(ThreadManager::current_thread_id() == THREAD_PROCESS);
@@ -87,21 +88,21 @@ QueuedEventSource::process(PostProcessor& dest, SampleCount nframes, FrameTime c
* makes the process callback (more) realtime-safe by preventing being
* choked by events coming in faster than they can be processed.
* FIXME: test this and figure out a good value */
- const unsigned int MAX_QUEUED_EVENTS = nframes / 100;
+ const unsigned int MAX_QUEUED_EVENTS = context.nframes() / 100;
unsigned int num_events_processed = 0;
/* FIXME: Merge these next two loops into one */
- while ((ev = pop_earliest_queued_before(cycle_end))) {
- ev->execute(nframes, cycle_start, cycle_end);
+ while ((ev = pop_earliest_queued_before(context.end()))) {
+ ev->execute(context);
dest.push(ev);
if (++num_events_processed > MAX_QUEUED_EVENTS)
break;
}
- while ((ev = pop_earliest_stamped_before(cycle_end))) {
- ev->execute(nframes, cycle_start, cycle_end);
+ while ((ev = pop_earliest_stamped_before(context.end()))) {
+ ev->execute(context);
dest.push(ev);
++num_events_processed;
}
diff --git a/src/libs/engine/QueuedEventSource.hpp b/src/libs/engine/QueuedEventSource.hpp
index d4cbc1ab..4c212ee1 100644
--- a/src/libs/engine/QueuedEventSource.hpp
+++ b/src/libs/engine/QueuedEventSource.hpp
@@ -52,7 +52,7 @@ public:
void activate() { Slave::start(); }
void deactivate() { Slave::stop(); }
- void process(PostProcessor& dest, SampleCount nframes, FrameTime cycle_start, FrameTime cycle_end);
+ void process(PostProcessor& dest, ProcessContext& context);
void unblock();
diff --git a/src/libs/engine/TransportNode.cpp b/src/libs/engine/TransportNode.cpp
index 6ee9835d..eddbc70d 100644
--- a/src/libs/engine/TransportNode.cpp
+++ b/src/libs/engine/TransportNode.cpp
@@ -82,9 +82,9 @@ TransportNode::TransportNode(const string& path, bool polyphonic, Patch* parent,
void
-TransportNode::process(ProcessContext& context, SampleCount nframes, FrameTime start, FrameTime end)
+TransportNode::process(ProcessContext& context)
{
- NodeBase::pre_process(nframes, start, end);
+ NodeBase::pre_process(context);
#if 0
// FIXME: this will die horribly with any driver other than jack (in theory)
@@ -149,7 +149,7 @@ TransportNode::process(ProcessContext& context, SampleCount nframes, FrameTime s
}
#endif
- NodeBase::post_process(nframes, start, end);
+ NodeBase::post_process(context);
}
diff --git a/src/libs/engine/TransportNode.hpp b/src/libs/engine/TransportNode.hpp
index bf11f309..e79d5737 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& context, SampleCount nframes, FrameTime start, FrameTime end);
+ virtual void process(ProcessContext& context);
};
diff --git a/src/libs/engine/events/AddNodeEvent.cpp b/src/libs/engine/events/AddNodeEvent.cpp
index 8dbe5f3f..f121c50e 100644
--- a/src/libs/engine/events/AddNodeEvent.cpp
+++ b/src/libs/engine/events/AddNodeEvent.cpp
@@ -107,9 +107,9 @@ AddNodeEvent::pre_process()
void
-AddNodeEvent::execute(SampleCount nframes, FrameTime start, FrameTime end)
+AddNodeEvent::execute(ProcessContext& context)
{
- QueuedEvent::execute(nframes, start, end);
+ QueuedEvent::execute(context);
if (_node != NULL) {
if (_patch->compiled_patch() != NULL)
diff --git a/src/libs/engine/events/AddNodeEvent.hpp b/src/libs/engine/events/AddNodeEvent.hpp
index eaf48807..ebee44b4 100644
--- a/src/libs/engine/events/AddNodeEvent.hpp
+++ b/src/libs/engine/events/AddNodeEvent.hpp
@@ -59,7 +59,7 @@ public:
bool poly);
void pre_process();
- void execute(SampleCount nframes, FrameTime start, FrameTime end);
+ void execute(ProcessContext& context);
void post_process();
private:
diff --git a/src/libs/engine/events/AddPortEvent.cpp b/src/libs/engine/events/AddPortEvent.cpp
index d31c2169..6aeb7f0f 100644
--- a/src/libs/engine/events/AddPortEvent.cpp
+++ b/src/libs/engine/events/AddPortEvent.cpp
@@ -133,9 +133,9 @@ AddPortEvent::pre_process()
void
-AddPortEvent::execute(SampleCount nframes, FrameTime start, FrameTime end)
+AddPortEvent::execute(ProcessContext& context)
{
- QueuedEvent::execute(nframes, start, end);
+ QueuedEvent::execute(context);
if (_patch_port) {
diff --git a/src/libs/engine/events/AddPortEvent.hpp b/src/libs/engine/events/AddPortEvent.hpp
index 8b40d370..f430d50c 100644
--- a/src/libs/engine/events/AddPortEvent.hpp
+++ b/src/libs/engine/events/AddPortEvent.hpp
@@ -45,7 +45,7 @@ public:
AddPortEvent(Engine& engine, SharedPtr<Responder> responder, SampleCount timestamp, const string& path, const string& type, bool is_output, QueuedEventSource* source);
void pre_process();
- void execute(SampleCount nframes, FrameTime start, FrameTime end);
+ void execute(ProcessContext& context);
void post_process();
private:
diff --git a/src/libs/engine/events/AllNotesOffEvent.cpp b/src/libs/engine/events/AllNotesOffEvent.cpp
index 130fb794..f3491dac 100644
--- a/src/libs/engine/events/AllNotesOffEvent.cpp
+++ b/src/libs/engine/events/AllNotesOffEvent.cpp
@@ -43,9 +43,9 @@ AllNotesOffEvent::AllNotesOffEvent(Engine& engine, SharedPtr<Responder> responde
void
-AllNotesOffEvent::execute(SampleCount nframes, FrameTime start, FrameTime end)
+AllNotesOffEvent::execute(ProcessContext& context)
{
- Event::execute(nframes, start, end);
+ Event::execute(context);
if (_patch == NULL && _patch_path != "")
_patch = _engine.object_store()->find_patch(_patch_path);
diff --git a/src/libs/engine/events/AllNotesOffEvent.hpp b/src/libs/engine/events/AllNotesOffEvent.hpp
index c9263a40..4c2a9309 100644
--- a/src/libs/engine/events/AllNotesOffEvent.hpp
+++ b/src/libs/engine/events/AllNotesOffEvent.hpp
@@ -37,7 +37,7 @@ public:
AllNotesOffEvent(Engine& engine, SharedPtr<Responder> responder, SampleCount timestamp, Patch* patch);
AllNotesOffEvent(Engine& engine, SharedPtr<Responder> responder, SampleCount timestamp, const string& patch_path);
- void execute(SampleCount nframes, FrameTime start, FrameTime end);
+ void execute(ProcessContext& context);
void post_process();
private:
diff --git a/src/libs/engine/events/ClearPatchEvent.cpp b/src/libs/engine/events/ClearPatchEvent.cpp
index aa72cd54..a4d5c8df 100644
--- a/src/libs/engine/events/ClearPatchEvent.cpp
+++ b/src/libs/engine/events/ClearPatchEvent.cpp
@@ -61,9 +61,9 @@ ClearPatchEvent::pre_process()
void
-ClearPatchEvent::execute(SampleCount nframes, FrameTime start, FrameTime end)
+ClearPatchEvent::execute(ProcessContext& context)
{
- QueuedEvent::execute(nframes, start, end);
+ QueuedEvent::execute(context);
if (_patch != NULL) {
_patch->disable();
diff --git a/src/libs/engine/events/ClearPatchEvent.hpp b/src/libs/engine/events/ClearPatchEvent.hpp
index dbcad25b..b1174c04 100644
--- a/src/libs/engine/events/ClearPatchEvent.hpp
+++ b/src/libs/engine/events/ClearPatchEvent.hpp
@@ -39,7 +39,7 @@ public:
ClearPatchEvent(Engine& engine, SharedPtr<Responder> responder, FrameTime time, QueuedEventSource* source, const string& patch_path);
void pre_process();
- void execute(SampleCount nframes, FrameTime start, FrameTime end);
+ void execute(ProcessContext& context);
void post_process();
private:
diff --git a/src/libs/engine/events/ConnectionEvent.cpp b/src/libs/engine/events/ConnectionEvent.cpp
index 69bb2645..4953eb02 100644
--- a/src/libs/engine/events/ConnectionEvent.cpp
+++ b/src/libs/engine/events/ConnectionEvent.cpp
@@ -145,9 +145,9 @@ ConnectionEvent::pre_process()
void
-ConnectionEvent::execute(SampleCount nframes, FrameTime start, FrameTime end)
+ConnectionEvent::execute(ProcessContext& context)
{
- QueuedEvent::execute(nframes, start, end);
+ QueuedEvent::execute(context);
if (_error == NO_ERROR) {
// These must be inserted here, since they're actually used by the audio thread
diff --git a/src/libs/engine/events/ConnectionEvent.hpp b/src/libs/engine/events/ConnectionEvent.hpp
index 202fef01..ed2318d8 100644
--- a/src/libs/engine/events/ConnectionEvent.hpp
+++ b/src/libs/engine/events/ConnectionEvent.hpp
@@ -52,7 +52,7 @@ public:
ConnectionEvent(Engine& engine, SharedPtr<Responder> responder, SampleCount timestamp, const string& src_port_path, const string& dst_port_path);
void pre_process();
- void execute(SampleCount nframes, FrameTime start, FrameTime end);
+ void execute(ProcessContext& context);
void post_process();
private:
diff --git a/src/libs/engine/events/CreatePatchEvent.cpp b/src/libs/engine/events/CreatePatchEvent.cpp
index 365b1a02..288eaee3 100644
--- a/src/libs/engine/events/CreatePatchEvent.cpp
+++ b/src/libs/engine/events/CreatePatchEvent.cpp
@@ -89,9 +89,9 @@ CreatePatchEvent::pre_process()
void
-CreatePatchEvent::execute(SampleCount nframes, FrameTime start, FrameTime end)
+CreatePatchEvent::execute(ProcessContext& context)
{
- QueuedEvent::execute(nframes, start, end);
+ QueuedEvent::execute(context);
if (_patch != NULL) {
if (_parent == NULL) {
diff --git a/src/libs/engine/events/CreatePatchEvent.hpp b/src/libs/engine/events/CreatePatchEvent.hpp
index 1eb33ed4..933ce066 100644
--- a/src/libs/engine/events/CreatePatchEvent.hpp
+++ b/src/libs/engine/events/CreatePatchEvent.hpp
@@ -45,7 +45,7 @@ public:
CreatePatchEvent(Engine& engine, SharedPtr<Responder> responder, SampleCount timestamp, const string& path, int poly);
void pre_process();
- void execute(SampleCount nframes, FrameTime start, FrameTime end);
+ void execute(ProcessContext& context);
void post_process();
private:
diff --git a/src/libs/engine/events/DSSIConfigureEvent.cpp b/src/libs/engine/events/DSSIConfigureEvent.cpp
index 3c325f35..a1588bed 100644
--- a/src/libs/engine/events/DSSIConfigureEvent.cpp
+++ b/src/libs/engine/events/DSSIConfigureEvent.cpp
@@ -50,9 +50,9 @@ DSSIConfigureEvent::pre_process()
void
-DSSIConfigureEvent::execute(SampleCount nframes, FrameTime start, FrameTime end)
+DSSIConfigureEvent::execute(ProcessContext& context)
{
- QueuedEvent::execute(nframes, start, end);
+ QueuedEvent::execute(context);
// Nothing.
}
diff --git a/src/libs/engine/events/DSSIConfigureEvent.hpp b/src/libs/engine/events/DSSIConfigureEvent.hpp
index 1ef43b50..5960daf9 100644
--- a/src/libs/engine/events/DSSIConfigureEvent.hpp
+++ b/src/libs/engine/events/DSSIConfigureEvent.hpp
@@ -34,7 +34,7 @@ public:
DSSIConfigureEvent(Engine& engine, SharedPtr<Responder> responder, SampleCount timestamp, const string& node_path, const string& key, const string& val);
void pre_process();
- void execute(SampleCount nframes, FrameTime start, FrameTime end);
+ void execute(ProcessContext& context);
void post_process();
private:
diff --git a/src/libs/engine/events/DSSIControlEvent.cpp b/src/libs/engine/events/DSSIControlEvent.cpp
index f0c261b0..648ec05a 100644
--- a/src/libs/engine/events/DSSIControlEvent.cpp
+++ b/src/libs/engine/events/DSSIControlEvent.cpp
@@ -49,9 +49,9 @@ DSSIControlEvent::pre_process()
void
-DSSIControlEvent::execute(SampleCount nframes, FrameTime start, FrameTime end)
+DSSIControlEvent::execute(ProcessContext& context)
{
- QueuedEvent::execute(nframes, start, end);
+ QueuedEvent::execute(context);
if (_node != NULL)
_node->set_control(_port_num, _val);
diff --git a/src/libs/engine/events/DSSIControlEvent.hpp b/src/libs/engine/events/DSSIControlEvent.hpp
index 68314fd7..56fd05cf 100644
--- a/src/libs/engine/events/DSSIControlEvent.hpp
+++ b/src/libs/engine/events/DSSIControlEvent.hpp
@@ -36,7 +36,7 @@ public:
DSSIControlEvent(Engine& engine, SharedPtr<Responder> responder, SampleCount timestamp, const string& node_path, int port_num, Sample val);
void pre_process();
- void execute(SampleCount nframes, FrameTime start, FrameTime end);
+ void execute(ProcessContext& context);
void post_process();
private:
diff --git a/src/libs/engine/events/DSSIProgramEvent.cpp b/src/libs/engine/events/DSSIProgramEvent.cpp
index 9e12255d..d791e484 100644
--- a/src/libs/engine/events/DSSIProgramEvent.cpp
+++ b/src/libs/engine/events/DSSIProgramEvent.cpp
@@ -52,9 +52,9 @@ DSSIProgramEvent::pre_process()
void
-DSSIProgramEvent::execute(SampleCount nframes, FrameTime start, FrameTime end)
+DSSIProgramEvent::execute(ProcessContext& context)
{
- QueuedEvent::execute(nframes, start, end);
+ QueuedEvent::execute(context);
if (_node != NULL)
_node->program(_bank, _program);
diff --git a/src/libs/engine/events/DSSIProgramEvent.hpp b/src/libs/engine/events/DSSIProgramEvent.hpp
index fa4760ce..b66dcb87 100644
--- a/src/libs/engine/events/DSSIProgramEvent.hpp
+++ b/src/libs/engine/events/DSSIProgramEvent.hpp
@@ -34,7 +34,7 @@ public:
DSSIProgramEvent(Engine& engine, SharedPtr<Responder> responder, SampleCount timestamp, const string& node_path, int bank, int program);
void pre_process();
- void execute(SampleCount nframes, FrameTime start, FrameTime end);
+ void execute(ProcessContext& context);
void post_process();
private:
diff --git a/src/libs/engine/events/DSSIUpdateEvent.cpp b/src/libs/engine/events/DSSIUpdateEvent.cpp
index bfb8f8fc..807cedad 100644
--- a/src/libs/engine/events/DSSIUpdateEvent.cpp
+++ b/src/libs/engine/events/DSSIUpdateEvent.cpp
@@ -55,9 +55,9 @@ DSSIUpdateEvent::pre_process()
void
-DSSIUpdateEvent::execute(SampleCount nframes, FrameTime start, FrameTime end)
+DSSIUpdateEvent::execute(ProcessContext& context)
{
- QueuedEvent::execute(nframes, start, end);
+ QueuedEvent::execute(context);
if (_node != NULL) {
_node->set_ui_url(_url);
diff --git a/src/libs/engine/events/DSSIUpdateEvent.hpp b/src/libs/engine/events/DSSIUpdateEvent.hpp
index 08c5a31a..16a2b50a 100644
--- a/src/libs/engine/events/DSSIUpdateEvent.hpp
+++ b/src/libs/engine/events/DSSIUpdateEvent.hpp
@@ -40,7 +40,7 @@ public:
DSSIUpdateEvent(Engine& engine, SharedPtr<Responder> responder, SampleCount timestamp, const string& path, const string& url);
void pre_process();
- void execute(SampleCount nframes, FrameTime start, FrameTime end);
+ void execute(ProcessContext& context);
void post_process();
private:
diff --git a/src/libs/engine/events/DeactivateEvent.cpp b/src/libs/engine/events/DeactivateEvent.cpp
index a7842a0d..a68419f0 100644
--- a/src/libs/engine/events/DeactivateEvent.cpp
+++ b/src/libs/engine/events/DeactivateEvent.cpp
@@ -36,9 +36,9 @@ DeactivateEvent::pre_process()
void
-DeactivateEvent::execute(SampleCount nframes, FrameTime start, FrameTime end)
+DeactivateEvent::execute(ProcessContext& context)
{
- QueuedEvent::execute(nframes, start, end);
+ QueuedEvent::execute(context);
}
diff --git a/src/libs/engine/events/DeactivateEvent.hpp b/src/libs/engine/events/DeactivateEvent.hpp
index e0ee2ea8..5a6750ba 100644
--- a/src/libs/engine/events/DeactivateEvent.hpp
+++ b/src/libs/engine/events/DeactivateEvent.hpp
@@ -33,7 +33,7 @@ public:
DeactivateEvent(Engine& engine, SharedPtr<Responder> responder, SampleCount timestamp);
void pre_process();
- void execute(SampleCount nframes, FrameTime start, FrameTime end);
+ void execute(ProcessContext& context);
void post_process();
};
diff --git a/src/libs/engine/events/DestroyEvent.cpp b/src/libs/engine/events/DestroyEvent.cpp
index ceb75816..a3d96ede 100644
--- a/src/libs/engine/events/DestroyEvent.cpp
+++ b/src/libs/engine/events/DestroyEvent.cpp
@@ -125,15 +125,15 @@ DestroyEvent::pre_process()
void
-DestroyEvent::execute(SampleCount nframes, FrameTime start, FrameTime end)
+DestroyEvent::execute(ProcessContext& context)
{
- QueuedEvent::execute(nframes, start, end);
+ QueuedEvent::execute(context);
if (_patch_node_listnode) {
assert(_node);
if (_disconnect_node_event)
- _disconnect_node_event->execute(nframes, start, end);
+ _disconnect_node_event->execute(context);
if (_node->parent_patch()->compiled_patch())
_engine.maid()->push(_node->parent_patch()->compiled_patch());
@@ -143,7 +143,7 @@ DestroyEvent::execute(SampleCount nframes, FrameTime start, FrameTime end)
assert(_port);
if (_disconnect_port_event)
- _disconnect_port_event->execute(nframes, start, end);
+ _disconnect_port_event->execute(context);
if (_port->parent_patch()->compiled_patch())
_engine.maid()->push(_port->parent_patch()->compiled_patch());
diff --git a/src/libs/engine/events/DestroyEvent.hpp b/src/libs/engine/events/DestroyEvent.hpp
index 82024e90..5ab3b01f 100644
--- a/src/libs/engine/events/DestroyEvent.hpp
+++ b/src/libs/engine/events/DestroyEvent.hpp
@@ -55,7 +55,7 @@ public:
~DestroyEvent();
void pre_process();
- void execute(SampleCount nframes, FrameTime start, FrameTime end);
+ void execute(ProcessContext& context);
void post_process();
private:
diff --git a/src/libs/engine/events/DisablePatchEvent.cpp b/src/libs/engine/events/DisablePatchEvent.cpp
index 146364d8..bc5219a6 100644
--- a/src/libs/engine/events/DisablePatchEvent.cpp
+++ b/src/libs/engine/events/DisablePatchEvent.cpp
@@ -45,9 +45,9 @@ DisablePatchEvent::pre_process()
void
-DisablePatchEvent::execute(SampleCount nframes, FrameTime start, FrameTime end)
+DisablePatchEvent::execute(ProcessContext& context)
{
- QueuedEvent::execute(nframes, start, end);
+ QueuedEvent::execute(context);
if (_patch != NULL)
_patch->disable();
diff --git a/src/libs/engine/events/DisablePatchEvent.hpp b/src/libs/engine/events/DisablePatchEvent.hpp
index 00cb5ce7..1a208246 100644
--- a/src/libs/engine/events/DisablePatchEvent.hpp
+++ b/src/libs/engine/events/DisablePatchEvent.hpp
@@ -38,7 +38,7 @@ public:
DisablePatchEvent(Engine& engine, SharedPtr<Responder> responder, SampleCount timestamp, const string& patch_path);
void pre_process();
- void execute(SampleCount nframes, FrameTime start, FrameTime end);
+ void execute(ProcessContext& context);
void post_process();
private:
diff --git a/src/libs/engine/events/DisablePortMonitoringEvent.cpp b/src/libs/engine/events/DisablePortMonitoringEvent.cpp
index 334970ae..3b5950ee 100644
--- a/src/libs/engine/events/DisablePortMonitoringEvent.cpp
+++ b/src/libs/engine/events/DisablePortMonitoringEvent.cpp
@@ -51,9 +51,9 @@ DisablePortMonitoringEvent::pre_process()
void
-DisablePortMonitoringEvent::execute(SampleCount nframes, FrameTime start, FrameTime end)
+DisablePortMonitoringEvent::execute(ProcessContext& context)
{
- QueuedEvent::execute(nframes, start, end);
+ QueuedEvent::execute(context);
#if 0
assert(_time >= start && _time <= end);
diff --git a/src/libs/engine/events/DisablePortMonitoringEvent.hpp b/src/libs/engine/events/DisablePortMonitoringEvent.hpp
index ed10c195..b2fac41b 100644
--- a/src/libs/engine/events/DisablePortMonitoringEvent.hpp
+++ b/src/libs/engine/events/DisablePortMonitoringEvent.hpp
@@ -44,7 +44,7 @@ public:
const std::string& port_path);
void pre_process();
- void execute(SampleCount nframes, FrameTime start, FrameTime end);
+ void execute(ProcessContext& context);
void post_process();
private:
diff --git a/src/libs/engine/events/DisconnectNodeEvent.cpp b/src/libs/engine/events/DisconnectNodeEvent.cpp
index 97dfc3d5..b1f76dd6 100644
--- a/src/libs/engine/events/DisconnectNodeEvent.cpp
+++ b/src/libs/engine/events/DisconnectNodeEvent.cpp
@@ -113,13 +113,13 @@ DisconnectNodeEvent::pre_process()
void
-DisconnectNodeEvent::execute(SampleCount nframes, FrameTime start, FrameTime end)
+DisconnectNodeEvent::execute(ProcessContext& context)
{
- QueuedEvent::execute(nframes, start, end);
+ QueuedEvent::execute(context);
if (_succeeded) {
for (Raul::List<DisconnectionEvent*>::iterator i = _disconnection_events.begin(); i != _disconnection_events.end(); ++i)
- (*i)->execute(nframes, start, end);
+ (*i)->execute(context);
}
}
diff --git a/src/libs/engine/events/DisconnectNodeEvent.hpp b/src/libs/engine/events/DisconnectNodeEvent.hpp
index 9ed7cb3a..616f321f 100644
--- a/src/libs/engine/events/DisconnectNodeEvent.hpp
+++ b/src/libs/engine/events/DisconnectNodeEvent.hpp
@@ -48,7 +48,7 @@ public:
~DisconnectNodeEvent();
void pre_process();
- void execute(SampleCount nframes, FrameTime start, FrameTime end);
+ void execute(ProcessContext& context);
void post_process();
private:
diff --git a/src/libs/engine/events/DisconnectPortEvent.cpp b/src/libs/engine/events/DisconnectPortEvent.cpp
index 6aa5a265..5056877d 100644
--- a/src/libs/engine/events/DisconnectPortEvent.cpp
+++ b/src/libs/engine/events/DisconnectPortEvent.cpp
@@ -121,13 +121,13 @@ DisconnectPortEvent::pre_process()
void
-DisconnectPortEvent::execute(SampleCount nframes, FrameTime start, FrameTime end)
+DisconnectPortEvent::execute(ProcessContext& context)
{
- QueuedEvent::execute(nframes, start, end);
+ QueuedEvent::execute(context);
if (_succeeded) {
for (Raul::List<DisconnectionEvent*>::iterator i = _disconnection_events.begin(); i != _disconnection_events.end(); ++i)
- (*i)->execute(nframes, start, end);
+ (*i)->execute(context);
}
}
diff --git a/src/libs/engine/events/DisconnectPortEvent.hpp b/src/libs/engine/events/DisconnectPortEvent.hpp
index 8fa9e25b..a58dc612 100644
--- a/src/libs/engine/events/DisconnectPortEvent.hpp
+++ b/src/libs/engine/events/DisconnectPortEvent.hpp
@@ -49,7 +49,7 @@ public:
~DisconnectPortEvent();
void pre_process();
- void execute(SampleCount nframes, FrameTime start, FrameTime end);
+ void execute(ProcessContext& context);
void post_process();
private:
diff --git a/src/libs/engine/events/DisconnectionEvent.cpp b/src/libs/engine/events/DisconnectionEvent.cpp
index 67c3b5fb..da91c147 100644
--- a/src/libs/engine/events/DisconnectionEvent.cpp
+++ b/src/libs/engine/events/DisconnectionEvent.cpp
@@ -152,9 +152,9 @@ DisconnectionEvent::pre_process()
void
-DisconnectionEvent::execute(SampleCount nframes, FrameTime start, FrameTime end)
+DisconnectionEvent::execute(ProcessContext& context)
{
- QueuedEvent::execute(nframes, start, end);
+ QueuedEvent::execute(context);
if (_error == NO_ERROR) {
Raul::ListNode<Connection*>* const port_connection
diff --git a/src/libs/engine/events/DisconnectionEvent.hpp b/src/libs/engine/events/DisconnectionEvent.hpp
index 7109c645..cefcb17b 100644
--- a/src/libs/engine/events/DisconnectionEvent.hpp
+++ b/src/libs/engine/events/DisconnectionEvent.hpp
@@ -53,7 +53,7 @@ public:
DisconnectionEvent(Engine& engine, SharedPtr<Responder> responder, SampleCount timestamp, Port* const src_port, Port* const dst_port);
void pre_process();
- void execute(SampleCount nframes, FrameTime start, FrameTime end);
+ void execute(ProcessContext& context);
void post_process();
private:
diff --git a/src/libs/engine/events/EnablePatchEvent.cpp b/src/libs/engine/events/EnablePatchEvent.cpp
index 46cc5cc6..d0d872bb 100644
--- a/src/libs/engine/events/EnablePatchEvent.cpp
+++ b/src/libs/engine/events/EnablePatchEvent.cpp
@@ -53,9 +53,9 @@ EnablePatchEvent::pre_process()
void
-EnablePatchEvent::execute(SampleCount nframes, FrameTime start, FrameTime end)
+EnablePatchEvent::execute(ProcessContext& context)
{
- QueuedEvent::execute(nframes, start, end);
+ QueuedEvent::execute(context);
if (_patch != NULL) {
_patch->enable();
diff --git a/src/libs/engine/events/EnablePatchEvent.hpp b/src/libs/engine/events/EnablePatchEvent.hpp
index 2bacd17d..f0ba5714 100644
--- a/src/libs/engine/events/EnablePatchEvent.hpp
+++ b/src/libs/engine/events/EnablePatchEvent.hpp
@@ -42,7 +42,7 @@ public:
EnablePatchEvent(Engine& engine, SharedPtr<Responder> responder, SampleCount timestamp, const string& patch_path);
void pre_process();
- void execute(SampleCount nframes, FrameTime start, FrameTime end);
+ void execute(ProcessContext& context);
void post_process();
private:
diff --git a/src/libs/engine/events/EnablePortMonitoringEvent.cpp b/src/libs/engine/events/EnablePortMonitoringEvent.cpp
index 1e2d79c0..bad80041 100644
--- a/src/libs/engine/events/EnablePortMonitoringEvent.cpp
+++ b/src/libs/engine/events/EnablePortMonitoringEvent.cpp
@@ -51,9 +51,9 @@ EnablePortMonitoringEvent::pre_process()
void
-EnablePortMonitoringEvent::execute(SampleCount nframes, FrameTime start, FrameTime end)
+EnablePortMonitoringEvent::execute(ProcessContext& context)
{
- QueuedEvent::execute(nframes, start, end);
+ QueuedEvent::execute(context);
#if 0
assert(_time >= start && _time <= end);
diff --git a/src/libs/engine/events/EnablePortMonitoringEvent.hpp b/src/libs/engine/events/EnablePortMonitoringEvent.hpp
index 19e19336..9696e5ca 100644
--- a/src/libs/engine/events/EnablePortMonitoringEvent.hpp
+++ b/src/libs/engine/events/EnablePortMonitoringEvent.hpp
@@ -44,7 +44,7 @@ public:
const std::string& port_path);
void pre_process();
- void execute(SampleCount nframes, FrameTime start, FrameTime end);
+ void execute(ProcessContext& context);
void post_process();
private:
diff --git a/src/libs/engine/events/Makefile.am b/src/libs/engine/events/Makefile.am
index c9e88099..d6b671a3 100644
--- a/src/libs/engine/events/Makefile.am
+++ b/src/libs/engine/events/Makefile.am
@@ -64,10 +64,10 @@ EXTRA_DIST = \
SendPortValueEvent.hpp \
SetMetadataEvent.cpp \
SetMetadataEvent.hpp \
- SetPolyphonyEvent.hpp \
- SetPolyphonyEvent.cpp \
- SetPolyphonicEvent.hpp \
SetPolyphonicEvent.cpp \
+ SetPolyphonicEvent.hpp \
+ SetPolyphonyEvent.cpp \
+ SetPolyphonyEvent.hpp \
SetPortValueEvent.cpp \
SetPortValueEvent.hpp \
SetPortValueQueuedEvent.cpp \
diff --git a/src/libs/engine/events/MidiLearnEvent.cpp b/src/libs/engine/events/MidiLearnEvent.cpp
index d0de3d39..66f0ae2f 100644
--- a/src/libs/engine/events/MidiLearnEvent.cpp
+++ b/src/libs/engine/events/MidiLearnEvent.cpp
@@ -59,9 +59,9 @@ MidiLearnEvent::pre_process()
void
-MidiLearnEvent::execute(SampleCount nframes, FrameTime start, FrameTime end)
+MidiLearnEvent::execute(ProcessContext& context)
{
- QueuedEvent::execute(nframes, start, end);
+ QueuedEvent::execute(context);
// FIXME: this isn't very good at all.
if (_node != NULL && _node->plugin()->type() == Plugin::Internal
diff --git a/src/libs/engine/events/MidiLearnEvent.hpp b/src/libs/engine/events/MidiLearnEvent.hpp
index bbb0c9a5..18cbcb43 100644
--- a/src/libs/engine/events/MidiLearnEvent.hpp
+++ b/src/libs/engine/events/MidiLearnEvent.hpp
@@ -68,7 +68,7 @@ public:
MidiLearnEvent(Engine& engine, SharedPtr<Responder> responder, SampleCount timestamp, const string& node_path);
void pre_process();
- void execute(SampleCount nframes, FrameTime start, FrameTime end);
+ void execute(ProcessContext& context);
void post_process();
private:
diff --git a/src/libs/engine/events/NoteOffEvent.cpp b/src/libs/engine/events/NoteOffEvent.cpp
index 4f683903..f560f250 100644
--- a/src/libs/engine/events/NoteOffEvent.cpp
+++ b/src/libs/engine/events/NoteOffEvent.cpp
@@ -23,6 +23,7 @@
#include "Plugin.hpp"
#include "MidiNoteNode.hpp"
#include "MidiTriggerNode.hpp"
+#include "ProcessContext.hpp"
namespace Ingen {
@@ -49,10 +50,10 @@ NoteOffEvent::NoteOffEvent(Engine& engine, SharedPtr<Responder> responder, Sampl
void
-NoteOffEvent::execute(SampleCount nframes, FrameTime start, FrameTime end)
+NoteOffEvent::execute(ProcessContext& context)
{
- Event::execute(nframes, start, end);
- assert(_time >= start && _time <= end);
+ Event::execute(context);
+ assert(_time >= context.start() && _time <= context.end());
if (_node == NULL && _node_path != "")
_node = _engine.object_store()->find_node(_node_path);
@@ -60,9 +61,9 @@ NoteOffEvent::execute(SampleCount nframes, FrameTime start, FrameTime end)
// FIXME: this isn't very good at all.
if (_node != NULL && _node->plugin()->type() == Plugin::Internal) {
if (_node->plugin()->plug_label() == "note_in")
- ((MidiNoteNode*)_node)->note_off(_note_num, _time, nframes, start, end);
+ ((MidiNoteNode*)_node)->note_off(_note_num, _time, context);
else if (_node->plugin()->plug_label() == "trigger_in")
- ((MidiTriggerNode*)_node)->note_off(_note_num, _time, nframes, start, end);
+ ((MidiTriggerNode*)_node)->note_off(_note_num, _time, context);
}
}
diff --git a/src/libs/engine/events/NoteOffEvent.hpp b/src/libs/engine/events/NoteOffEvent.hpp
index c9301f5b..1b7d118c 100644
--- a/src/libs/engine/events/NoteOffEvent.hpp
+++ b/src/libs/engine/events/NoteOffEvent.hpp
@@ -38,7 +38,7 @@ public:
NoteOffEvent(Engine& engine, SharedPtr<Responder> responder, SampleCount timestamp, Node* node, uchar note_num);
NoteOffEvent(Engine& engine, SharedPtr<Responder> responder, SampleCount timestamp, const string& node_path, uchar note_num);
- void execute(SampleCount nframes, FrameTime start, FrameTime end);
+ void execute(ProcessContext& context);
void post_process();
private:
diff --git a/src/libs/engine/events/NoteOnEvent.cpp b/src/libs/engine/events/NoteOnEvent.cpp
index 22e85972..316e293a 100644
--- a/src/libs/engine/events/NoteOnEvent.cpp
+++ b/src/libs/engine/events/NoteOnEvent.cpp
@@ -23,6 +23,7 @@
#include "MidiNoteNode.hpp"
#include "MidiTriggerNode.hpp"
#include "Plugin.hpp"
+#include "ProcessContext.hpp"
namespace Ingen {
@@ -57,10 +58,10 @@ NoteOnEvent::NoteOnEvent(Engine& engine, SharedPtr<Responder> responder, SampleC
void
-NoteOnEvent::execute(SampleCount nframes, FrameTime start, FrameTime end)
+NoteOnEvent::execute(ProcessContext& context)
{
- Event::execute(nframes, start, end);
- assert(_time >= start && _time <= end);
+ Event::execute(context);
+ assert(_time >= context.start() && _time <= context.end());
// Lookup if neccessary
if (_is_osc_triggered)
@@ -69,9 +70,9 @@ NoteOnEvent::execute(SampleCount nframes, FrameTime start, FrameTime end)
// FIXME: this isn't very good at all.
if (_node != NULL && _node->plugin()->type() == Plugin::Internal) {
if (_node->plugin()->plug_label() == "note_in")
- ((MidiNoteNode*)_node)->note_on(_note_num, _velocity, _time, nframes, start, end);
+ ((MidiNoteNode*)_node)->note_on(_note_num, _velocity, _time, context);
else if (_node->plugin()->plug_label() == "trigger_in")
- ((MidiTriggerNode*)_node)->note_on(_note_num, _velocity, _time, nframes, start, end);
+ ((MidiTriggerNode*)_node)->note_on(_note_num, _velocity, _time, context);
}
}
diff --git a/src/libs/engine/events/NoteOnEvent.hpp b/src/libs/engine/events/NoteOnEvent.hpp
index 175623bf..a629023f 100644
--- a/src/libs/engine/events/NoteOnEvent.hpp
+++ b/src/libs/engine/events/NoteOnEvent.hpp
@@ -38,7 +38,7 @@ public:
NoteOnEvent(Engine& engine, SharedPtr<Responder> responder, SampleCount timestamp, Node* patch, uchar note_num, uchar velocity);
NoteOnEvent(Engine& engine, SharedPtr<Responder> responder, SampleCount timestamp, const string& node_path, uchar note_num, uchar velocity);
- void execute(SampleCount nframes, FrameTime start, FrameTime end);
+ void execute(ProcessContext& context);
void post_process();
private:
diff --git a/src/libs/engine/events/RenameEvent.cpp b/src/libs/engine/events/RenameEvent.cpp
index a731314b..1ec3b0d1 100644
--- a/src/libs/engine/events/RenameEvent.cpp
+++ b/src/libs/engine/events/RenameEvent.cpp
@@ -93,10 +93,10 @@ RenameEvent::pre_process()
void
-RenameEvent::execute(SampleCount nframes, FrameTime start, FrameTime end)
+RenameEvent::execute(ProcessContext& context)
{
//cout << "Executing rename event...";
- QueuedEvent::execute(nframes, start, end);
+ QueuedEvent::execute(context);
}
diff --git a/src/libs/engine/events/RenameEvent.hpp b/src/libs/engine/events/RenameEvent.hpp
index da7d642a..ec3a0cec 100644
--- a/src/libs/engine/events/RenameEvent.hpp
+++ b/src/libs/engine/events/RenameEvent.hpp
@@ -49,7 +49,7 @@ public:
~RenameEvent();
void pre_process();
- void execute(SampleCount nframes, FrameTime start, FrameTime end);
+ void execute(ProcessContext& context);
void post_process();
private:
diff --git a/src/libs/engine/events/RequestObjectEvent.cpp b/src/libs/engine/events/RequestObjectEvent.cpp
index 62651e63..4c875e45 100644
--- a/src/libs/engine/events/RequestObjectEvent.cpp
+++ b/src/libs/engine/events/RequestObjectEvent.cpp
@@ -26,6 +26,7 @@
#include "Node.hpp"
#include "Port.hpp"
#include "ObjectSender.hpp"
+#include "ProcessContext.hpp"
using std::string;
@@ -50,10 +51,10 @@ RequestObjectEvent::pre_process()
void
-RequestObjectEvent::execute(SampleCount nframes, FrameTime start, FrameTime end)
+RequestObjectEvent::execute(ProcessContext& context)
{
- QueuedEvent::execute(nframes, start, end);
- assert(_time >= start && _time <= end);
+ QueuedEvent::execute(context);
+ assert(_time >= context.start() && _time <= context.end());
}
diff --git a/src/libs/engine/events/RequestObjectEvent.hpp b/src/libs/engine/events/RequestObjectEvent.hpp
index 1997cabe..263ea627 100644
--- a/src/libs/engine/events/RequestObjectEvent.hpp
+++ b/src/libs/engine/events/RequestObjectEvent.hpp
@@ -41,7 +41,7 @@ public:
RequestObjectEvent(Engine& engine, SharedPtr<Responder> responder, SampleCount timestamp, const string& port_path);
void pre_process();
- void execute(SampleCount nframes, FrameTime start, FrameTime end);
+ void execute(ProcessContext& context);
void post_process();
private:
diff --git a/src/libs/engine/events/RequestPluginEvent.cpp b/src/libs/engine/events/RequestPluginEvent.cpp
index 693a021a..af7a4754 100644
--- a/src/libs/engine/events/RequestPluginEvent.cpp
+++ b/src/libs/engine/events/RequestPluginEvent.cpp
@@ -25,6 +25,7 @@
#include "ClientBroadcaster.hpp"
#include "NodeFactory.hpp"
#include "Plugin.hpp"
+#include "ProcessContext.hpp"
using std::string;
@@ -49,10 +50,10 @@ RequestPluginEvent::pre_process()
void
-RequestPluginEvent::execute(SampleCount nframes, FrameTime start, FrameTime end)
+RequestPluginEvent::execute(ProcessContext& context)
{
- QueuedEvent::execute(nframes, start, end);
- assert(_time >= start && _time <= end);
+ QueuedEvent::execute(context);
+ assert(_time >= context.start() && _time <= context.end());
}
diff --git a/src/libs/engine/events/RequestPluginEvent.hpp b/src/libs/engine/events/RequestPluginEvent.hpp
index 978aa5ff..a4c6cd09 100644
--- a/src/libs/engine/events/RequestPluginEvent.hpp
+++ b/src/libs/engine/events/RequestPluginEvent.hpp
@@ -41,7 +41,7 @@ public:
RequestPluginEvent(Engine& engine, SharedPtr<Responder> responder, SampleCount timestamp, const string& uri);
void pre_process();
- void execute(SampleCount nframes, FrameTime start, FrameTime end);
+ void execute(ProcessContext& context);
void post_process();
private:
diff --git a/src/libs/engine/events/RequestPortValueEvent.cpp b/src/libs/engine/events/RequestPortValueEvent.cpp
index 992c1615..224c3045 100644
--- a/src/libs/engine/events/RequestPortValueEvent.cpp
+++ b/src/libs/engine/events/RequestPortValueEvent.cpp
@@ -24,6 +24,7 @@
#include "ObjectStore.hpp"
#include "ClientBroadcaster.hpp"
#include "AudioBuffer.hpp"
+#include "ProcessContext.hpp"
using std::string;
@@ -49,10 +50,10 @@ RequestPortValueEvent::pre_process()
void
-RequestPortValueEvent::execute(SampleCount nframes, FrameTime start, FrameTime end)
+RequestPortValueEvent::execute(ProcessContext& context)
{
- QueuedEvent::execute(nframes, start, end);
- assert(_time >= start && _time <= end);
+ QueuedEvent::execute(context);
+ assert(_time >= context.start() && _time <= context.end());
if (_port != NULL && _port->type() == DataType::FLOAT)
_value = ((AudioBuffer*)_port->buffer(0))->value_at(0/*_time - start*/);
diff --git a/src/libs/engine/events/RequestPortValueEvent.hpp b/src/libs/engine/events/RequestPortValueEvent.hpp
index f7170153..d3bccfdc 100644
--- a/src/libs/engine/events/RequestPortValueEvent.hpp
+++ b/src/libs/engine/events/RequestPortValueEvent.hpp
@@ -41,7 +41,7 @@ public:
RequestPortValueEvent(Engine& engine, SharedPtr<Responder> responder, SampleCount timestamp, const string& port_path);
void pre_process();
- void execute(SampleCount nframes, FrameTime start, FrameTime end);
+ void execute(ProcessContext& context);
void post_process();
private:
diff --git a/src/libs/engine/events/SendPortValueEvent.cpp b/src/libs/engine/events/SendPortValueEvent.cpp
index d537011d..91bbb64e 100644
--- a/src/libs/engine/events/SendPortValueEvent.cpp
+++ b/src/libs/engine/events/SendPortValueEvent.cpp
@@ -30,28 +30,16 @@ using namespace std;
namespace Ingen {
-
-SendPortValueEvent(Engine& engine,
- SampleCount timestamp,
- Port* port,
- bool omni,
- uint32_t voice_num,
- float value)
- : _port(port)
- , _omni(omni)
- , _voice_num(voice_num)
- , _value(value)
-{
-}
-
+class Engine;
void
SendPortValueEvent::post_process()
{
+ // FIXME...
+
if (_omni) {
_engine.broadcaster()->send_control_change(_port->path(), _value);
} else {
- cerr << "NON-OMNI CONTROL CHANGE WHAT?" << endl;
_engine.broadcaster()->send_control_change(_port->path(), _value);
}
}
diff --git a/src/libs/engine/events/SendPortValueEvent.hpp b/src/libs/engine/events/SendPortValueEvent.hpp
index d63d43b0..e80682d0 100644
--- a/src/libs/engine/events/SendPortValueEvent.hpp
+++ b/src/libs/engine/events/SendPortValueEvent.hpp
@@ -43,15 +43,14 @@ class Port;
class SendPortValueEvent : public Event
{
public:
- SendPortValueEvent() {}
-
inline SendPortValueEvent(Engine& engine,
SampleCount timestamp,
Port* port,
bool omni,
uint32_t voice_num,
Sample value)
- : _port(port)
+ : Event(engine, SharedPtr<Responder>(), timestamp)
+ , _port(port)
, _omni(omni)
, _voice_num(voice_num)
, _value(value)
diff --git a/src/libs/engine/events/SetMetadataEvent.cpp b/src/libs/engine/events/SetMetadataEvent.cpp
index 8e848aa6..8e9163f0 100644
--- a/src/libs/engine/events/SetMetadataEvent.cpp
+++ b/src/libs/engine/events/SetMetadataEvent.cpp
@@ -54,9 +54,9 @@ SetMetadataEvent::pre_process()
void
-SetMetadataEvent::execute(SampleCount nframes, FrameTime start, FrameTime end)
+SetMetadataEvent::execute(ProcessContext& context)
{
- QueuedEvent::execute(nframes, start, end);
+ QueuedEvent::execute(context);
// Do nothing
}
diff --git a/src/libs/engine/events/SetMetadataEvent.hpp b/src/libs/engine/events/SetMetadataEvent.hpp
index 51af36f7..363a63eb 100644
--- a/src/libs/engine/events/SetMetadataEvent.hpp
+++ b/src/libs/engine/events/SetMetadataEvent.hpp
@@ -39,7 +39,7 @@ public:
SetMetadataEvent(Engine& engine, SharedPtr<Responder> responder, SampleCount timestamp, const string& path, const string& key, const Raul::Atom& value);
void pre_process();
- void execute(SampleCount nframes, FrameTime start, FrameTime end);
+ void execute(ProcessContext& context);
void post_process();
private:
diff --git a/src/libs/engine/events/SetPolyphonicEvent.cpp b/src/libs/engine/events/SetPolyphonicEvent.cpp
index 17313f96..bce9a1b2 100644
--- a/src/libs/engine/events/SetPolyphonicEvent.cpp
+++ b/src/libs/engine/events/SetPolyphonicEvent.cpp
@@ -50,9 +50,9 @@ SetPolyphonicEvent::pre_process()
void
-SetPolyphonicEvent::execute(SampleCount nframes, FrameTime start, FrameTime end)
+SetPolyphonicEvent::execute(ProcessContext& context)
{
- QueuedEvent::execute(nframes, start, end);
+ QueuedEvent::execute(context);
if (_object)
_object->set_polyphonic(*_engine.maid(), _poly);
diff --git a/src/libs/engine/events/SetPolyphonicEvent.hpp b/src/libs/engine/events/SetPolyphonicEvent.hpp
index 3e3aa81e..4d0084c9 100644
--- a/src/libs/engine/events/SetPolyphonicEvent.hpp
+++ b/src/libs/engine/events/SetPolyphonicEvent.hpp
@@ -39,7 +39,7 @@ public:
SetPolyphonicEvent(Engine& engine, SharedPtr<Responder> responder, FrameTime time, QueuedEventSource* source, const string& path, bool poly);
void pre_process();
- void execute(SampleCount nframes, FrameTime start, FrameTime end);
+ void execute(ProcessContext& context);
void post_process();
private:
diff --git a/src/libs/engine/events/SetPolyphonyEvent.cpp b/src/libs/engine/events/SetPolyphonyEvent.cpp
index bdf4e1a1..7a261b5e 100644
--- a/src/libs/engine/events/SetPolyphonyEvent.cpp
+++ b/src/libs/engine/events/SetPolyphonyEvent.cpp
@@ -52,9 +52,9 @@ SetPolyphonyEvent::pre_process()
void
-SetPolyphonyEvent::execute(SampleCount nframes, FrameTime start, FrameTime end)
+SetPolyphonyEvent::execute(ProcessContext& context)
{
- QueuedEvent::execute(nframes, start, end);
+ QueuedEvent::execute(context);
if (_patch)
_patch->apply_internal_poly(*_engine.maid(), _poly);
diff --git a/src/libs/engine/events/SetPolyphonyEvent.hpp b/src/libs/engine/events/SetPolyphonyEvent.hpp
index 923c8f60..a2ac1862 100644
--- a/src/libs/engine/events/SetPolyphonyEvent.hpp
+++ b/src/libs/engine/events/SetPolyphonyEvent.hpp
@@ -39,7 +39,7 @@ public:
SetPolyphonyEvent(Engine& engine, SharedPtr<Responder> responder, FrameTime time, QueuedEventSource* source, const string& patch_path, uint32_t poly);
void pre_process();
- void execute(SampleCount nframes, FrameTime start, FrameTime end);
+ void execute(ProcessContext& context);
void post_process();
private:
diff --git a/src/libs/engine/events/SetPortValueEvent.cpp b/src/libs/engine/events/SetPortValueEvent.cpp
index c1f3c890..b0fc273e 100644
--- a/src/libs/engine/events/SetPortValueEvent.cpp
+++ b/src/libs/engine/events/SetPortValueEvent.cpp
@@ -25,6 +25,7 @@
#include "ObjectStore.hpp"
#include "AudioBuffer.hpp"
#include "MidiBuffer.hpp"
+#include "ProcessContext.hpp"
using namespace std;
@@ -79,10 +80,10 @@ SetPortValueEvent::~SetPortValueEvent()
void
-SetPortValueEvent::execute(SampleCount nframes, FrameTime start, FrameTime end)
+SetPortValueEvent::execute(ProcessContext& context)
{
- Event::execute(nframes, start, end);
- assert(_time >= start && _time <= end);
+ Event::execute(context);
+ assert(_time >= context.start() && _time <= context.end());
if (_port == NULL)
_port = _engine.object_store()->find_port(_port_path);
@@ -95,7 +96,7 @@ SetPortValueEvent::execute(SampleCount nframes, FrameTime start, FrameTime end)
Buffer* const buf = _port->buffer(0);
AudioBuffer* const abuf = dynamic_cast<AudioBuffer*>(buf);
if (abuf) {
- const uint32_t offset = (buf->size() == 1) ? 0 : _time - start;
+ const uint32_t offset = (buf->size() == 1) ? 0 : _time - context.start();
if (_omni)
for (uint32_t i=0; i < _port->poly(); ++i)
@@ -108,7 +109,7 @@ SetPortValueEvent::execute(SampleCount nframes, FrameTime start, FrameTime end)
MidiBuffer* const mbuf = dynamic_cast<MidiBuffer*>(buf);
if (mbuf) {
- const double stamp = std::max((double)(_time - start), mbuf->latest_stamp());
+ const double stamp = std::max((double)(_time - context.start()), mbuf->latest_stamp());
mbuf->append(stamp, _data_size, (const unsigned char*)_data);
}
}
diff --git a/src/libs/engine/events/SetPortValueEvent.hpp b/src/libs/engine/events/SetPortValueEvent.hpp
index 4b6e8d92..0761ed39 100644
--- a/src/libs/engine/events/SetPortValueEvent.hpp
+++ b/src/libs/engine/events/SetPortValueEvent.hpp
@@ -52,7 +52,7 @@ public:
~SetPortValueEvent();
- void execute(SampleCount nframes, FrameTime start, FrameTime end);
+ void execute(ProcessContext& context);
void post_process();
private:
diff --git a/src/libs/engine/events/SetPortValueQueuedEvent.cpp b/src/libs/engine/events/SetPortValueQueuedEvent.cpp
index d0bfff4a..00de1cce 100644
--- a/src/libs/engine/events/SetPortValueQueuedEvent.cpp
+++ b/src/libs/engine/events/SetPortValueQueuedEvent.cpp
@@ -26,6 +26,7 @@
#include "ObjectStore.hpp"
#include "AudioBuffer.hpp"
#include "MidiBuffer.hpp"
+#include "ProcessContext.hpp"
namespace Ingen {
@@ -88,10 +89,10 @@ SetPortValueQueuedEvent::pre_process()
void
-SetPortValueQueuedEvent::execute(SampleCount nframes, FrameTime start, FrameTime end)
+SetPortValueQueuedEvent::execute(ProcessContext& context)
{
- QueuedEvent::execute(nframes, start, end);
- assert(_time >= start && _time <= end);
+ QueuedEvent::execute(context);
+ assert(_time >= context.start() && _time <= context.end());
if (_error == NO_ERROR) {
assert(_port);
@@ -99,7 +100,7 @@ SetPortValueQueuedEvent::execute(SampleCount nframes, FrameTime start, FrameTime
Buffer* const buf = _port->buffer(0);
AudioBuffer* const abuf = dynamic_cast<AudioBuffer*>(buf);
if (abuf) {
- const uint32_t offset = (buf->size() == 1) ? 0 : _time - start;
+ const uint32_t offset = (buf->size() == 1) ? 0 : _time - context.start();
if (_omni)
for (uint32_t i=0; i < _port->poly(); ++i)
@@ -112,7 +113,7 @@ SetPortValueQueuedEvent::execute(SampleCount nframes, FrameTime start, FrameTime
MidiBuffer* const mbuf = dynamic_cast<MidiBuffer*>(buf);
if (mbuf) {
- const double stamp = std::max((double)(_time - start), mbuf->latest_stamp());
+ const double stamp = std::max((double)(_time - context.start()), mbuf->latest_stamp());
mbuf->append(stamp, _data_size, (const unsigned char*)_data);
}
}
diff --git a/src/libs/engine/events/SetPortValueQueuedEvent.hpp b/src/libs/engine/events/SetPortValueQueuedEvent.hpp
index b64cf903..c6a3c0ee 100644
--- a/src/libs/engine/events/SetPortValueQueuedEvent.hpp
+++ b/src/libs/engine/events/SetPortValueQueuedEvent.hpp
@@ -51,7 +51,7 @@ public:
const void* data);
void pre_process();
- void execute(SampleCount nframes, FrameTime start, FrameTime end);
+ void execute(ProcessContext& context);
void post_process();
private: