summaryrefslogtreecommitdiffstats
path: root/src/server/internals
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/internals')
-rw-r--r--src/server/internals/Controller.cpp8
-rw-r--r--src/server/internals/Note.cpp23
-rw-r--r--src/server/internals/Trigger.cpp21
3 files changed, 22 insertions, 30 deletions
diff --git a/src/server/internals/Controller.cpp b/src/server/internals/Controller.cpp
index 85f69442..571918fe 100644
--- a/src/server/internals/Controller.cpp
+++ b/src/server/internals/Controller.cpp
@@ -117,8 +117,7 @@ ControllerNode::control(ProcessContext& context, uint8_t control_num, uint8_t va
if (_learning) {
// FIXME: not thread safe
_param_port->set_value(context.engine().world()->forge().make(control_num));
- ((AudioBuffer*)_param_port->buffer(0).get())->set_value(
- (float)control_num, context.start(), context.end());
+ _param_port->set_control_value(context, time, control_num);
_param_port->broadcast_value(context, true);
_learning = false;
}
@@ -139,8 +138,9 @@ ControllerNode::control(ProcessContext& context, uint8_t control_num, uint8_t va
scaled_value = ((nval) * (max_port_val - min_port_val)) + min_port_val;
}
- if (control_num == ((AudioBuffer*)_param_port->buffer(0).get())->value_at(0))
- ((AudioBuffer*)_audio_port->buffer(0).get())->set_value(scaled_value, context.start(), time);
+ if (control_num == ((AudioBuffer*)_param_port->buffer(0).get())->value_at(0)) {
+ _audio_port->set_control_value(context, time, scaled_value);
+ }
}
} // namespace Internals
diff --git a/src/server/internals/Note.cpp b/src/server/internals/Note.cpp
index 1292686d..e72e2d38 100644
--- a/src/server/internals/Note.cpp
+++ b/src/server/internals/Note.cpp
@@ -259,18 +259,11 @@ NoteNode::note_on(ProcessContext& context, uint8_t note_num, uint8_t velocity, F
assert(_keys[voice->note].state == Key::Key::ON_ASSIGNED);
assert(_keys[voice->note].voice == voice_num);
- ((AudioBuffer*)_freq_port->buffer(voice_num).get())->set_value(
- note_to_freq(note_num), context.start(), time);
- ((AudioBuffer*)_vel_port->buffer(voice_num).get())->set_value(
- velocity/127.0, context.start(), time);
- ((AudioBuffer*)_gate_port->buffer(voice_num).get())->set_value(
- 1.0f, context.start(), time);
-
- // trigger (one sample)
- ((AudioBuffer*)_trig_port->buffer(voice_num).get())->set_value(
- 1.0f, context.start(), time);
- ((AudioBuffer*)_trig_port->buffer(voice_num).get())->set_value(
- 0.0f, context.start(), time + 1);
+ _freq_port->set_voice_value(context, voice_num, time, note_to_freq(note_num));
+ _vel_port->set_voice_value(context, voice_num, time, velocity / 127.0f);
+ _gate_port->set_voice_value(context, voice_num, time, 1.0f);
+ _trig_port->set_voice_value(context, voice_num, time, 1.0f);
+ _trig_port->set_voice_value(context, voice_num, time + 1, 0.0f);
assert(key->state == Key::Key::ON_ASSIGNED);
assert(voice->state == Voice::Voice::ACTIVE);
@@ -339,7 +332,7 @@ NoteNode::free_voice(ProcessContext& context, uint32_t voice, FrameTime time)
assert(replace_key->state == Key::ON_UNASSIGNED);
// Change the freq but leave the gate high and don't retrigger
- ((AudioBuffer*)_freq_port->buffer(voice).get())->set_value(note_to_freq(replace_key_num), context.start(), time);
+ _freq_port->set_voice_value(context, voice, time, note_to_freq(replace_key_num));
replace_key->state = Key::ON_ASSIGNED;
replace_key->voice = voice;
@@ -351,7 +344,7 @@ NoteNode::free_voice(ProcessContext& context, uint32_t voice, FrameTime time)
#ifdef NOTE_DEBUG
LOG(Raul::debug) << "Note off: key " << (int)(*_voices)[voice].note << " voice " << voice << endl;
#endif
- ((AudioBuffer*)_gate_port->buffer(voice).get())->set_value(0.0f, context.start(), time);
+ _gate_port->set_voice_value(context, voice, time, 0.0f);
(*_voices)[voice].state = Voice::FREE;
}
}
@@ -368,7 +361,7 @@ NoteNode::all_notes_off(ProcessContext& context, FrameTime time)
// FIXME: set all keys to Key::OFF?
for (uint32_t i = 0; i < _polyphony; ++i) {
- ((AudioBuffer*)_gate_port->buffer(i).get())->set_value(0.0f, context.start(), time);
+ _gate_port->set_voice_value(context, i, time, 0.0f);
(*_voices)[i].state = Voice::FREE;
}
}
diff --git a/src/server/internals/Trigger.cpp b/src/server/internals/Trigger.cpp
index 699c31f1..4c4c6ab6 100644
--- a/src/server/internals/Trigger.cpp
+++ b/src/server/internals/Trigger.cpp
@@ -23,6 +23,7 @@
#include "raul/midi_events.h"
#include "AudioBuffer.hpp"
+#include "Engine.hpp"
#include "InputPort.hpp"
#include "InternalPlugin.hpp"
#include "OutputPort.hpp"
@@ -114,8 +115,7 @@ TriggerNode::process(ProcessContext& context)
case MIDI_CMD_CONTROL:
if (buf[1] == MIDI_CTL_ALL_NOTES_OFF ||
buf[1] == MIDI_CTL_ALL_SOUNDS_OFF) {
- ((AudioBuffer*)_gate_port->buffer(0).get())->set_value(
- 0.0f, context.start(), time);
+ _gate_port->set_control_value(context, time, 0.0f);
}
default:
break;
@@ -132,10 +132,9 @@ TriggerNode::note_on(ProcessContext& context, uint8_t note_num, uint8_t velocity
assert(time >= context.start() && time <= context.end());
if (_learning) {
- // FIXME
- //_note_port->set_value(note_num);
- ((AudioBuffer*)_note_port->buffer(0).get())->set_value(
- (float)note_num, context.start(), context.end());
+ // FIXME: not thread safe
+ _note_port->set_value(context.engine().world()->forge().make(note_num));
+ _note_port->set_control_value(context, time, note_num);
_note_port->broadcast_value(context, true);
_learning = false;
}
@@ -146,10 +145,10 @@ TriggerNode::note_on(ProcessContext& context, uint8_t note_num, uint8_t velocity
Sample filter_note = ((AudioBuffer*)_note_port->buffer(0).get())->value_at(0);
if (filter_note >= 0.0 && filter_note < 127.0 && (note_num == (uint8_t)filter_note)) {
- ((AudioBuffer*)_gate_port->buffer(0).get())->set_value(1.0f, context.start(), time);
- ((AudioBuffer*)_trig_port->buffer(0).get())->set_value(1.0f, context.start(), time);
- ((AudioBuffer*)_trig_port->buffer(0).get())->set_value(0.0f, context.start(), time + 1);
- ((AudioBuffer*)_vel_port->buffer(0).get())->set_value(velocity / 127.0f, context.start(), time);
+ _gate_port->set_control_value(context, time, 1.0f);
+ _trig_port->set_control_value(context, time, 1.0f);
+ _trig_port->set_control_value(context, time + 1, 0.0f);
+ _vel_port->set_control_value(context, time, velocity / 127.0f);
assert(((AudioBuffer*)_trig_port->buffer(0).get())->data()[time - context.start()] == 1.0f);
}
}
@@ -160,7 +159,7 @@ TriggerNode::note_off(ProcessContext& context, uint8_t note_num, FrameTime time)
assert(time >= context.start() && time <= context.end());
if (note_num == lrintf(((AudioBuffer*)_note_port->buffer(0).get())->value_at(0)))
- ((AudioBuffer*)_gate_port->buffer(0).get())->set_value(0.0f, context.start(), time);
+ _gate_port->set_control_value(context, time, 0.0f);
}
} // namespace Internals