summaryrefslogtreecommitdiffstats
path: root/src/server/internals
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2020-08-01 17:51:16 +0200
committerDavid Robillard <d@drobilla.net>2020-08-02 01:48:48 +0200
commitd13e41341f687b9f526887aba7e664d71ae34aec (patch)
tree2f68f12e6c182169ad840b1710fa3e376c47ed00 /src/server/internals
parent95ceaf902f95baa431cdda972c0ebb48293e2022 (diff)
downloadingen-d13e41341f687b9f526887aba7e664d71ae34aec.tar.gz
ingen-d13e41341f687b9f526887aba7e664d71ae34aec.tar.bz2
ingen-d13e41341f687b9f526887aba7e664d71ae34aec.zip
Use consistent naming for context parameters
Diffstat (limited to 'src/server/internals')
-rw-r--r--src/server/internals/BlockDelay.cpp6
-rw-r--r--src/server/internals/BlockDelay.hpp2
-rw-r--r--src/server/internals/Controller.cpp14
-rw-r--r--src/server/internals/Controller.hpp4
-rw-r--r--src/server/internals/Note.cpp84
-rw-r--r--src/server/internals/Note.hpp22
-rw-r--r--src/server/internals/Time.cpp5
-rw-r--r--src/server/internals/Time.hpp2
-rw-r--r--src/server/internals/Trigger.cpp38
-rw-r--r--src/server/internals/Trigger.hpp6
10 files changed, 91 insertions, 92 deletions
diff --git a/src/server/internals/BlockDelay.cpp b/src/server/internals/BlockDelay.cpp
index 0176c9b1..2974ca18 100644
--- a/src/server/internals/BlockDelay.cpp
+++ b/src/server/internals/BlockDelay.cpp
@@ -75,13 +75,13 @@ BlockDelayNode::activate(BufferFactory& bufs)
}
void
-BlockDelayNode::run(RunContext& context)
+BlockDelayNode::run(RunContext& ctx)
{
// Copy buffer from last cycle to output
- _out_port->buffer(0)->copy(context, _buffer.get());
+ _out_port->buffer(0)->copy(ctx, _buffer.get());
// Copy input from this cycle to buffer
- _buffer->copy(context, _in_port->buffer(0).get());
+ _buffer->copy(ctx, _in_port->buffer(0).get());
}
} // namespace internals
diff --git a/src/server/internals/BlockDelay.hpp b/src/server/internals/BlockDelay.hpp
index 0e8fadce..3c84ff39 100644
--- a/src/server/internals/BlockDelay.hpp
+++ b/src/server/internals/BlockDelay.hpp
@@ -45,7 +45,7 @@ public:
void activate(BufferFactory& bufs) override;
- void run(RunContext& context) override;
+ void run(RunContext& ctx) override;
static InternalPlugin* internal_plugin(URIs& uris);
diff --git a/src/server/internals/Controller.cpp b/src/server/internals/Controller.cpp
index d40fc431..0d38bc43 100644
--- a/src/server/internals/Controller.cpp
+++ b/src/server/internals/Controller.cpp
@@ -108,7 +108,7 @@ ControllerNode::ControllerNode(InternalPlugin* plugin,
}
void
-ControllerNode::run(RunContext& context)
+ControllerNode::run(RunContext& ctx)
{
const BufferRef midi_in = _midi_in_port->buffer(0);
auto* seq = midi_in->get<LV2_Atom_Sequence>();
@@ -119,7 +119,7 @@ ControllerNode::run(RunContext& context)
if (ev->body.type == _midi_in_port->bufs().uris().midi_MidiEvent &&
ev->body.size >= 3 &&
lv2_midi_message_type(buf) == LV2_MIDI_MSG_CONTROLLER) {
- if (control(context, buf[1], buf[2], ev->time.frames + context.start())) {
+ if (control(ctx, buf[1], buf[2], ev->time.frames + ctx.start())) {
midi_out->append_event(ev->time.frames, &ev->body);
}
}
@@ -127,15 +127,15 @@ ControllerNode::run(RunContext& context)
}
bool
-ControllerNode::control(RunContext& context, uint8_t control_num, uint8_t val, FrameTime time)
+ControllerNode::control(RunContext& ctx, uint8_t control_num, uint8_t val, FrameTime time)
{
- assert(time >= context.start() && time <= context.end());
- const uint32_t offset = time - context.start();
+ assert(time >= ctx.start() && time <= ctx.end());
+ const uint32_t offset = time - ctx.start();
const Sample nval = (val / 127.0f); // normalized [0, 1]
if (_learning) {
- _param_port->set_control_value(context, time, control_num);
+ _param_port->set_control_value(ctx, time, control_num);
_param_port->force_monitor_update();
_learning = false;
} else {
@@ -168,7 +168,7 @@ ControllerNode::control(RunContext& context, uint8_t control_num, uint8_t val, F
scaled_value = ((nval) * (max_port_val - min_port_val)) + min_port_val;
}
- _audio_port->set_control_value(context, time, scaled_value);
+ _audio_port->set_control_value(ctx, time, scaled_value);
return true;
}
diff --git a/src/server/internals/Controller.hpp b/src/server/internals/Controller.hpp
index 0a62b235..9c24fa49 100644
--- a/src/server/internals/Controller.hpp
+++ b/src/server/internals/Controller.hpp
@@ -47,9 +47,9 @@ public:
GraphImpl* parent,
SampleRate srate);
- void run(RunContext& context) override;
+ void run(RunContext& ctx) override;
- bool control(RunContext& context, uint8_t control_num, uint8_t val, FrameTime time);
+ bool control(RunContext& ctx, uint8_t control_num, uint8_t val, FrameTime time);
void learn() override { _learning = true; }
diff --git a/src/server/internals/Note.cpp b/src/server/internals/Note.cpp
index b2a22c14..76dde8af 100644
--- a/src/server/internals/Note.cpp
+++ b/src/server/internals/Note.cpp
@@ -146,9 +146,9 @@ NoteNode::prepare_poly(BufferFactory& bufs, uint32_t poly)
}
bool
-NoteNode::apply_poly(RunContext& context, uint32_t poly)
+NoteNode::apply_poly(RunContext& ctx, uint32_t poly)
{
- if (!BlockImpl::apply_poly(context, poly)) {
+ if (!BlockImpl::apply_poly(ctx, poly)) {
return false;
}
@@ -162,7 +162,7 @@ NoteNode::apply_poly(RunContext& context, uint32_t poly)
}
void
-NoteNode::run(RunContext& context)
+NoteNode::run(RunContext& ctx)
{
Buffer* const midi_in = _midi_in_port->buffer(0).get();
auto* seq = midi_in->get<LV2_Atom_Sequence>();
@@ -172,48 +172,48 @@ NoteNode::run(RunContext& context)
static_cast<const uint8_t*>(LV2_ATOM_BODY_CONST(&ev->body));
const FrameTime time =
- context.start() + static_cast<FrameTime>(ev->time.frames);
+ ctx.start() + static_cast<FrameTime>(ev->time.frames);
if (ev->body.type == _midi_in_port->bufs().uris().midi_MidiEvent &&
ev->body.size >= 3) {
switch (lv2_midi_message_type(buf)) {
case LV2_MIDI_MSG_NOTE_ON:
if (buf[2] == 0) {
- note_off(context, buf[1], time);
+ note_off(ctx, buf[1], time);
} else {
- note_on(context, buf[1], buf[2], time);
+ note_on(ctx, buf[1], buf[2], time);
}
break;
case LV2_MIDI_MSG_NOTE_OFF:
- note_off(context, buf[1], time);
+ note_off(ctx, buf[1], time);
break;
case LV2_MIDI_MSG_CONTROLLER:
switch (buf[1]) {
case LV2_MIDI_CTL_ALL_NOTES_OFF:
case LV2_MIDI_CTL_ALL_SOUNDS_OFF:
- all_notes_off(context, time);
+ all_notes_off(ctx, time);
break;
case LV2_MIDI_CTL_SUSTAIN:
if (buf[2] > 63) {
- sustain_on(context, time);
+ sustain_on(ctx, time);
} else {
- sustain_off(context, time);
+ sustain_off(ctx, time);
}
break;
}
break;
case LV2_MIDI_MSG_BENDER:
- bend(context,
+ bend(ctx,
time,
((((static_cast<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);
+ channel_pressure(ctx, time, buf[1] / 127.0f);
break;
case LV2_MIDI_MSG_NOTE_PRESSURE:
- note_pressure(context, time, buf[1], buf[2] / 127.0f);
+ note_pressure(ctx, time, buf[1], buf[2] / 127.0f);
break;
default:
break;
@@ -230,9 +230,9 @@ note_to_freq(uint8_t num)
}
void
-NoteNode::note_on(RunContext& context, uint8_t note_num, uint8_t velocity, FrameTime time)
+NoteNode::note_on(RunContext& ctx, uint8_t note_num, uint8_t velocity, FrameTime time)
{
- assert(time >= context.start() && time <= context.end());
+ assert(time >= ctx.start() && time <= ctx.end());
assert(note_num <= 127);
Key* key = &_keys[note_num];
@@ -293,13 +293,13 @@ NoteNode::note_on(RunContext& context, uint8_t note_num, uint8_t velocity, Frame
assert(_keys[voice->note].state == Key::State::ON_ASSIGNED);
assert(_keys[voice->note].voice == voice_num);
- _freq_port->set_voice_value(context, voice_num, time, note_to_freq(note_num));
- _num_port->set_voice_value(context, voice_num, time, static_cast<float>(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);
+ _freq_port->set_voice_value(ctx, voice_num, time, note_to_freq(note_num));
+ _num_port->set_voice_value(ctx, voice_num, time, static_cast<float>(note_num));
+ _vel_port->set_voice_value(ctx, voice_num, time, velocity / 127.0f);
+ _gate_port->set_voice_value(ctx, voice_num, time, 1.0f);
if (!double_trigger) {
- _trig_port->set_voice_value(context, voice_num, time, 1.0f);
- _trig_port->set_voice_value(context, voice_num, time + 1, 0.0f);
+ _trig_port->set_voice_value(ctx, voice_num, time, 1.0f);
+ _trig_port->set_voice_value(ctx, voice_num, time + 1, 0.0f);
}
assert(key->state == Key::State::ON_ASSIGNED);
@@ -309,9 +309,9 @@ NoteNode::note_on(RunContext& context, uint8_t note_num, uint8_t velocity, Frame
}
void
-NoteNode::note_off(RunContext& context, uint8_t note_num, FrameTime time)
+NoteNode::note_off(RunContext& ctx, uint8_t note_num, FrameTime time)
{
- assert(time >= context.start() && time <= context.end());
+ assert(time >= ctx.start() && time <= ctx.end());
Key* key = &_keys[note_num];
@@ -320,7 +320,7 @@ NoteNode::note_off(RunContext& context, uint8_t note_num, FrameTime time)
if ((*_voices)[key->voice].state == Voice::State::ACTIVE) {
assert((*_voices)[key->voice].note == note_num);
if ( ! _sustain) {
- free_voice(context, key->voice, time);
+ free_voice(ctx, key->voice, time);
} else {
(*_voices)[key->voice].state = Voice::State::HOLDING;
}
@@ -331,9 +331,9 @@ NoteNode::note_off(RunContext& context, uint8_t note_num, FrameTime time)
}
void
-NoteNode::free_voice(RunContext& context, uint32_t voice, FrameTime time)
+NoteNode::free_voice(RunContext& ctx, uint32_t voice, FrameTime time)
{
- assert(time >= context.start() && time <= context.end());
+ assert(time >= ctx.start() && time <= ctx.end());
// Find a key to reassign to the freed voice (the newest, if there is one)
Key* replace_key = nullptr;
@@ -353,8 +353,8 @@ NoteNode::free_voice(RunContext& context, uint32_t voice, FrameTime time)
assert(replace_key->state == Key::State::ON_UNASSIGNED);
// Change the freq but leave the gate high and don't retrigger
- _freq_port->set_voice_value(context, voice, time, note_to_freq(replace_key_num));
- _num_port->set_voice_value(context, voice, time, replace_key_num);
+ _freq_port->set_voice_value(ctx, voice, time, note_to_freq(replace_key_num));
+ _num_port->set_voice_value(ctx, voice, time, replace_key_num);
replace_key->state = Key::State::ON_ASSIGNED;
replace_key->voice = voice;
@@ -363,65 +363,65 @@ NoteNode::free_voice(RunContext& context, uint32_t voice, FrameTime time)
(*_voices)[voice].state = Voice::State::ACTIVE;
} else {
// No new note for voice, deactivate (set gate low)
- _gate_port->set_voice_value(context, voice, time, 0.0f);
+ _gate_port->set_voice_value(ctx, voice, time, 0.0f);
(*_voices)[voice].state = Voice::State::FREE;
}
}
void
-NoteNode::all_notes_off(RunContext& context, FrameTime time)
+NoteNode::all_notes_off(RunContext& ctx, FrameTime time)
{
- assert(time >= context.start() && time <= context.end());
+ assert(time >= ctx.start() && time <= ctx.end());
// FIXME: set all keys to Key::OFF?
for (uint32_t i = 0; i < _polyphony; ++i) {
- _gate_port->set_voice_value(context, i, time, 0.0f);
+ _gate_port->set_voice_value(ctx, i, time, 0.0f);
(*_voices)[i].state = Voice::State::FREE;
}
}
void
-NoteNode::sustain_on(RunContext& context, FrameTime time)
+NoteNode::sustain_on(RunContext&, FrameTime)
{
_sustain = true;
}
void
-NoteNode::sustain_off(RunContext& context, FrameTime time)
+NoteNode::sustain_off(RunContext& ctx, FrameTime time)
{
- assert(time >= context.start() && time <= context.end());
+ assert(time >= ctx.start() && time <= ctx.end());
_sustain = false;
for (uint32_t i=0; i < _polyphony; ++i) {
if ((*_voices)[i].state == Voice::State::HOLDING) {
- free_voice(context, i, time);
+ free_voice(ctx, i, time);
}
}
}
void
-NoteNode::bend(RunContext& context, FrameTime time, float amount)
+NoteNode::bend(RunContext& ctx, FrameTime time, float amount)
{
- _bend_port->set_control_value(context, time, amount);
+ _bend_port->set_control_value(ctx, time, amount);
}
void
-NoteNode::note_pressure(RunContext& context, FrameTime time, uint8_t note_num, float amount)
+NoteNode::note_pressure(RunContext& ctx, 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);
+ _pressure_port->set_voice_value(ctx, i, time, amount);
return;
}
}
}
void
-NoteNode::channel_pressure(RunContext& context, FrameTime time, float amount)
+NoteNode::channel_pressure(RunContext& ctx, FrameTime time, float amount)
{
- _pressure_port->set_control_value(context, time, amount);
+ _pressure_port->set_control_value(ctx, time, amount);
}
} // namespace internals
diff --git a/src/server/internals/Note.hpp b/src/server/internals/Note.hpp
index eed5dda7..c986a745 100644
--- a/src/server/internals/Note.hpp
+++ b/src/server/internals/Note.hpp
@@ -48,20 +48,20 @@ public:
SampleRate srate);
bool prepare_poly(BufferFactory& bufs, uint32_t poly) override;
- bool apply_poly(RunContext& context, uint32_t poly) override;
+ bool apply_poly(RunContext& ctx, uint32_t poly) override;
- void run(RunContext& context) override;
+ void run(RunContext& ctx) override;
- void note_on(RunContext& context, uint8_t note_num, uint8_t velocity, FrameTime time);
- void note_off(RunContext& context, uint8_t note_num, FrameTime time);
- void all_notes_off(RunContext& context, FrameTime time);
+ void note_on(RunContext& ctx, uint8_t note_num, uint8_t velocity, FrameTime time);
+ void note_off(RunContext& ctx, uint8_t note_num, FrameTime time);
+ void all_notes_off(RunContext& ctx, FrameTime time);
- void sustain_on(RunContext& context, FrameTime time);
- void sustain_off(RunContext& context, FrameTime time);
+ void sustain_on(RunContext& ctx, FrameTime time);
+ void sustain_off(RunContext& ctx, FrameTime time);
- void bend(RunContext& context, FrameTime time, float amount);
- void note_pressure(RunContext& context, FrameTime time, uint8_t note_num, float amount);
- void channel_pressure(RunContext& context, FrameTime time, float amount);
+ void bend(RunContext& ctx, FrameTime time, float amount);
+ void note_pressure(RunContext& ctx, FrameTime time, uint8_t note_num, float amount);
+ void channel_pressure(RunContext& ctx, FrameTime time, float amount);
static InternalPlugin* internal_plugin(URIs& uris);
@@ -86,7 +86,7 @@ private:
using Voices = Raul::Array<Voice>;
- void free_voice(RunContext& context, uint32_t voice, FrameTime time);
+ void free_voice(RunContext& ctx, uint32_t voice, FrameTime time);
MPtr<Voices> _voices;
MPtr<Voices> _prepared_voices;
diff --git a/src/server/internals/Time.cpp b/src/server/internals/Time.cpp
index a771b9a9..3f5d2d8e 100644
--- a/src/server/internals/Time.cpp
+++ b/src/server/internals/Time.cpp
@@ -59,7 +59,7 @@ TimeNode::TimeNode(InternalPlugin* plugin,
}
void
-TimeNode::run(RunContext& context)
+TimeNode::run(RunContext& ctx)
{
BufferRef buf = _notify_port->buffer(0);
auto* seq = buf->get<LV2_Atom_Sequence>();
@@ -71,8 +71,7 @@ TimeNode::run(RunContext& context)
seq->body.pad = 0;
// Ask the driver to append any time events for this cycle
- context.engine().driver()->append_time_events(
- context, *_notify_port->buffer(0));
+ ctx.engine().driver()->append_time_events(ctx, *_notify_port->buffer(0));
}
} // namespace internals
diff --git a/src/server/internals/Time.hpp b/src/server/internals/Time.hpp
index 958cd239..3cf6983d 100644
--- a/src/server/internals/Time.hpp
+++ b/src/server/internals/Time.hpp
@@ -44,7 +44,7 @@ public:
GraphImpl* parent,
SampleRate srate);
- void run(RunContext& context) override;
+ void run(RunContext& ctx) override;
static InternalPlugin* internal_plugin(URIs& uris);
diff --git a/src/server/internals/Trigger.cpp b/src/server/internals/Trigger.cpp
index 0fe5715c..df429ba6 100644
--- a/src/server/internals/Trigger.cpp
+++ b/src/server/internals/Trigger.cpp
@@ -104,14 +104,14 @@ TriggerNode::TriggerNode(InternalPlugin* plugin,
}
void
-TriggerNode::run(RunContext& context)
+TriggerNode::run(RunContext& ctx)
{
const BufferRef midi_in = _midi_in_port->buffer(0);
auto* const seq = midi_in->get<LV2_Atom_Sequence>();
const BufferRef midi_out = _midi_out_port->buffer(0);
// Initialise output to the empty sequence
- midi_out->prepare_write(context);
+ midi_out->prepare_write(ctx);
LV2_ATOM_SEQUENCE_FOREACH(seq, ev) {
const int64_t t = ev->time.frames;
@@ -120,23 +120,23 @@ TriggerNode::run(RunContext& context)
bool emit = false;
if (ev->body.type == _midi_in_port->bufs().uris().midi_MidiEvent &&
ev->body.size >= 3) {
- const FrameTime time = context.start() + t;
+ const FrameTime time = ctx.start() + t;
switch (lv2_midi_message_type(buf)) {
case LV2_MIDI_MSG_NOTE_ON:
if (buf[2] == 0) {
- emit = note_off(context, buf[1], time);
+ emit = note_off(ctx, buf[1], time);
} else {
- emit = note_on(context, buf[1], buf[2], time);
+ emit = note_on(ctx, buf[1], buf[2], time);
}
break;
case LV2_MIDI_MSG_NOTE_OFF:
- emit = note_off(context, buf[1], time);
+ emit = note_off(ctx, buf[1], time);
break;
case LV2_MIDI_MSG_CONTROLLER:
switch (buf[1]) {
case LV2_MIDI_CTL_ALL_NOTES_OFF:
case LV2_MIDI_CTL_ALL_SOUNDS_OFF:
- _gate_port->set_control_value(context, time, 0.0f);
+ _gate_port->set_control_value(ctx, time, 0.0f);
emit = true;
}
default:
@@ -151,35 +151,35 @@ TriggerNode::run(RunContext& context)
}
bool
-TriggerNode::note_on(RunContext& context, uint8_t note_num, uint8_t velocity, FrameTime time)
+TriggerNode::note_on(RunContext& ctx, uint8_t note_num, uint8_t velocity, FrameTime time)
{
- assert(time >= context.start() && time <= context.end());
- const uint32_t offset = time - context.start();
+ assert(time >= ctx.start() && time <= ctx.end());
+ const uint32_t offset = time - ctx.start();
if (_learning) {
- _note_port->set_control_value(context, time, static_cast<float>(note_num));
+ _note_port->set_control_value(ctx, time, static_cast<float>(note_num));
_note_port->force_monitor_update();
_learning = false;
}
if (note_num == lrintf(_note_port->buffer(0)->value_at(offset))) {
- _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);
+ _gate_port->set_control_value(ctx, time, 1.0f);
+ _trig_port->set_control_value(ctx, time, 1.0f);
+ _trig_port->set_control_value(ctx, time + 1, 0.0f);
+ _vel_port->set_control_value(ctx, time, velocity / 127.0f);
return true;
}
return false;
}
bool
-TriggerNode::note_off(RunContext& context, uint8_t note_num, FrameTime time)
+TriggerNode::note_off(RunContext& ctx, uint8_t note_num, FrameTime time)
{
- assert(time >= context.start() && time <= context.end());
- const uint32_t offset = time - context.start();
+ assert(time >= ctx.start() && time <= ctx.end());
+ const uint32_t offset = time - ctx.start();
if (note_num == lrintf(_note_port->buffer(0)->value_at(offset))) {
- _gate_port->set_control_value(context, time, 0.0f);
+ _gate_port->set_control_value(ctx, time, 0.0f);
return true;
}
diff --git a/src/server/internals/Trigger.hpp b/src/server/internals/Trigger.hpp
index 0508b615..17ae12e3 100644
--- a/src/server/internals/Trigger.hpp
+++ b/src/server/internals/Trigger.hpp
@@ -50,10 +50,10 @@ public:
GraphImpl* parent,
SampleRate srate);
- void run(RunContext& context) override;
+ void run(RunContext& ctx) override;
- bool note_on(RunContext& context, uint8_t note_num, uint8_t velocity, FrameTime time);
- bool note_off(RunContext& context, uint8_t note_num, FrameTime time);
+ bool note_on(RunContext& ctx, uint8_t note_num, uint8_t velocity, FrameTime time);
+ bool note_off(RunContext& ctx, uint8_t note_num, FrameTime time);
void learn() override { _learning = true; }