summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/engine/EventSink.hpp2
-rw-r--r--src/engine/MidiControlNode.cpp15
-rw-r--r--src/engine/PortImpl.cpp34
-rw-r--r--src/engine/PortImpl.hpp2
-rw-r--r--src/engine/PostProcessor.cpp7
-rw-r--r--src/engine/events/MidiLearnEvent.cpp26
-rw-r--r--src/engine/events/MidiLearnEvent.hpp6
-rw-r--r--src/gui/NodeMenu.cpp11
-rw-r--r--src/gui/NodeMenu.hpp1
-rw-r--r--src/gui/ingen_gui.glade14
10 files changed, 83 insertions, 35 deletions
diff --git a/src/engine/EventSink.hpp b/src/engine/EventSink.hpp
index 82443dbd..be739de9 100644
--- a/src/engine/EventSink.hpp
+++ b/src/engine/EventSink.hpp
@@ -52,7 +52,7 @@ public:
private:
Engine& _engine;
- Raul::RingBuffer<uchar> _events;
+ Raul::RingBuffer<uint8_t> _events;
};
diff --git a/src/engine/MidiControlNode.cpp b/src/engine/MidiControlNode.cpp
index fc6098ec..0e907a8b 100644
--- a/src/engine/MidiControlNode.cpp
+++ b/src/engine/MidiControlNode.cpp
@@ -20,12 +20,14 @@
#include "MidiControlNode.hpp"
#include "PostProcessor.hpp"
#include "events/MidiLearnEvent.hpp"
+#include "events/SendPortValueEvent.hpp"
#include "InputPort.hpp"
#include "OutputPort.hpp"
#include "InternalPlugin.hpp"
#include "AudioBuffer.hpp"
#include "ProcessContext.hpp"
#include "EventBuffer.hpp"
+#include "Engine.hpp"
#include "util.hpp"
namespace Ingen {
@@ -102,18 +104,13 @@ MidiControlNode::control(ProcessContext& context, uchar control_num, uchar val,
const Sample nval = (val / 127.0f); // normalized [0, 1]
if (_learning) {
- assert(false); // FIXME FIXME FIXME
-#if 0
assert(_learn_event != NULL);
- _param_port->set_value(control_num, offset);
- assert(_param_port->buffer(0)->value_at(0) == control_num);
- _learn_event->set_value(control_num);
- _learn_event->execute(offset);
- //Engine::instance().post_processor()->push(_learn_event);
- //Engine::instance().post_processor()->whip();
+ _param_port->set_value(control_num);
+ ((AudioBuffer*)_param_port->buffer(0))->set_value(
+ (float)control_num, context.start(), context.end());
+ _param_port->broadcast_value(context, true);
_learning = false;
_learn_event = NULL;
-#endif
}
const Sample min_port_val = ((AudioBuffer*)_min_port->buffer(0))->value_at(0);
diff --git a/src/engine/PortImpl.cpp b/src/engine/PortImpl.cpp
index b8c77f43..4669dba4 100644
--- a/src/engine/PortImpl.cpp
+++ b/src/engine/PortImpl.cpp
@@ -169,25 +169,31 @@ PortImpl::clear_buffers()
void
-PortImpl::broadcast(ProcessContext& context)
+PortImpl::broadcast_value(ProcessContext& context, bool force)
{
- if (_broadcast) {
- if (_type == DataType::CONTROL || _type == DataType::AUDIO) {
- const Sample value = ((AudioBuffer*)buffer(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::EVENT) {
- if (((EventBuffer*)buffer(0))->event_count() > 0) {
- const SendPortActivityEvent ev(context.engine(), context.start(), this);
- context.event_sink().write(sizeof(ev), &ev);
- }
+ if (_type == DataType::CONTROL || _type == DataType::AUDIO) {
+ const Sample value = ((AudioBuffer*)buffer(0))->value_at(0);
+ if (force || 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::EVENT) {
+ if (((EventBuffer*)buffer(0))->event_count() > 0) {
+ const SendPortActivityEvent ev(context.engine(), context.start(), this);
+ context.event_sink().write(sizeof(ev), &ev);
}
}
}
+void
+PortImpl::broadcast(ProcessContext& context)
+{
+ if (_broadcast)
+ broadcast_value(context);
+}
+
+
} // namespace Ingen
diff --git a/src/engine/PortImpl.hpp b/src/engine/PortImpl.hpp
index 9837ebf2..66108b56 100644
--- a/src/engine/PortImpl.hpp
+++ b/src/engine/PortImpl.hpp
@@ -109,6 +109,8 @@ public:
void broadcast(bool b) { _broadcast = b; }
bool broadcast() { return _broadcast; }
+ void broadcast_value(ProcessContext& context, bool force=false);
+
void raise_set_by_user_flag() { _set_by_user = true; }
Context::ID context() const { return _context; }
diff --git a/src/engine/PostProcessor.cpp b/src/engine/PostProcessor.cpp
index 23b841ca..9543a712 100644
--- a/src/engine/PostProcessor.cpp
+++ b/src/engine/PostProcessor.cpp
@@ -70,8 +70,11 @@ PostProcessor::process()
/* Process audio thread generated events */
while (_engine.audio_driver()->context().event_sink().read(
_event_buffer_size, _event_buffer)) {
- if (((Event*)_event_buffer)->time() > end_time)
- break; // FIXME: loses event?
+ if (((Event*)_event_buffer)->time() > end_time) {
+ cerr << "WARNING: Lost event with time "
+ << ((Event*)_event_buffer)->time() << " > " << end_time << endl;
+ break;
+ }
((Event*)_event_buffer)->post_process();
}
diff --git a/src/engine/events/MidiLearnEvent.cpp b/src/engine/events/MidiLearnEvent.cpp
index 2f37f30d..68293cb7 100644
--- a/src/engine/events/MidiLearnEvent.cpp
+++ b/src/engine/events/MidiLearnEvent.cpp
@@ -40,10 +40,11 @@ MidiLearnResponseEvent::post_process()
// MidiLearnEvent
MidiLearnEvent::MidiLearnEvent(Engine& engine, SharedPtr<Responder> responder, SampleCount timestamp, const string& node_path)
-: QueuedEvent(engine, responder, timestamp),
- _node_path(node_path),
- _node(NULL),
- _response_event(NULL)
+ : QueuedEvent(engine, responder, timestamp)
+ , _error(NO_ERROR)
+ , _node_path(node_path)
+ , _node(NULL)
+ , _response_event(NULL)
{
}
@@ -63,10 +64,14 @@ MidiLearnEvent::execute(ProcessContext& context)
{
QueuedEvent::execute(context);
- // FIXME: this isn't very good at all.
- if (_node != NULL && _node->plugin_impl()->type() == Plugin::Internal
- && _node->plugin_impl()->uri() == "ingen:control_node") {
+ if (_node != NULL) {
+ if (_node->plugin_impl()->type() == Plugin::Internal
+ && _node->plugin_impl()->uri() == "http://drobilla.net/ns/ingen#control_node") {
((MidiControlNode*)_node)->learn(_response_event);
+ } else {
+ std::cout << "NOT CAPABLE: " << _node->plugin_impl()->uri() << std::endl;
+ _error = INVALID_NODE_TYPE;
+ }
}
}
@@ -74,12 +79,15 @@ MidiLearnEvent::execute(ProcessContext& context)
void
MidiLearnEvent::post_process()
{
- if (_node != NULL) {
+ if (_error == NO_ERROR) {
_responder->respond_ok();
- } else {
+ } else if (_node == NULL) {
string msg = "Did not find node '";
msg.append(_node_path).append("' for MIDI learn.");
_responder->respond_error(msg);
+ } else {
+ const string msg = string("Node '") + _node_path + "' is not capable of MIDI learn.";
+ _responder->respond_error(msg);
}
}
diff --git a/src/engine/events/MidiLearnEvent.hpp b/src/engine/events/MidiLearnEvent.hpp
index c0fc4a17..1dceb041 100644
--- a/src/engine/events/MidiLearnEvent.hpp
+++ b/src/engine/events/MidiLearnEvent.hpp
@@ -72,6 +72,12 @@ public:
void post_process();
private:
+ enum ErrorType {
+ NO_ERROR,
+ INVALID_NODE_TYPE
+ };
+
+ ErrorType _error;
const string _node_path;
NodeImpl* _node;
diff --git a/src/gui/NodeMenu.cpp b/src/gui/NodeMenu.cpp
index 43c0bf75..accf8ef1 100644
--- a/src/gui/NodeMenu.cpp
+++ b/src/gui/NodeMenu.cpp
@@ -36,11 +36,13 @@ NodeMenu::NodeMenu(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml
{
Gtk::Menu* node_menu = NULL;
xml->get_widget("node_menu", node_menu);
+ xml->get_widget("node_learn_menuitem", _learn_menuitem);
xml->get_widget("node_controls_menuitem", _controls_menuitem);
xml->get_widget("node_popup_gui_menuitem", _popup_gui_menuitem);
xml->get_widget("node_embed_gui_menuitem", _embed_gui_menuitem);
xml->get_widget("node_randomize_menuitem", _randomize_menuitem);
+ node_menu->remove(*_learn_menuitem);
node_menu->remove(*_controls_menuitem);
node_menu->remove(*_popup_gui_menuitem);
node_menu->remove(*_embed_gui_menuitem);
@@ -51,6 +53,7 @@ NodeMenu::NodeMenu(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml
insert(*_controls_menuitem, 0);
insert(*_popup_gui_menuitem, 0);
insert(*_embed_gui_menuitem, 0);
+ insert(*_learn_menuitem, 0);
}
@@ -59,6 +62,9 @@ NodeMenu::init(SharedPtr<NodeModel> node)
{
ObjectMenu::init(node);
+ _learn_menuitem->signal_activate().connect(sigc::mem_fun(this,
+ &NodeMenu::on_menu_learn));
+
_controls_menuitem->signal_activate().connect(sigc::bind(
sigc::mem_fun(App::instance().window_factory(), &WindowFactory::present_controls),
node));
@@ -84,6 +90,11 @@ NodeMenu::init(SharedPtr<NodeModel> node)
else
_randomize_menuitem->hide();
+ if (plugin->uri() == "http://drobilla.net/ns/ingen#control_node")
+ _learn_menuitem->show();
+ else
+ _learn_menuitem->hide();
+
_enable_signal = true;
}
diff --git a/src/gui/NodeMenu.hpp b/src/gui/NodeMenu.hpp
index d31aded2..c37dc415 100644
--- a/src/gui/NodeMenu.hpp
+++ b/src/gui/NodeMenu.hpp
@@ -60,6 +60,7 @@ protected:
void on_menu_embed_gui();
void on_menu_randomize();
+ Gtk::MenuItem* _learn_menuitem;
Gtk::MenuItem* _controls_menuitem;
Gtk::MenuItem* _popup_gui_menuitem;
Gtk::CheckMenuItem* _embed_gui_menuitem;
diff --git a/src/gui/ingen_gui.glade b/src/gui/ingen_gui.glade
index cabf3377..402e5466 100644
--- a/src/gui/ingen_gui.glade
+++ b/src/gui/ingen_gui.glade
@@ -3267,6 +3267,20 @@ Thank you for contributing.</property>
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<child>
+ <widget class="GtkImageMenuItem" id="node_learn_menuitem">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="tooltip" translatable="yes">Learn from the next received event</property>
+ <property name="label" translatable="yes">_Learn</property>
+ <property name="use_underline">True</property>
+ <child internal-child="image">
+ <widget class="GtkImage" id="menu-item-image25">
+ <property name="stock">gtk-media-record</property>
+ </widget>
+ </child>
+ </widget>
+ </child>
+ <child>
<widget class="GtkImageMenuItem" id="node_controls_menuitem">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>