summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2007-10-09 03:45:24 +0000
committerDavid Robillard <d@drobilla.net>2007-10-09 03:45:24 +0000
commitb98fd4bc7b8548cc2be538a91ce799fabbd3054f (patch)
tree1b48099e550d83eb138d886f3bb643a90071f5f0
parent531cd8958765315a5340ba94487d655023acd758 (diff)
downloadingen-b98fd4bc7b8548cc2be538a91ce799fabbd3054f.tar.gz
ingen-b98fd4bc7b8548cc2be538a91ce799fabbd3054f.tar.bz2
ingen-b98fd4bc7b8548cc2be538a91ce799fabbd3054f.zip
Fix OSC patching.
Add OSC "bang" LV2 plugin, with GUI (just a button). Make OSC metronome suck slightly less. git-svn-id: http://svn.drobilla.net/lad/ingen@857 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r--src/libs/client/Makefile.am1
-rw-r--r--src/libs/client/OSCClientReceiver.cpp2
-rw-r--r--src/libs/client/PluginModel.cpp24
-rw-r--r--src/libs/engine/ConnectionImpl.cpp6
-rw-r--r--src/libs/engine/Makefile.am1
-rw-r--r--src/libs/engine/OSCBuffer.hpp5
-rw-r--r--src/libs/engine/ObjectStore.cpp8
-rw-r--r--src/libs/engine/events/SetPortValueEvent.cpp10
-rw-r--r--src/libs/engine/events/SetPortValueEvent.hpp14
-rw-r--r--src/libs/gui/NodeModule.cpp11
10 files changed, 60 insertions, 22 deletions
diff --git a/src/libs/client/Makefile.am b/src/libs/client/Makefile.am
index 2106c6db..ba8afd89 100644
--- a/src/libs/client/Makefile.am
+++ b/src/libs/client/Makefile.am
@@ -9,6 +9,7 @@ libingen_client_la_CXXFLAGS = \
-I$(top_srcdir)/slv2 \
-I$(top_srcdir)/raul \
-I$(top_srcdir)/ingen/src/common \
+ -I$(top_srcdir)/lv2/extensions/osc \
-DPKGDATADIR=\"$(pkgdatadir)\" \
@LIBLO_CFLAGS@ \
@LXML2_CFLAGS@ @RASQAL_CFLAGS@ @RAPTOR_CFLAGS@ \
diff --git a/src/libs/client/OSCClientReceiver.cpp b/src/libs/client/OSCClientReceiver.cpp
index 1da99a96..bd0b5db9 100644
--- a/src/libs/client/OSCClientReceiver.cpp
+++ b/src/libs/client/OSCClientReceiver.cpp
@@ -35,7 +35,7 @@ OSCClientReceiver::OSCClientReceiver(int listen_port)
_listen_port(listen_port),
_st(NULL)
{
- start(false);
+ start(false); // true = dump, false = shutup
}
diff --git a/src/libs/client/PluginModel.cpp b/src/libs/client/PluginModel.cpp
index 1947ddbd..e819d04b 100644
--- a/src/libs/client/PluginModel.cpp
+++ b/src/libs/client/PluginModel.cpp
@@ -17,6 +17,7 @@
#include <sstream>
#include <raul/Path.hpp>
+#include "lv2_osc_print.h"
#include "PluginModel.hpp"
#include "PatchModel.hpp"
@@ -63,14 +64,31 @@ struct NodeController {
void
lv2_ui_write(LV2UI_Controller controller,
- uint32_t port,
+ uint32_t port_index,
uint32_t buffer_size,
const void* buffer)
{
+ /*cerr << "********* LV2 UI WRITE:" << endl;
+ lv2_osc_message_print((const LV2Message*)buffer);
+
+ fprintf(stderr, "RAW:\n");
+ for (uint32_t i=0; i < buffer_size; ++i) {
+ unsigned char byte = ((unsigned char*)buffer)[i];
+ if (byte >= 32 && byte <= 126)
+ fprintf(stderr, "%c ", ((unsigned char*)buffer)[i]);
+ else
+ fprintf(stderr, "%2X ", ((unsigned char*)buffer)[i]);
+ }
+
+ fprintf(stderr, "\n");
+ */
+
NodeController* nc = (NodeController*)controller;
- nc->engine->set_port_value_immediate(nc->node->ports()[port]->path(),
- "ingen:midi", buffer_size, buffer);
+ SharedPtr<PortModel> port = nc->node->ports()[port_index];
+
+ nc->engine->set_port_value_immediate(port->path(),
+ port->type().uri(), buffer_size, buffer);
}
diff --git a/src/libs/engine/ConnectionImpl.cpp b/src/libs/engine/ConnectionImpl.cpp
index 4114e7ae..019a051e 100644
--- a/src/libs/engine/ConnectionImpl.cpp
+++ b/src/libs/engine/ConnectionImpl.cpp
@@ -54,7 +54,7 @@ ConnectionImpl::ConnectionImpl(PortImpl* src_port, PortImpl* dst_port)
/*assert((src_port->parent_node()->poly() == dst_port->parent_node()->poly())
|| (src_port->parent_node()->poly() == 1 || dst_port->parent_node()->poly() == 1));*/
- if (type() == DataType::MIDI)
+ if (type() == DataType::MIDI || type() == DataType::OSC)
_must_mix = false; // FIXME: kludge
if (_must_mix)
@@ -164,6 +164,10 @@ ConnectionImpl::process(ProcessContext& context)
cerr << "WARNING: No MIDI mixing." << endl;
+ } else if (_must_mix && type() == DataType::OSC) {
+
+ cerr << "WARNING: No OSC mixing." << endl;
+
}
}
diff --git a/src/libs/engine/Makefile.am b/src/libs/engine/Makefile.am
index 68f9739a..91af96fc 100644
--- a/src/libs/engine/Makefile.am
+++ b/src/libs/engine/Makefile.am
@@ -10,6 +10,7 @@ libingen_engine_la_CXXFLAGS = \
-I$(top_srcdir)/ingen/src/common \
-I$(top_srcdir)/ingen/src/libs \
-I$(top_srcdir)/ingen/src/libs/engine/events \
+ -I$(top_srcdir)/lv2/extensions/osc \
@JACK_CFLAGS@ @LIBLO_CFLAGS@ @ALSA_CFLAGS@ @LASH_CFLAGS@ @GLIBMM_CFLAGS@
libingen_engine_la_LDFLAGS = -no-undefined -module -avoid-version
diff --git a/src/libs/engine/OSCBuffer.hpp b/src/libs/engine/OSCBuffer.hpp
index 9f352de3..31371641 100644
--- a/src/libs/engine/OSCBuffer.hpp
+++ b/src/libs/engine/OSCBuffer.hpp
@@ -37,8 +37,6 @@ public:
void prepare_read(SampleCount nframes);
void prepare_write(SampleCount nframes);
-
- void* raw_data() const { return _buf; }
bool is_joined_to(Buffer* buf) const;
bool join(Buffer* buf);
@@ -48,6 +46,9 @@ public:
uint32_t this_nframes() const { return _this_nframes; }
uint32_t event_count() const { return _buf->message_count; }
+
+ inline void* raw_data() const
+ { return ((_joined_buf != NULL) ? _joined_buf->raw_data() : _buf); }
inline LV2OSCBuffer* data()
{ return ((_joined_buf != NULL) ? _joined_buf->data() : _buf); }
diff --git a/src/libs/engine/ObjectStore.cpp b/src/libs/engine/ObjectStore.cpp
index 7b9f29fe..2eff21b0 100644
--- a/src/libs/engine/ObjectStore.cpp
+++ b/src/libs/engine/ObjectStore.cpp
@@ -79,7 +79,7 @@ ObjectStore::add(GraphObjectImpl* o)
{
assert(ThreadManager::current_thread_id() == THREAD_PRE_PROCESS);
- cerr << "[ObjectStore] Adding " << o->path() << endl;
+ //cerr << "[ObjectStore] Adding " << o->path() << endl;
_objects.insert(make_pair(o->path(), o));
NodeImpl* node = dynamic_cast<NodeImpl*>(o);
@@ -101,10 +101,10 @@ ObjectStore::add(const Table<Path, SharedPtr<Shared::GraphObject> >& table)
//cerr << "[ObjectStore] Adding " << o[0].second->path() << endl;
_objects.cram(table);
- cerr << "[ObjectStore] Adding Table:" << endl;
+ /*cerr << "[ObjectStore] Adding Table:" << endl;
for (Objects::const_iterator i = table.begin(); i != table.end(); ++i) {
cerr << i->first << " = " << i->second->path() << endl;
- }
+ }*/
}
@@ -132,7 +132,7 @@ ObjectStore::remove(Objects::iterator object)
if (object != _objects.end()) {
Objects::iterator descendants_end = _objects.find_descendants_end(object);
- cout << "[ObjectStore] Removing " << object->first << " {" << endl;
+ //cout << "[ObjectStore] Removing " << object->first << " {" << endl;
Table<Path, SharedPtr<Shared::GraphObject> > removed = _objects.yank(object, descendants_end);
for (Objects::iterator i = removed.begin(); i != removed.end(); ++i) {
cout << "\t" << i->first << endl;
diff --git a/src/libs/engine/events/SetPortValueEvent.cpp b/src/libs/engine/events/SetPortValueEvent.cpp
index f278c083..592c09b3 100644
--- a/src/libs/engine/events/SetPortValueEvent.cpp
+++ b/src/libs/engine/events/SetPortValueEvent.cpp
@@ -16,6 +16,7 @@
*/
#include <sstream>
+#include "lv2_osc_print.h"
#include "Responder.hpp"
#include "SetPortValueEvent.hpp"
#include "Engine.hpp"
@@ -25,6 +26,7 @@
#include "ObjectStore.hpp"
#include "AudioBuffer.hpp"
#include "MidiBuffer.hpp"
+#include "OSCBuffer.hpp"
#include "ProcessContext.hpp"
using namespace std;
@@ -111,6 +113,14 @@ SetPortValueEvent::execute(ProcessContext& context)
if (mbuf) {
const double stamp = std::max((double)(_time - context.start()), mbuf->latest_stamp());
mbuf->append(stamp, _data_size, (const unsigned char*)_data);
+ return;
+ }
+
+ OSCBuffer* const obuf = dynamic_cast<OSCBuffer*>(buf);
+ if (obuf) {
+ //cerr << "Appending OSC message:" << endl;
+ //lv2_osc_message_print((LV2Message*)_data);
+ lv2_osc_buffer_append_message(obuf->data(), (LV2Message*)_data);
}
}
}
diff --git a/src/libs/engine/events/SetPortValueEvent.hpp b/src/libs/engine/events/SetPortValueEvent.hpp
index c9d46a8e..e6497aa5 100644
--- a/src/libs/engine/events/SetPortValueEvent.hpp
+++ b/src/libs/engine/events/SetPortValueEvent.hpp
@@ -58,13 +58,13 @@ public:
private:
enum ErrorType { NO_ERROR, PORT_NOT_FOUND, NO_SPACE };
- bool _omni;
- uint32_t _voice_num;
- string _port_path;
- uint32_t _data_size;
- void* _data;
- PortImpl* _port;
- ErrorType _error;
+ bool _omni;
+ uint32_t _voice_num;
+ const string _port_path;
+ uint32_t _data_size;
+ void* _data;
+ PortImpl* _port;
+ ErrorType _error;
};
diff --git a/src/libs/gui/NodeModule.cpp b/src/libs/gui/NodeModule.cpp
index a0ca3992..1f4f8d91 100644
--- a/src/libs/gui/NodeModule.cpp
+++ b/src/libs/gui/NodeModule.cpp
@@ -111,7 +111,8 @@ NodeModule::control_change(uint32_t index, float control)
if (_slv2_ui) {
const LV2UI_Descriptor* const ui_descriptor = slv2_ui_instance_get_descriptor(_slv2_ui);
LV2UI_Handle ui_handle = slv2_ui_instance_get_handle(_slv2_ui);
- ui_descriptor->port_event(ui_handle, index, 4, &control);
+ if (ui_descriptor->port_event)
+ ui_descriptor->port_event(ui_handle, index, 4, &control);
}
}
@@ -190,9 +191,11 @@ NodeModule::embed_gui(bool embed)
_gui_item = NULL;
}
- slv2_ui_instance_free(_slv2_ui);
- _slv2_ui = NULL;
- _gui = NULL;
+ if (_slv2_ui) {
+ slv2_ui_instance_free(_slv2_ui);
+ _slv2_ui = NULL;
+ _gui = NULL;
+ }
_ports_y_offset = 0;
_minimum_width = 0; // resize() takes care of it..