summaryrefslogtreecommitdiffstats
path: root/src/libs/engine
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs/engine')
-rw-r--r--src/libs/engine/MidiBuffer.cpp5
-rw-r--r--src/libs/engine/MidiNoteNode.cpp6
-rw-r--r--src/libs/engine/OSCEngineReceiver.cpp110
-rw-r--r--src/libs/engine/OSCEngineReceiver.hpp2
-rw-r--r--src/libs/engine/QueuedEngineInterface.cpp4
-rw-r--r--src/libs/engine/QueuedEngineInterface.hpp4
-rw-r--r--src/libs/engine/events/SetPortValueEvent.cpp4
-rw-r--r--src/libs/engine/events/SetPortValueQueuedEvent.cpp29
8 files changed, 112 insertions, 52 deletions
diff --git a/src/libs/engine/MidiBuffer.cpp b/src/libs/engine/MidiBuffer.cpp
index 0e10a44e..59da7646 100644
--- a/src/libs/engine/MidiBuffer.cpp
+++ b/src/libs/engine/MidiBuffer.cpp
@@ -178,6 +178,11 @@ MidiBuffer::append(double timestamp,
uint32_t size,
const unsigned char* data)
{
+ /*cerr << "Append midi " << size << " bytes @ " << timestamp << ":" << endl;
+ for (uint32_t i=0; i < size; ++i) {
+ fprintf(stderr, "( %X )", *((uint8_t*)data + i));
+ }*/
+
if (_buf->capacity - _buf->size < sizeof(double) + sizeof(uint32_t) + size)
return false;
diff --git a/src/libs/engine/MidiNoteNode.cpp b/src/libs/engine/MidiNoteNode.cpp
index a5b29f85..42d96dfa 100644
--- a/src/libs/engine/MidiNoteNode.cpp
+++ b/src/libs/engine/MidiNoteNode.cpp
@@ -218,8 +218,8 @@ MidiNoteNode::note_on(uchar note_num, uchar velocity, FrameTime time, SampleCoun
assert(voice != NULL);
assert(voice == &(*_voices)[voice_num]);
- //cerr << "[MidiNoteNode] Note " << (int)note_num << " on @ " << time
- // << ". Voice " << voice_num << " / " << _polyphony << endl;
+ cerr << "[MidiNoteNode] Note " << (int)note_num << " on @ " << time
+ << ". Voice " << voice_num << " / " << _polyphony << endl;
// Update stolen key, if applicable
if (voice->state == Voice::Voice::ACTIVE) {
@@ -273,7 +273,7 @@ MidiNoteNode::note_off(uchar note_num, FrameTime time, SampleCount nframes, Fram
Key* key = &_keys[note_num];
- //cerr << "[MidiNoteNode] Note off @ " << time << ". Key " << (int)note_num << endl;
+ cerr << "[MidiNoteNode] Note off @ " << time << ". Key " << (int)note_num << endl;
if (key->state == Key::ON_ASSIGNED) {
// Assigned key, turn off voice and key
diff --git a/src/libs/engine/OSCEngineReceiver.cpp b/src/libs/engine/OSCEngineReceiver.cpp
index caaf0d73..d2d7a4a0 100644
--- a/src/libs/engine/OSCEngineReceiver.cpp
+++ b/src/libs/engine/OSCEngineReceiver.cpp
@@ -96,10 +96,8 @@ OSCEngineReceiver::OSCEngineReceiver(Engine& engine, size_t queue_size, uint16_t
lo_server_add_method(_server, "/ingen/connect", "iss", connect_cb, this);
lo_server_add_method(_server, "/ingen/disconnect", "iss", disconnect_cb, this);
lo_server_add_method(_server, "/ingen/disconnect_all", "is", disconnect_all_cb, this);
- lo_server_add_method(_server, "/ingen/set_port_value", "isf", set_port_value_cb, this);
- lo_server_add_method(_server, "/ingen/set_port_value", "isif", set_port_value_voice_cb, this);
- lo_server_add_method(_server, "/ingen/set_port_value_immediate", "isf", set_port_value_immediate_cb, this);
- lo_server_add_method(_server, "/ingen/set_port_value_immediate", "isif", set_port_value_immediate_voice_cb, this);
+ lo_server_add_method(_server, "/ingen/set_port_value", NULL, set_port_value_cb, this);
+ lo_server_add_method(_server, "/ingen/set_port_value_immediate", NULL, set_port_value_immediate_cb, this);
lo_server_add_method(_server, "/ingen/note_on", "isii", note_on_cb, this);
lo_server_add_method(_server, "/ingen/note_off", "isi", note_off_cb, this);
lo_server_add_method(_server, "/ingen/all_notes_off", "isi", all_notes_off_cb, this);
@@ -598,7 +596,7 @@ OSCEngineReceiver::_disconnect_cb(const char* path, const char* types, lo_arg**
int
OSCEngineReceiver::_disconnect_all_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
{
- const char* node_path = &argv[1]->s;
+ const char* node_path = &argv[1]->s;
disconnect_all(node_path);
return 0;
@@ -611,17 +609,6 @@ OSCEngineReceiver::_disconnect_all_cb(const char* path, const char* types, lo_ar
* \arg \b port-path (string) - Name of port
* \arg \b value (float) - Value to set port to </p> \n \n
*/
-int
-OSCEngineReceiver::_set_port_value_immediate_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
-{
- const char* port_path = &argv[1]->s;
- const float value = argv[2]->f;
-
- set_port_value_immediate(port_path, sizeof(float), &value);
- return 0;
-}
-
-
/** \page engine_osc_namespace
* <p> \b /ingen/set_port_value_immediate - Sets the value of a port for a specific voice (both AR and CR)
* \arg \b response-id (integer)
@@ -632,13 +619,43 @@ OSCEngineReceiver::_set_port_value_immediate_cb(const char* path, const char* ty
* See documentation for set_port_value for the distinction between these two messages.
*/
int
-OSCEngineReceiver::_set_port_value_immediate_voice_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
+OSCEngineReceiver::_set_port_value_immediate_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
{
- const char* port_path = &argv[1]->s;
- const int32_t voice = argv[2]->i;
- const float value = argv[3]->f;
+ if (argc < 3 || argc > 4 || strncmp(types, "is", 2))
+ return 1;
+
+ const char* port_path = &argv[1]->s;
+
+ if (argc == 3) {
+ if (types[2] == 'f') {
+ const float value = argv[2]->f;
+ set_port_value_immediate(port_path, "who cares", sizeof(float), &value);
+ return 0;
+ } else if (types[2] == 'b') {
+ lo_blob b = argv[2];
+ size_t data_size = lo_blob_datasize(b);
+ void* data = lo_blob_dataptr(b);
+ set_port_value_immediate(port_path, "who cares", data_size, data);
+ return 0;
+ } else {
+ return 1;
+ }
+ } else {
+ if (types[3] == 'f') {
+ const float value = argv[3]->f;
+ set_port_value_immediate(port_path, "who cares", argv[2]->i, sizeof(float), &value);
+ return 0;
+ } else if (types[3] == 'b') {
+ lo_blob b = argv[3];
+ size_t data_size = lo_blob_datasize(b);
+ void* data = lo_blob_dataptr(b);
+ set_port_value_immediate(port_path, "who cares", argv[2]->i, data_size, data);
+ return 0;
+ } else {
+ return 1;
+ }
+ }
- set_port_value_immediate(port_path, voice, sizeof(float), &value);
return 0;
}
@@ -657,17 +674,6 @@ OSCEngineReceiver::_set_port_value_immediate_voice_cb(const char* path, const ch
* There is also a fast "immediate" version of this message, set_port_value_immediate, which
* does not have this ordering guarantee.</p> \n \n
*/
-int
-OSCEngineReceiver::_set_port_value_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
-{
- const char* port_path = &argv[1]->s;
- const float value = argv[2]->f;
-
- set_port_value(port_path, sizeof(float), &value);
- return 0;
-}
-
-
/** \page engine_osc_namespace
* <p> \b /ingen/set_port_value - Sets the value of a port for all voices (as a QueuedEvent)
* \arg \b response-id (integer)
@@ -683,13 +689,43 @@ OSCEngineReceiver::_set_port_value_cb(const char* path, const char* types, lo_ar
* does not have this ordering guarantee.</p> \n \n
*/
int
-OSCEngineReceiver::_set_port_value_voice_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
+OSCEngineReceiver::_set_port_value_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
{
- const char* port_path = &argv[1]->s;
- const int32_t voice = argv[2]->i;
- const float value = argv[3]->f;
+ if (argc < 3 || argc > 4 || strncmp(types, "is", 2))
+ return 1;
+
+ const char* port_path = &argv[1]->s;
+
+ if (argc == 3) {
+ if (types[2] == 'f') {
+ const float value = argv[2]->f;
+ set_port_value(port_path, "who cares", sizeof(float), &value);
+ return 0;
+ } else if (types[2] == 'b') {
+ lo_blob b = argv[2];
+ size_t data_size = lo_blob_datasize(b);
+ void* data = lo_blob_dataptr(b);
+ set_port_value(port_path, "who cares", data_size, data);
+ return 0;
+ } else {
+ return 1;
+ }
+ } else {
+ if (types[3] == 'f') {
+ const float value = argv[3]->f;
+ set_port_value(port_path, "who cares", argv[2]->i, sizeof(float), &value);
+ return 0;
+ } else if (types[3] == 'b') {
+ lo_blob b = argv[3];
+ size_t data_size = lo_blob_datasize(b);
+ void* data = lo_blob_dataptr(b);
+ set_port_value(port_path, "who cares", argv[2]->i, data_size, data);
+ return 0;
+ } else {
+ return 1;
+ }
+ }
- set_port_value(port_path, voice, sizeof(float), &value);
return 0;
}
diff --git a/src/libs/engine/OSCEngineReceiver.hpp b/src/libs/engine/OSCEngineReceiver.hpp
index e6ecebac..75cbda7c 100644
--- a/src/libs/engine/OSCEngineReceiver.hpp
+++ b/src/libs/engine/OSCEngineReceiver.hpp
@@ -99,9 +99,7 @@ private:
LO_HANDLER(disconnect);
LO_HANDLER(disconnect_all);
LO_HANDLER(set_port_value);
- LO_HANDLER(set_port_value_voice);
LO_HANDLER(set_port_value_immediate);
- LO_HANDLER(set_port_value_immediate_voice);
LO_HANDLER(note_on);
LO_HANDLER(note_off);
LO_HANDLER(all_notes_off);
diff --git a/src/libs/engine/QueuedEngineInterface.cpp b/src/libs/engine/QueuedEngineInterface.cpp
index 41780e92..72be00aa 100644
--- a/src/libs/engine/QueuedEngineInterface.cpp
+++ b/src/libs/engine/QueuedEngineInterface.cpp
@@ -233,6 +233,7 @@ QueuedEngineInterface::disconnect_all(const string& node_path)
void
QueuedEngineInterface::set_port_value(const string& port_path,
+ const string& type_uri,
uint32_t data_size,
const void* data)
{
@@ -242,6 +243,7 @@ QueuedEngineInterface::set_port_value(const string& port_path,
void
QueuedEngineInterface::set_port_value(const string& port_path,
+ const string& type_uri,
uint32_t voice,
uint32_t data_size,
const void* data)
@@ -252,6 +254,7 @@ QueuedEngineInterface::set_port_value(const string& port_path,
void
QueuedEngineInterface::set_port_value_immediate(const string& port_path,
+ const string& type_uri,
uint32_t data_size,
const void* data)
{
@@ -261,6 +264,7 @@ QueuedEngineInterface::set_port_value_immediate(const string& port_path,
void
QueuedEngineInterface::set_port_value_immediate(const string& port_path,
+ const string& type_uri,
uint32_t voice,
uint32_t data_size,
const void* data)
diff --git a/src/libs/engine/QueuedEngineInterface.hpp b/src/libs/engine/QueuedEngineInterface.hpp
index 06583186..3a0ad016 100644
--- a/src/libs/engine/QueuedEngineInterface.hpp
+++ b/src/libs/engine/QueuedEngineInterface.hpp
@@ -119,19 +119,23 @@ public:
virtual void disconnect_all(const string& node_path);
virtual void set_port_value(const string& port_path,
+ const string& type_uri,
uint32_t data_size,
const void* data);
virtual void set_port_value(const string& port_path,
+ const string& type_uri,
uint32_t voice,
uint32_t data_size,
const void* data);
virtual void set_port_value_immediate(const string& port_path,
+ const string& type_uri,
uint32_t data_size,
const void* data);
virtual void set_port_value_immediate(const string& port_path,
+ const string& type_uri,
uint32_t voice,
uint32_t data_size,
const void* data);
diff --git a/src/libs/engine/events/SetPortValueEvent.cpp b/src/libs/engine/events/SetPortValueEvent.cpp
index fa2238e2..9d1ad0db 100644
--- a/src/libs/engine/events/SetPortValueEvent.cpp
+++ b/src/libs/engine/events/SetPortValueEvent.cpp
@@ -95,7 +95,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 size_t offset = (buf->size() == 1) ? 0 : _time - start;
+ const uint32_t offset = (buf->size() == 1) ? 0 : _time - start;
if (_omni)
for (uint32_t i=0; i < _port->poly(); ++i)
@@ -108,7 +108,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, mbuf->latest_stamp());
+ const double stamp = std::max((double)(_time - start), mbuf->latest_stamp());
mbuf->append(stamp, _data_size, (const unsigned char*)_data);
}
}
diff --git a/src/libs/engine/events/SetPortValueQueuedEvent.cpp b/src/libs/engine/events/SetPortValueQueuedEvent.cpp
index 8940d4c5..d0bfff4a 100644
--- a/src/libs/engine/events/SetPortValueQueuedEvent.cpp
+++ b/src/libs/engine/events/SetPortValueQueuedEvent.cpp
@@ -25,6 +25,7 @@
#include "Node.hpp"
#include "ObjectStore.hpp"
#include "AudioBuffer.hpp"
+#include "MidiBuffer.hpp"
namespace Ingen {
@@ -94,14 +95,26 @@ SetPortValueQueuedEvent::execute(SampleCount nframes, FrameTime start, FrameTime
if (_error == NO_ERROR) {
assert(_port);
- AudioBuffer* const buf = (AudioBuffer*)_port->buffer(0);
- const size_t offset = (buf->size() == 1) ? 0 : _time - start;
-
- if (_omni)
- for (uint32_t i=0; i < _port->poly(); ++i)
- ((AudioBuffer*)_port->buffer(i))->set(*(float*)_data, offset);
- else
- ((AudioBuffer*)_port->buffer(_voice_num))->set(*(float*)_data, offset);
+
+ 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;
+
+ if (_omni)
+ for (uint32_t i=0; i < _port->poly(); ++i)
+ ((AudioBuffer*)_port->buffer(i))->set(*(float*)_data, offset);
+ else
+ ((AudioBuffer*)_port->buffer(_voice_num))->set(*(float*)_data, offset);
+
+ return;
+ }
+
+ MidiBuffer* const mbuf = dynamic_cast<MidiBuffer*>(buf);
+ if (mbuf) {
+ const double stamp = std::max((double)(_time - start), mbuf->latest_stamp());
+ mbuf->append(stamp, _data_size, (const unsigned char*)_data);
+ }
}
}