summaryrefslogtreecommitdiffstats
path: root/src/libs/engine
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs/engine')
-rw-r--r--src/libs/engine/BufferFactory.cpp3
-rw-r--r--src/libs/engine/DataType.h13
-rw-r--r--src/libs/engine/Makefile.am5
-rw-r--r--src/libs/engine/OSCBuffer.cpp105
-rw-r--r--src/libs/engine/OSCBuffer.h63
-rw-r--r--src/libs/engine/OSCClientSender.cpp2
-rw-r--r--src/libs/engine/OSCEngineReceiver.cpp2
-rw-r--r--src/libs/engine/ObjectSender.cpp2
-rw-r--r--src/libs/engine/Port.cpp4
-rw-r--r--src/libs/engine/events/AddPortEvent.cpp6
10 files changed, 195 insertions, 10 deletions
diff --git a/src/libs/engine/BufferFactory.cpp b/src/libs/engine/BufferFactory.cpp
index f2761f08..48db9261 100644
--- a/src/libs/engine/BufferFactory.cpp
+++ b/src/libs/engine/BufferFactory.cpp
@@ -18,6 +18,7 @@
#include "BufferFactory.h"
#include "AudioBuffer.h"
#include "MidiBuffer.h"
+#include "OSCBuffer.h"
namespace Ingen {
namespace BufferFactory {
@@ -30,6 +31,8 @@ create(DataType type, size_t size)
return new AudioBuffer(size);
else if (type == DataType::MIDI)
return new MidiBuffer(size);
+ else if (type == DataType::OSC)
+ return new OSCBuffer(size);
else
return NULL;
}
diff --git a/src/libs/engine/DataType.h b/src/libs/engine/DataType.h
index 469c48d8..1f431edd 100644
--- a/src/libs/engine/DataType.h
+++ b/src/libs/engine/DataType.h
@@ -33,16 +33,19 @@ public:
enum Symbol {
UNKNOWN = 0,
FLOAT = 1,
- MIDI = 2
+ MIDI = 2,
+ OSC = 3
};
DataType(const std::string& uri)
: _symbol(UNKNOWN)
{
- if (uri == type_uris[MIDI]) {
- _symbol = MIDI;
- } else if (uri == type_uris[FLOAT]) {
+ if (uri == type_uris[FLOAT]) {
_symbol = FLOAT;
+ } else if (uri == type_uris[MIDI]) {
+ _symbol = MIDI;
+ } else if (uri == type_uris[OSC]) {
+ _symbol = OSC;
}
}
@@ -62,7 +65,7 @@ private:
Symbol _symbol;
// Defined in Port.cpp for no good reason
- static const char* const type_uris[3];
+ static const char* const type_uris[4];
};
diff --git a/src/libs/engine/Makefile.am b/src/libs/engine/Makefile.am
index 89dd0735..04353964 100644
--- a/src/libs/engine/Makefile.am
+++ b/src/libs/engine/Makefile.am
@@ -9,6 +9,8 @@ libingen_engine_la_CXXFLAGS = @RAUL_CFLAGS@ @JACK_CFLAGS@ @LOSC_CFLAGS@ @ALSA_CF
libingen_engine_la_LDFLAGS = -no-undefined -module -avoid-version
libingen_engine_la_LIBADD = @RAUL_LIBS@ @JACK_LIBS@ @LOSC_LIBS@ @ALSA_LIBS@ @LASH_LIBS@ @SLV2_LIBS@
+AM_CFLAGS="-std=c99"
+
libingen_engine_la_SOURCES = \
engine.h \
engine.cpp \
@@ -45,6 +47,9 @@ libingen_engine_la_SOURCES = \
AudioBuffer.cpp \
MidiBuffer.h \
MidiBuffer.cpp \
+ OSCBuffer.h \
+ OSCBuffer.cpp \
+ ../../../../lv2/extensions/osc/lv2_osc.c \
BufferFactory.h \
BufferFactory.cpp \
Port.h \
diff --git a/src/libs/engine/OSCBuffer.cpp b/src/libs/engine/OSCBuffer.cpp
new file mode 100644
index 00000000..75201a30
--- /dev/null
+++ b/src/libs/engine/OSCBuffer.cpp
@@ -0,0 +1,105 @@
+/* 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 <iostream>
+#include "OSCBuffer.h"
+
+using namespace std;
+
+namespace Ingen {
+
+OSCBuffer::OSCBuffer(size_t capacity)
+ : Buffer(DataType(DataType::OSC), capacity)
+ , _buf(lv2_osc_buffer_new((uint32_t)capacity))
+ , _joined_buf(NULL)
+{
+ /*_local_state.midi = _buf;
+ _state = &_local_state;
+ assert(_local_state.midi);
+ reset(0);
+ clear();
+ assert(_local_state.midi == _buf);
+*/
+ //cerr << "Creating OSC Buffer " << _buf << ", capacity = " << _buf->capacity << endl;
+}
+
+
+
+/** Use another buffer's data instead of the local one.
+ *
+ * This buffer will essentially be identical to @a buf after this call.
+ */
+bool
+OSCBuffer::join(Buffer* buf)
+{
+ OSCBuffer* mbuf = dynamic_cast<OSCBuffer*>(buf);
+ if (!mbuf)
+ return false;
+
+ //assert(mbuf->size() == _size);
+
+ _joined_buf = mbuf;
+
+ //_state = mbuf->_state;
+
+ return true;
+}
+
+
+void
+OSCBuffer::unjoin()
+{
+ _joined_buf = NULL;
+ //_state = &_local_state;
+ //_state->midi = _buf;
+
+ clear();
+ reset(_this_nframes);
+}
+
+
+bool
+OSCBuffer::is_joined_to(Buffer* buf) const
+{
+ OSCBuffer* mbuf = dynamic_cast<OSCBuffer*>(buf);
+ if (mbuf)
+ return (data() == mbuf->data());
+
+ return false;
+}
+
+
+void
+OSCBuffer::prepare_read(SampleCount nframes)
+{
+ assert(!_joined_buf || data() == _joined_buf->data());
+
+ reset(nframes);
+}
+
+
+void
+OSCBuffer::prepare_write(SampleCount nframes)
+{
+ clear();
+ reset(nframes);
+
+ assert(!_joined_buf || data() == _joined_buf->data());
+}
+
+
+} // namespace Ingen
diff --git a/src/libs/engine/OSCBuffer.h b/src/libs/engine/OSCBuffer.h
new file mode 100644
index 00000000..53e3b2d5
--- /dev/null
+++ b/src/libs/engine/OSCBuffer.h
@@ -0,0 +1,63 @@
+/* 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
+ */
+
+#ifndef OSCBUFFER_H
+#define OSCBUFFER_H
+
+#include "Buffer.h"
+#include "DataType.h"
+#include "../../../../lv2/extensions/osc/lv2_osc.h"
+
+namespace Ingen {
+
+
+class OSCBuffer : public Buffer {
+public:
+ OSCBuffer(size_t capacity);
+
+ ~OSCBuffer() { }
+
+ void clear() { lv2_osc_buffer_clear(_buf); }
+ void reset(SampleCount nframs) {}
+
+ void prepare_read(SampleCount nframes);
+ void prepare_write(SampleCount nframes);
+
+ bool is_joined_to(Buffer* buf) const;
+ bool join(Buffer* buf);
+ void unjoin();
+
+ uint32_t this_nframes() const { return _this_nframes; }
+
+ inline LV2OSCBuffer* data()
+ { return ((_joined_buf != NULL) ? _joined_buf->data() : _buf); }
+
+ inline const LV2OSCBuffer* data() const
+ { return ((_joined_buf != NULL) ? _joined_buf->data() : _buf); }
+
+private:
+ LV2OSCBuffer* const _buf;
+
+ OSCBuffer* _joined_buf; ///< Buffer to mirror, if joined
+
+ uint32_t _this_nframes;
+};
+
+
+} // namespace Ingen
+
+#endif // OSCBUFFER_H
diff --git a/src/libs/engine/OSCClientSender.cpp b/src/libs/engine/OSCClientSender.cpp
index a20efea4..c3f0f330 100644
--- a/src/libs/engine/OSCClientSender.cpp
+++ b/src/libs/engine/OSCClientSender.cpp
@@ -338,7 +338,7 @@ void OSCClientSender::new_node(string plugin_uri,
/** \page client_osc_namespace
* <p> \b /ingen/new_port - Notification of a new port's creation.
* \arg \b path (string) - Path of new port
- * \arg \b data-type (string) - Type of port (ingen:audio, ingen:control, or ingen:midi)
+ * \arg \b data-type (string) - Type of port (ingen:audio, ingen:control, ingen:midi, or ingen:osc)
* \arg \b direction ("is-output") (integer) - Direction of data flow (Input = 0, Output = 1)
*
* \li Note that in the event of loading a patch, this message could be
diff --git a/src/libs/engine/OSCEngineReceiver.cpp b/src/libs/engine/OSCEngineReceiver.cpp
index 6a4ce9ae..7bc336c2 100644
--- a/src/libs/engine/OSCEngineReceiver.cpp
+++ b/src/libs/engine/OSCEngineReceiver.cpp
@@ -480,7 +480,7 @@ OSCEngineReceiver::_clear_patch_cb(const char* path, const char* types, lo_arg**
* <p> \b /ingen/create_port - Add a port into a given patch (load a plugin by URI)
* \arg \b response-id (integer)
* \arg \b path (string) - Full path of the new port (ie. /patch2/subpatch/newport)
- * \arg \b data-type (string) - Data type for port to contain ("ingen:audio", "ingen:control", or "ingen:midi")
+ * \arg \b data-type (string) - Data type for port to contain ("ingen:audio", "ingen:control", "ingen:midi", or "ingen:osc")
* \arg \b direction ("is-output") (integer) - Direction of data flow (Input = 0, Output = 1) </p> \n \n
*/
int
diff --git a/src/libs/engine/ObjectSender.cpp b/src/libs/engine/ObjectSender.cpp
index 608d1768..592f4735 100644
--- a/src/libs/engine/ObjectSender.cpp
+++ b/src/libs/engine/ObjectSender.cpp
@@ -131,6 +131,8 @@ ObjectSender::send_port(ClientInterface* client, const Port* port)
type = "ingen:audio";
} else if (port->type() == DataType::MIDI) {
type = "ingen:midi";
+ } else if (port->type() == DataType::OSC) {
+ type = "ingen:osc";
}
//cerr << ", type = " << type << endl;
diff --git a/src/libs/engine/Port.cpp b/src/libs/engine/Port.cpp
index bfb09a35..f82da743 100644
--- a/src/libs/engine/Port.cpp
+++ b/src/libs/engine/Port.cpp
@@ -24,8 +24,8 @@
namespace Ingen {
-// Yeah, this shouldn't be here.
-const char* const DataType::type_uris[3] = { "UNKNOWN", "FLOAT", "MIDI" };
+// FIXME: Make these actually URIs..
+const char* const DataType::type_uris[4] = { "UNKNOWN", "FLOAT", "MIDI", "OSC" };
Port::Port(Node* const node, const string& name, size_t index, size_t poly, DataType type, size_t buffer_size)
diff --git a/src/libs/engine/events/AddPortEvent.cpp b/src/libs/engine/events/AddPortEvent.cpp
index b1925b07..82cd4ded 100644
--- a/src/libs/engine/events/AddPortEvent.cpp
+++ b/src/libs/engine/events/AddPortEvent.cpp
@@ -68,6 +68,8 @@ AddPortEvent::AddPortEvent(Engine& engine,
_data_type = DataType::FLOAT;
else if (type == "ingen:midi")
_data_type = DataType::MIDI;
+ else if (type == "ingen:osc")
+ _data_type = DataType::OSC;
}
@@ -87,7 +89,7 @@ AddPortEvent::pre_process()
assert(_patch->path() == _path.parent());
size_t buffer_size = 1;
- if (_type == "ingen:audio" || _type == "ingen:midi")
+ if (_type != "ingen:control")
buffer_size = _engine.audio_driver()->buffer_size();
const size_t old_num_ports = _patch->num_ports();
@@ -145,6 +147,8 @@ AddPortEvent::execute(SampleCount nframes, FrameTime start, FrameTime end)
_engine.audio_driver()->add_port(_driver_port);
else if (_type == "ingen:midi")
_engine.midi_driver()->add_port(_driver_port);
+ else if (_type == "ingen:osc")
+ cerr << "OSC DRIVER PORT" << endl;
}