summaryrefslogtreecommitdiffstats
path: root/src/libs/engine
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs/engine')
-rw-r--r--src/libs/engine/Event.h7
-rw-r--r--src/libs/engine/QueuedEngineInterface.cpp5
-rw-r--r--src/libs/engine/events/AllNotesOffEvent.cpp4
-rw-r--r--src/libs/engine/events/ClearPatchEvent.cpp4
-rw-r--r--src/libs/engine/events/ConnectionEvent.cpp9
-rw-r--r--src/libs/engine/events/DSSIConfigureEvent.cpp1
-rw-r--r--src/libs/engine/events/DSSIControlEvent.cpp2
-rw-r--r--src/libs/engine/events/DSSIProgramEvent.cpp2
-rw-r--r--src/libs/engine/events/DSSIUpdateEvent.cpp4
-rw-r--r--src/libs/engine/events/DisablePatchEvent.cpp4
-rw-r--r--src/libs/engine/events/DisconnectNodeEvent.cpp4
-rw-r--r--src/libs/engine/events/DisconnectPortEvent.cpp4
-rw-r--r--src/libs/engine/events/DisconnectionEvent.cpp4
-rw-r--r--src/libs/engine/events/EnablePatchEvent.cpp4
-rw-r--r--src/libs/engine/events/NoteOffEvent.cpp1
-rw-r--r--src/libs/engine/events/NoteOnEvent.cpp1
-rw-r--r--src/libs/engine/events/RequestPortValueEvent.cpp3
-rw-r--r--src/libs/engine/events/SetMetadataEvent.cpp3
-rw-r--r--src/libs/engine/events/SetPortValueEvent.cpp1
-rw-r--r--src/libs/engine/events/SetPortValueQueuedEvent.cpp1
20 files changed, 46 insertions, 22 deletions
diff --git a/src/libs/engine/Event.h b/src/libs/engine/Event.h
index 3ea72555..dc6f8aaa 100644
--- a/src/libs/engine/Event.h
+++ b/src/libs/engine/Event.h
@@ -48,7 +48,12 @@ public:
virtual void execute(SampleCount nframes, FrameTime start, FrameTime end)
{
assert(!_executed);
- assert(_time >= start && _time <= end);
+ assert(_time <= end);
+
+ // Missed the event, jitter, damnit.
+ if (_time < start)
+ _time = start;
+
_executed = true;
}
diff --git a/src/libs/engine/QueuedEngineInterface.cpp b/src/libs/engine/QueuedEngineInterface.cpp
index 919d3054..d56b8de1 100644
--- a/src/libs/engine/QueuedEngineInterface.cpp
+++ b/src/libs/engine/QueuedEngineInterface.cpp
@@ -34,9 +34,12 @@ QueuedEngineInterface::QueuedEngineInterface(CountedPtr<Engine> engine, size_t q
SampleCount
QueuedEngineInterface::now() const
{
- return _engine->audio_driver()->frame_time();
+ // Exactly one cycle latency (some could run ASAP if we get lucky, but not always, and a slight
+ // constant latency is far better than jittery lower (average) latency
+ return _engine->audio_driver()->frame_time() + _engine->audio_driver()->buffer_size();
}
+
/** Set the Responder to send responses to commands with, once the commands
* are preprocessed and ready to be executed (or not).
*
diff --git a/src/libs/engine/events/AllNotesOffEvent.cpp b/src/libs/engine/events/AllNotesOffEvent.cpp
index b26f1315..eacebda1 100644
--- a/src/libs/engine/events/AllNotesOffEvent.cpp
+++ b/src/libs/engine/events/AllNotesOffEvent.cpp
@@ -43,7 +43,9 @@ AllNotesOffEvent::AllNotesOffEvent(Engine& engine, CountedPtr<Responder> respond
void
AllNotesOffEvent::execute(SampleCount nframes, FrameTime start, FrameTime end)
-{
+{
+ Event::execute(nframes, start, end);
+
if (m_patch == NULL && m_patch_path != "")
m_patch = _engine.object_store()->find_patch(m_patch_path);
diff --git a/src/libs/engine/events/ClearPatchEvent.cpp b/src/libs/engine/events/ClearPatchEvent.cpp
index 3518dc03..b8f31243 100644
--- a/src/libs/engine/events/ClearPatchEvent.cpp
+++ b/src/libs/engine/events/ClearPatchEvent.cpp
@@ -59,6 +59,8 @@ ClearPatchEvent::pre_process()
void
ClearPatchEvent::execute(SampleCount nframes, FrameTime start, FrameTime end)
{
+ QueuedEvent::execute(nframes, start, end);
+
if (m_patch != NULL) {
m_patch->disable();
@@ -70,8 +72,6 @@ ClearPatchEvent::execute(SampleCount nframes, FrameTime start, FrameTime end)
m_patch->process_order(NULL);
}
}
-
- QueuedEvent::execute(nframes, start, end);
}
diff --git a/src/libs/engine/events/ConnectionEvent.cpp b/src/libs/engine/events/ConnectionEvent.cpp
index 7c97de03..17d3c9cb 100644
--- a/src/libs/engine/events/ConnectionEvent.cpp
+++ b/src/libs/engine/events/ConnectionEvent.cpp
@@ -115,8 +115,10 @@ ConnectionEvent::pre_process()
return;
}
+ assert(m_typed_event);
m_typed_event->pre_process();
-
+ assert(m_typed_event->is_prepared());
+
QueuedEvent::pre_process();
}
@@ -223,6 +225,9 @@ TypedConnectionEvent<T>::pre_process()
if (m_patch->enabled())
m_process_order = m_patch->build_process_order();
+
+ m_succeeded = true;
+ QueuedEvent::pre_process();
}
@@ -230,6 +235,8 @@ template <typename T>
void
TypedConnectionEvent<T>::execute(SampleCount nframes, FrameTime start, FrameTime end)
{
+ QueuedEvent::execute(nframes, start, end);
+
if (m_succeeded) {
// These must be inserted here, since they're actually used by the audio thread
m_dst_port->add_connection(m_port_listnode);
diff --git a/src/libs/engine/events/DSSIConfigureEvent.cpp b/src/libs/engine/events/DSSIConfigureEvent.cpp
index fb006444..fb9dc727 100644
--- a/src/libs/engine/events/DSSIConfigureEvent.cpp
+++ b/src/libs/engine/events/DSSIConfigureEvent.cpp
@@ -51,6 +51,7 @@ DSSIConfigureEvent::pre_process()
void
DSSIConfigureEvent::execute(SampleCount nframes, FrameTime start, FrameTime end)
{
+ QueuedEvent::execute(nframes, start, end);
// Nothing.
}
diff --git a/src/libs/engine/events/DSSIControlEvent.cpp b/src/libs/engine/events/DSSIControlEvent.cpp
index 9ae4274b..4ab3cd6c 100644
--- a/src/libs/engine/events/DSSIControlEvent.cpp
+++ b/src/libs/engine/events/DSSIControlEvent.cpp
@@ -50,6 +50,8 @@ DSSIControlEvent::pre_process()
void
DSSIControlEvent::execute(SampleCount nframes, FrameTime start, FrameTime end)
{
+ QueuedEvent::execute(nframes, start, end);
+
if (m_node != NULL)
m_node->set_control(m_port_num, m_val);
}
diff --git a/src/libs/engine/events/DSSIProgramEvent.cpp b/src/libs/engine/events/DSSIProgramEvent.cpp
index d602b57c..c6a9e0b7 100644
--- a/src/libs/engine/events/DSSIProgramEvent.cpp
+++ b/src/libs/engine/events/DSSIProgramEvent.cpp
@@ -53,6 +53,8 @@ DSSIProgramEvent::pre_process()
void
DSSIProgramEvent::execute(SampleCount nframes, FrameTime start, FrameTime end)
{
+ QueuedEvent::execute(nframes, start, end);
+
if (m_node != NULL)
m_node->program(m_bank, m_program);
}
diff --git a/src/libs/engine/events/DSSIUpdateEvent.cpp b/src/libs/engine/events/DSSIUpdateEvent.cpp
index d2953a9b..edfe1394 100644
--- a/src/libs/engine/events/DSSIUpdateEvent.cpp
+++ b/src/libs/engine/events/DSSIUpdateEvent.cpp
@@ -56,11 +56,11 @@ DSSIUpdateEvent::pre_process()
void
DSSIUpdateEvent::execute(SampleCount nframes, FrameTime start, FrameTime end)
{
+ QueuedEvent::execute(nframes, start, end);
+
if (m_node != NULL) {
m_node->set_ui_url(m_url);
}
-
- QueuedEvent::execute(nframes, start, end);
}
diff --git a/src/libs/engine/events/DisablePatchEvent.cpp b/src/libs/engine/events/DisablePatchEvent.cpp
index 064dd9fd..8e6d64a1 100644
--- a/src/libs/engine/events/DisablePatchEvent.cpp
+++ b/src/libs/engine/events/DisablePatchEvent.cpp
@@ -46,10 +46,10 @@ DisablePatchEvent::pre_process()
void
DisablePatchEvent::execute(SampleCount nframes, FrameTime start, FrameTime end)
{
+ QueuedEvent::execute(nframes, start, end);
+
if (m_patch != NULL)
m_patch->disable();
-
- QueuedEvent::execute(nframes, start, end);
}
diff --git a/src/libs/engine/events/DisconnectNodeEvent.cpp b/src/libs/engine/events/DisconnectNodeEvent.cpp
index df85e1db..5be1167e 100644
--- a/src/libs/engine/events/DisconnectNodeEvent.cpp
+++ b/src/libs/engine/events/DisconnectNodeEvent.cpp
@@ -114,12 +114,12 @@ DisconnectNodeEvent::pre_process()
void
DisconnectNodeEvent::execute(SampleCount nframes, FrameTime start, FrameTime end)
{
+ QueuedEvent::execute(nframes, start, end);
+
if (m_succeeded) {
for (List<DisconnectionEvent*>::iterator i = m_disconnection_events.begin(); i != m_disconnection_events.end(); ++i)
(*i)->execute(nframes, start, end);
}
-
- QueuedEvent::execute(nframes, start, end);
}
diff --git a/src/libs/engine/events/DisconnectPortEvent.cpp b/src/libs/engine/events/DisconnectPortEvent.cpp
index 41ceff8b..f6dfa40c 100644
--- a/src/libs/engine/events/DisconnectPortEvent.cpp
+++ b/src/libs/engine/events/DisconnectPortEvent.cpp
@@ -119,12 +119,12 @@ DisconnectPortEvent::pre_process()
void
DisconnectPortEvent::execute(SampleCount nframes, FrameTime start, FrameTime end)
{
+ QueuedEvent::execute(nframes, start, end);
+
if (m_succeeded) {
for (List<DisconnectionEvent*>::iterator i = m_disconnection_events.begin(); i != m_disconnection_events.end(); ++i)
(*i)->execute(nframes, start, end);
}
-
- QueuedEvent::execute(nframes, start, end);
}
diff --git a/src/libs/engine/events/DisconnectionEvent.cpp b/src/libs/engine/events/DisconnectionEvent.cpp
index 7e050369..a83e6e3f 100644
--- a/src/libs/engine/events/DisconnectionEvent.cpp
+++ b/src/libs/engine/events/DisconnectionEvent.cpp
@@ -125,6 +125,7 @@ DisconnectionEvent::pre_process()
assert(m_typed_event);
m_typed_event->pre_process();
+ assert(m_typed_event->is_prepared());
QueuedEvent::pre_process();
}
@@ -235,6 +236,8 @@ template <typename T>
void
TypedDisconnectionEvent<T>::execute(SampleCount nframes, FrameTime start, FrameTime end)
{
+ QueuedEvent::execute(nframes, start, end);
+
if (m_succeeded) {
ListNode<TypedConnection<T>*>* const port_connection
@@ -259,7 +262,6 @@ TypedDisconnectionEvent<T>::execute(SampleCount nframes, FrameTime start, FrameT
m_succeeded = false; // Ports weren't connected
}
}
- QueuedEvent::execute(nframes, start, end);
}
diff --git a/src/libs/engine/events/EnablePatchEvent.cpp b/src/libs/engine/events/EnablePatchEvent.cpp
index 01144013..3d238372 100644
--- a/src/libs/engine/events/EnablePatchEvent.cpp
+++ b/src/libs/engine/events/EnablePatchEvent.cpp
@@ -54,14 +54,14 @@ EnablePatchEvent::pre_process()
void
EnablePatchEvent::execute(SampleCount nframes, FrameTime start, FrameTime end)
{
+ QueuedEvent::execute(nframes, start, end);
+
if (m_patch != NULL) {
m_patch->enable();
if (m_patch->process_order() == NULL)
m_patch->process_order(m_process_order);
}
-
- QueuedEvent::execute(nframes, start, end);
}
diff --git a/src/libs/engine/events/NoteOffEvent.cpp b/src/libs/engine/events/NoteOffEvent.cpp
index 8145c208..26f3a324 100644
--- a/src/libs/engine/events/NoteOffEvent.cpp
+++ b/src/libs/engine/events/NoteOffEvent.cpp
@@ -49,6 +49,7 @@ NoteOffEvent::NoteOffEvent(Engine& engine, CountedPtr<Responder> responder, Samp
void
NoteOffEvent::execute(SampleCount nframes, FrameTime start, FrameTime end)
{
+ Event::execute(nframes, start, end);
assert(_time >= start && _time <= end);
if (m_node == NULL && m_node_path != "")
diff --git a/src/libs/engine/events/NoteOnEvent.cpp b/src/libs/engine/events/NoteOnEvent.cpp
index 7a98c58d..540bc618 100644
--- a/src/libs/engine/events/NoteOnEvent.cpp
+++ b/src/libs/engine/events/NoteOnEvent.cpp
@@ -58,6 +58,7 @@ NoteOnEvent::NoteOnEvent(Engine& engine, CountedPtr<Responder> responder, Sample
void
NoteOnEvent::execute(SampleCount nframes, FrameTime start, FrameTime end)
{
+ Event::execute(nframes, start, end);
assert(_time >= start && _time <= end);
// Lookup if neccessary
diff --git a/src/libs/engine/events/RequestPortValueEvent.cpp b/src/libs/engine/events/RequestPortValueEvent.cpp
index 12dea975..80f55dcd 100644
--- a/src/libs/engine/events/RequestPortValueEvent.cpp
+++ b/src/libs/engine/events/RequestPortValueEvent.cpp
@@ -51,14 +51,13 @@ RequestPortValueEvent::pre_process()
void
RequestPortValueEvent::execute(SampleCount nframes, FrameTime start, FrameTime end)
{
+ QueuedEvent::execute(nframes, start, end);
assert(_time >= start && _time <= end);
if (m_port != NULL && m_port->type() == DataType::FLOAT)
m_value = ((TypedPort<Sample>*)m_port)->buffer(0)->value_at(_time - start);
else
m_port = NULL; // triggers error response
-
- QueuedEvent::execute(nframes, start, end);
}
diff --git a/src/libs/engine/events/SetMetadataEvent.cpp b/src/libs/engine/events/SetMetadataEvent.cpp
index 428437e3..db8e0118 100644
--- a/src/libs/engine/events/SetMetadataEvent.cpp
+++ b/src/libs/engine/events/SetMetadataEvent.cpp
@@ -55,9 +55,8 @@ SetMetadataEvent::pre_process()
void
SetMetadataEvent::execute(SampleCount nframes, FrameTime start, FrameTime end)
{
- // Do nothing
-
QueuedEvent::execute(nframes, start, end);
+ // Do nothing
}
diff --git a/src/libs/engine/events/SetPortValueEvent.cpp b/src/libs/engine/events/SetPortValueEvent.cpp
index efe53b37..41395feb 100644
--- a/src/libs/engine/events/SetPortValueEvent.cpp
+++ b/src/libs/engine/events/SetPortValueEvent.cpp
@@ -52,6 +52,7 @@ SetPortValueEvent::SetPortValueEvent(Engine& engine, CountedPtr<Responder> respo
void
SetPortValueEvent::execute(SampleCount nframes, FrameTime start, FrameTime end)
{
+ Event::execute(nframes, start, end);
assert(_time >= start && _time <= end);
if (m_port == NULL)
diff --git a/src/libs/engine/events/SetPortValueQueuedEvent.cpp b/src/libs/engine/events/SetPortValueQueuedEvent.cpp
index dcbec0be..21ccf214 100644
--- a/src/libs/engine/events/SetPortValueQueuedEvent.cpp
+++ b/src/libs/engine/events/SetPortValueQueuedEvent.cpp
@@ -70,7 +70,6 @@ void
SetPortValueQueuedEvent::execute(SampleCount nframes, FrameTime start, FrameTime end)
{
QueuedEvent::execute(nframes, start, end);
-
assert(_time >= start && _time <= end);
if (m_error == NO_ERROR) {