summaryrefslogtreecommitdiffstats
path: root/src/libs/engine/Port.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2007-10-01 05:27:41 +0000
committerDavid Robillard <d@drobilla.net>2007-10-01 05:27:41 +0000
commita47220df59c076eaa717710dc2ffc6614bee268c (patch)
treebea9dd981dd6a8ca90bb27c77bb976997be31f2d /src/libs/engine/Port.cpp
parent344cdcbd4f2bc7a9203b4e98da2ac349581e521a (diff)
downloadingen-a47220df59c076eaa717710dc2ffc6614bee268c.tar.gz
ingen-a47220df59c076eaa717710dc2ffc6614bee268c.tar.bz2
ingen-a47220df59c076eaa717710dc2ffc6614bee268c.zip
Blink MIDI ports on message transmission.
git-svn-id: http://svn.drobilla.net/lad/ingen@794 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/libs/engine/Port.cpp')
-rw-r--r--src/libs/engine/Port.cpp33
1 files changed, 32 insertions, 1 deletions
diff --git a/src/libs/engine/Port.cpp b/src/libs/engine/Port.cpp
index d1813f3f..d85c1790 100644
--- a/src/libs/engine/Port.cpp
+++ b/src/libs/engine/Port.cpp
@@ -15,14 +15,19 @@
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <iostream>
#include <raul/Array.hpp>
#include <raul/Maid.hpp>
#include "Port.hpp"
#include "Node.hpp"
#include "DataType.hpp"
#include "AudioBuffer.hpp"
+#include "MidiBuffer.hpp"
#include "BufferFactory.hpp"
#include "ProcessContext.hpp"
+#include "SendPortActivityEvent.hpp"
+
+using namespace std;
namespace Ingen {
@@ -38,7 +43,8 @@ Port::Port(Node* const node, const string& name, uint32_t index, uint32_t poly,
, _buffer_size(buffer_size)
, _type(type)
, _fixed_buffers(false)
- , _monitor(false)
+ , _broadcast(false)
+ , _last_broadcasted_value(0.0f) // default?
, _buffers(new Raul::Array<Buffer*>(poly))
{
assert(node != NULL);
@@ -49,6 +55,9 @@ Port::Port(Node* const node, const string& name, uint32_t index, uint32_t poly,
if (node->parent() == NULL)
_polyphonic = false;
+
+ if (type == DataType::MIDI)
+ _broadcast = true; // send activity blips
assert(_buffers->size() > 0);
}
@@ -138,6 +147,28 @@ Port::clear_buffers()
for (uint32_t i=0; i < _poly; ++i)
_buffers->at(i)->clear();
}
+
+
+void
+Port::broadcast(ProcessContext& context)
+{
+ if (_broadcast) {
+ if (_type == DataType::FLOAT && _buffer_size == 1) {
+ const Sample value = ((AudioBuffer*)(*_buffers)[0])->value_at(0);
+ if (value != _last_broadcasted_value) {
+ const SendPortValueEvent ev(context.engine(), context.start(), this, false, 0, value);
+ context.event_sink().write(sizeof(ev), &ev);
+ _last_broadcasted_value = value;
+ }
+ } else if (_type == DataType::MIDI) {
+ if (((MidiBuffer*)(*_buffers)[0])->event_count() > 0) {
+ const SendPortActivityEvent ev(context.engine(), context.start(), this);
+ context.event_sink().write(sizeof(ev), &ev);
+ }
+ }
+ }
+}
+
} // namespace Ingen