diff options
author | David Robillard <d@drobilla.net> | 2020-08-01 17:51:16 +0200 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2020-08-02 01:48:48 +0200 |
commit | d13e41341f687b9f526887aba7e664d71ae34aec (patch) | |
tree | 2f68f12e6c182169ad840b1710fa3e376c47ed00 /src/server/internals/Note.cpp | |
parent | 95ceaf902f95baa431cdda972c0ebb48293e2022 (diff) | |
download | ingen-d13e41341f687b9f526887aba7e664d71ae34aec.tar.gz ingen-d13e41341f687b9f526887aba7e664d71ae34aec.tar.bz2 ingen-d13e41341f687b9f526887aba7e664d71ae34aec.zip |
Use consistent naming for context parameters
Diffstat (limited to 'src/server/internals/Note.cpp')
-rw-r--r-- | src/server/internals/Note.cpp | 84 |
1 files changed, 42 insertions, 42 deletions
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 |