summaryrefslogtreecommitdiffstats
path: root/src/server/internals
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/internals')
-rw-r--r--src/server/internals/Note.cpp56
-rw-r--r--src/server/internals/Note.hpp6
2 files changed, 60 insertions, 2 deletions
diff --git a/src/server/internals/Note.cpp b/src/server/internals/Note.cpp
index 7558334e..cdb5b3e9 100644
--- a/src/server/internals/Note.cpp
+++ b/src/server/internals/Note.cpp
@@ -58,9 +58,10 @@ NoteNode::NoteNode(InternalPlugin* plugin,
, _sustain(false)
{
const Ingen::URIs& uris = bufs.uris();
- _ports = new Raul::Array<PortImpl*>(6);
+ _ports = new Raul::Array<PortImpl*>(8);
const Atom zero = bufs.forge().make(0.0f);
+ const Atom one = bufs.forge().make(1.0f);
_midi_in_port = new InputPort(bufs, this, Raul::Symbol("input"), 0, 1,
PortType::ATOM, uris.atom_Sequence, Atom());
@@ -91,7 +92,7 @@ NoteNode::NoteNode(InternalPlugin* plugin,
PortType::ATOM, uris.atom_Sequence, zero);
_vel_port->set_property(uris.atom_supports, bufs.uris().atom_Float);
_vel_port->set_property(uris.lv2_minimum, zero);
- _vel_port->set_property(uris.lv2_maximum, bufs.forge().make(1.0f));
+ _vel_port->set_property(uris.lv2_maximum, one);
_vel_port->set_property(uris.lv2_name, bufs.forge().alloc("Velocity"));
_ports->at(3) = _vel_port;
@@ -108,6 +109,24 @@ NoteNode::NoteNode(InternalPlugin* plugin,
_trig_port->set_property(uris.lv2_portProperty, uris.lv2_toggled);
_trig_port->set_property(uris.lv2_name, bufs.forge().alloc("Trigger"));
_ports->at(5) = _trig_port;
+
+ _bend_port = new OutputPort(bufs, this, Raul::Symbol("bend"), 5, _polyphony,
+ PortType::ATOM, uris.atom_Sequence, zero);
+ _bend_port->set_property(uris.atom_supports, bufs.uris().atom_Float);
+ _bend_port->set_property(uris.lv2_name, bufs.forge().alloc("Bender"));
+ _bend_port->set_property(uris.lv2_default, zero);
+ _bend_port->set_property(uris.lv2_minimum, bufs.forge().make(-1.0f));
+ _bend_port->set_property(uris.lv2_maximum, one);
+ _ports->at(6) = _bend_port;
+
+ _pressure_port = new OutputPort(bufs, this, Raul::Symbol("pressure"), 6, _polyphony,
+ PortType::ATOM, uris.atom_Sequence, zero);
+ _pressure_port->set_property(uris.atom_supports, bufs.uris().atom_Float);
+ _pressure_port->set_property(uris.lv2_name, bufs.forge().alloc("Pressure"));
+ _pressure_port->set_property(uris.lv2_default, zero);
+ _pressure_port->set_property(uris.lv2_minimum, zero);
+ _pressure_port->set_property(uris.lv2_maximum, one);
+ _ports->at(7) = _pressure_port;
}
NoteNode::~NoteNode()
@@ -183,6 +202,16 @@ NoteNode::run(ProcessContext& context)
}
break;
}
+ case LV2_MIDI_MSG_BENDER:
+ bend(context, time, (((((uint16_t)buf[2] << 7) | buf[1]) - 8192.0f)
+ / 8192.0f));
+ break;
+ case LV2_MIDI_MSG_CHANNEL_PRESSURE:
+ channel_pressure(context, time, buf[1] / 127.0f);
+ break;
+ case LV2_MIDI_MSG_NOTE_PRESSURE:
+ note_pressure(context, time, buf[1], buf[2] / 127.0f);
+ break;
default:
break;
}
@@ -360,6 +389,29 @@ NoteNode::sustain_off(ProcessContext& context, FrameTime time)
free_voice(context, i, time);
}
+void
+NoteNode::bend(ProcessContext& context, FrameTime time, float amount)
+{
+ _bend_port->set_control_value(context, time, amount);
+}
+
+void
+NoteNode::note_pressure(ProcessContext& context, FrameTime time, uint8_t note_num, float amount)
+{
+ for (uint32_t i=0; i < _polyphony; ++i) {
+ if ((*_voices)[i].state != Voice::State::FREE && (*_voices)[i].note == note_num) {
+ _pressure_port->set_voice_value(context, i, time, amount);
+ return;
+ }
+ }
+}
+
+void
+NoteNode::channel_pressure(ProcessContext& context, FrameTime time, float amount)
+{
+ _pressure_port->set_control_value(context, time, amount);
+}
+
} // namespace Internals
} // namespace Server
} // namespace Ingen
diff --git a/src/server/internals/Note.hpp b/src/server/internals/Note.hpp
index 3b77cf12..2ef64718 100644
--- a/src/server/internals/Note.hpp
+++ b/src/server/internals/Note.hpp
@@ -59,6 +59,10 @@ public:
void sustain_on(ProcessContext& context, FrameTime time);
void sustain_off(ProcessContext& context, FrameTime time);
+ void bend(ProcessContext& context, FrameTime time, float amount);
+ void note_pressure(ProcessContext& context, FrameTime time, uint8_t note_num, float amount);
+ void channel_pressure(ProcessContext& context, FrameTime time, float amount);
+
static InternalPlugin* internal_plugin(URIs& uris);
private:
@@ -93,6 +97,8 @@ private:
OutputPort* _vel_port;
OutputPort* _gate_port;
OutputPort* _trig_port;
+ OutputPort* _bend_port;
+ OutputPort* _pressure_port;
};
} // namespace Server