From d13e41341f687b9f526887aba7e664d71ae34aec Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 1 Aug 2020 17:51:16 +0200 Subject: Use consistent naming for context parameters --- src/server/BlockImpl.cpp | 42 ++++++++-------- src/server/BlockImpl.hpp | 14 +++--- src/server/Buffer.cpp | 20 ++++---- src/server/Buffer.hpp | 12 ++--- src/server/CompiledGraph.cpp | 4 +- src/server/CompiledGraph.hpp | 2 +- src/server/ControlBindings.cpp | 40 +++++++-------- src/server/ControlBindings.hpp | 14 +++--- src/server/DirectDriver.hpp | 6 +-- src/server/Driver.hpp | 7 ++- src/server/DuplexPort.cpp | 20 ++++---- src/server/DuplexPort.hpp | 8 +-- src/server/Engine.hpp | 2 +- src/server/Event.hpp | 2 +- src/server/GraphImpl.cpp | 36 +++++++------- src/server/GraphImpl.hpp | 14 +++--- src/server/InputPort.cpp | 32 ++++++------ src/server/InputPort.hpp | 12 ++--- src/server/InternalBlock.cpp | 4 +- src/server/InternalBlock.hpp | 2 +- src/server/JackDriver.cpp | 29 ++++++----- src/server/JackDriver.hpp | 10 ++-- src/server/LV2Block.cpp | 14 +++--- src/server/LV2Block.hpp | 6 +-- src/server/NodeImpl.hpp | 4 +- src/server/PortAudioDriver.cpp | 8 +-- src/server/PortAudioDriver.hpp | 10 ++-- src/server/PortImpl.cpp | 98 +++++++++++++++++++------------------ src/server/PortImpl.hpp | 24 ++++----- src/server/PostProcessor.hpp | 2 +- src/server/PreProcessor.cpp | 16 +++--- src/server/PreProcessor.hpp | 2 +- src/server/Task.cpp | 22 ++++----- src/server/Task.hpp | 6 +-- src/server/events/Connect.cpp | 6 +-- src/server/events/Connect.hpp | 2 +- src/server/events/Copy.hpp | 2 +- src/server/events/CreateBlock.hpp | 2 +- src/server/events/CreateGraph.cpp | 4 +- src/server/events/CreateGraph.hpp | 2 +- src/server/events/CreatePort.cpp | 4 +- src/server/events/CreatePort.hpp | 2 +- src/server/events/Delete.cpp | 10 ++-- src/server/events/Delete.hpp | 2 +- src/server/events/Delta.cpp | 20 ++++---- src/server/events/Delta.hpp | 2 +- src/server/events/Disconnect.cpp | 10 ++-- src/server/events/Disconnect.hpp | 4 +- src/server/events/DisconnectAll.cpp | 4 +- src/server/events/DisconnectAll.hpp | 2 +- src/server/events/Get.cpp | 5 ++ src/server/events/Get.hpp | 2 +- src/server/events/Mark.cpp | 2 +- src/server/events/Mark.hpp | 2 +- src/server/events/Move.cpp | 2 +- src/server/events/Move.hpp | 2 +- src/server/events/SetPortValue.cpp | 20 ++++---- src/server/events/SetPortValue.hpp | 4 +- src/server/events/Undo.cpp | 2 +- src/server/events/Undo.hpp | 2 +- src/server/ingen_lv2.cpp | 20 ++++---- src/server/internals/BlockDelay.cpp | 6 +-- src/server/internals/BlockDelay.hpp | 2 +- src/server/internals/Controller.cpp | 14 +++--- src/server/internals/Controller.hpp | 4 +- src/server/internals/Note.cpp | 84 +++++++++++++++---------------- src/server/internals/Note.hpp | 22 ++++----- src/server/internals/Time.cpp | 5 +- src/server/internals/Time.hpp | 2 +- src/server/internals/Trigger.cpp | 38 +++++++------- src/server/internals/Trigger.hpp | 6 +-- src/server/mix.cpp | 10 ++-- src/server/mix.hpp | 2 +- 73 files changed, 443 insertions(+), 437 deletions(-) (limited to 'src/server') diff --git a/src/server/BlockImpl.cpp b/src/server/BlockImpl.cpp index c14690b1..a723547c 100644 --- a/src/server/BlockImpl.cpp +++ b/src/server/BlockImpl.cpp @@ -123,7 +123,7 @@ BlockImpl::prepare_poly(BufferFactory& bufs, uint32_t poly) } bool -BlockImpl::apply_poly(RunContext& context, uint32_t poly) +BlockImpl::apply_poly(RunContext& ctx, uint32_t poly) { if (!_polyphonic) { poly = 1; @@ -133,7 +133,7 @@ BlockImpl::apply_poly(RunContext& context, uint32_t poly) if (_ports) { for (uint32_t i = 0; i < num_ports(); ++i) { - _ports->at(i)->apply_poly(context, poly); + _ports->at(i)->apply_poly(ctx, poly); } } @@ -141,7 +141,7 @@ BlockImpl::apply_poly(RunContext& context, uint32_t poly) } void -BlockImpl::set_buffer_size(RunContext& context, +BlockImpl::set_buffer_size(RunContext& ctx, BufferFactory& bufs, LV2_URID type, uint32_t size) @@ -150,7 +150,7 @@ BlockImpl::set_buffer_size(RunContext& context, for (uint32_t i = 0; i < _ports->size(); ++i) { PortImpl* const p = _ports->at(i); if (p->buffer_type() == type) { - p->set_buffer_size(context, bufs, size); + p->set_buffer_size(ctx, bufs, size); } } } @@ -183,18 +183,18 @@ BlockImpl::port_by_symbol(const char* symbol) } void -BlockImpl::pre_process(RunContext& context) +BlockImpl::pre_process(RunContext& ctx) { // Mix down input ports for (uint32_t i = 0; i < num_ports(); ++i) { PortImpl* const port = _ports->at(i); - port->pre_process(context); + port->pre_process(ctx); port->connect_buffers(); } } void -BlockImpl::bypass(RunContext& context) +BlockImpl::bypass(RunContext& ctx) { if (!_ports) { return; @@ -203,7 +203,7 @@ BlockImpl::bypass(RunContext& context) // Prepare port buffers for reading, converting/mixing if necessary for (uint32_t i = 0; i < _ports->size(); ++i) { _ports->at(i)->connect_buffers(); - _ports->at(i)->pre_run(context); + _ports->at(i)->pre_run(ctx); } // Dumb bypass @@ -216,7 +216,7 @@ BlockImpl::bypass(RunContext& context) } else if (in) { // Copy corresponding input to output for (uint32_t v = 0; v < _polyphony; ++v) { - out->buffer(v)->copy(context, in->buffer(v).get()); + out->buffer(v)->copy(ctx, in->buffer(v).get()); } } else { // Output but no corresponding input, clear @@ -226,29 +226,29 @@ BlockImpl::bypass(RunContext& context) } } } - post_process(context); + post_process(ctx); } void -BlockImpl::process(RunContext& context) +BlockImpl::process(RunContext& ctx) { - pre_process(context); + pre_process(ctx); if (!_enabled) { - bypass(context); - post_process(context); + bypass(ctx); + post_process(ctx); return; } - RunContext subcontext(context); - for (SampleCount offset = 0; offset < context.nframes();) { + RunContext subcontext(ctx); + for (SampleCount offset = 0; offset < ctx.nframes();) { // Find earliest offset of a value change - SampleCount chunk_end = context.nframes(); + SampleCount chunk_end = ctx.nframes(); for (uint32_t i = 0; _ports && i < _ports->size(); ++i) { PortImpl* const port = _ports->at(i); if (port->type() == PortType::CONTROL && port->is_input()) { const SampleCount o = port->next_value_offset( - offset, context.nframes()); + offset, ctx.nframes()); if (o < chunk_end) { chunk_end = o; } @@ -282,15 +282,15 @@ BlockImpl::process(RunContext& context) subcontext.slice(offset, chunk_end - offset); } - post_process(context); + post_process(ctx); } void -BlockImpl::post_process(RunContext& context) +BlockImpl::post_process(RunContext& ctx) { // Write output ports for (uint32_t i = 0; _ports && i < _ports->size(); ++i) { - _ports->at(i)->post_process(context); + _ports->at(i)->post_process(ctx); } } diff --git a/src/server/BlockImpl.hpp b/src/server/BlockImpl.hpp index 9bf3cac9..8c947e68 100644 --- a/src/server/BlockImpl.hpp +++ b/src/server/BlockImpl.hpp @@ -118,19 +118,19 @@ public: virtual void learn() {} /** Do whatever needs doing in the process thread before process() is called */ - virtual void pre_process(RunContext& context); + virtual void pre_process(RunContext& ctx); /** Run block for an entire process cycle (calls run()). */ - virtual void process(RunContext& context); + virtual void process(RunContext& ctx); /** Bypass block for an entire process cycle (called from process()). */ - virtual void bypass(RunContext& context); + virtual void bypass(RunContext& ctx); /** Run block for a portion of process cycle (called from process()). */ - virtual void run(RunContext& context) = 0; + virtual void run(RunContext& ctx) = 0; /** Do whatever needs doing in the process thread after process() is called */ - virtual void post_process(RunContext& context); + virtual void post_process(RunContext& ctx); /** Set the buffer of a port to a given buffer (e.g. connect plugin to buffer) */ virtual void set_port_buffer(uint32_t voice, @@ -161,7 +161,7 @@ public: virtual void set_polyphonic(bool p) { _polyphonic = p; } 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; /** Information about the Plugin this Block is an instance of. * Not the best name - not all blocks come from plugins (ie Graph) @@ -175,7 +175,7 @@ public: virtual void plugin(PluginImpl* pi) { _plugin = pi; } - virtual void set_buffer_size(RunContext& context, + virtual void set_buffer_size(RunContext& ctx, BufferFactory& bufs, LV2_URID type, uint32_t size); diff --git a/src/server/Buffer.cpp b/src/server/Buffer.cpp index dfcd0a71..3a09762f 100644 --- a/src/server/Buffer.cpp +++ b/src/server/Buffer.cpp @@ -127,13 +127,13 @@ Buffer::clear() } void -Buffer::render_sequence(const RunContext& context, const Buffer* src, bool add) +Buffer::render_sequence(const RunContext& ctx, const Buffer* src, bool add) { const LV2_URID atom_Float = _factory.uris().atom_Float; const auto* seq = src->get(); const auto* init = reinterpret_cast(src->value()); float value = init ? init->body : 0.0f; - SampleCount offset = context.offset(); + SampleCount offset = ctx.offset(); LV2_ATOM_SEQUENCE_FOREACH(seq, ev) { if (ev->time.frames >= offset && ev->body.type == atom_Float) { @@ -142,11 +142,11 @@ Buffer::render_sequence(const RunContext& context, const Buffer* src, bool add) offset = ev->time.frames; } } - write_block(value, offset, context.offset() + context.nframes(), add); + write_block(value, offset, ctx.offset() + ctx.nframes(), add); } void -Buffer::copy(const RunContext& context, const Buffer* src) +Buffer::copy(const RunContext& ctx, const Buffer* src) { if (!_buf) { return; @@ -160,10 +160,10 @@ Buffer::copy(const RunContext& context, const Buffer* src) } else if (src->is_audio() && is_control()) { samples()[0] = src->samples()[0]; } else if (src->is_control() && is_audio()) { - set_block(src->samples()[0], 0, context.nframes()); + set_block(src->samples()[0], 0, ctx.nframes()); } else if (src->is_sequence() && is_audio() && src->value_type() == _factory.uris().atom_Float) { - render_sequence(context, src, false); + render_sequence(ctx, src, false); } else { clear(); } @@ -222,12 +222,12 @@ mm_abs_ps(__m128 x) #endif float -Buffer::peak(const RunContext& context) const +Buffer::peak(const RunContext& ctx) const { #ifdef __SSE__ const auto* const vbuf = reinterpret_cast(samples()); __m128 vpeak = mm_abs_ps(vbuf[0]); - const SampleCount nblocks = context.nframes() / 4; + const SampleCount nblocks = ctx.nframes() / 4; // First, find the vector absolute max of the buffer for (SampleCount i = 1; i < nblocks; ++i) { @@ -431,11 +431,11 @@ Buffer::update_value_buffer(SampleCount offset) #ifndef NDEBUG void -Buffer::dump_cv(const RunContext& context) const +Buffer::dump_cv(const RunContext& ctx) const { float value = samples()[0]; fprintf(stderr, "{ 0000: %.02f\n", value); - for (uint32_t i = 0; i < context.nframes(); ++i) { + for (uint32_t i = 0; i < ctx.nframes(); ++i) { if (samples()[i] != value) { value = samples()[i]; fprintf(stderr, " %4u: %.02f\n", i, value); diff --git a/src/server/Buffer.hpp b/src/server/Buffer.hpp index c784f661..3e7eb753 100644 --- a/src/server/Buffer.hpp +++ b/src/server/Buffer.hpp @@ -56,8 +56,8 @@ public: void clear(); void resize(uint32_t capacity); - void copy(const RunContext& context, const Buffer* src); - void prepare_write(RunContext& context); + void copy(const RunContext& ctx, const Buffer* src); + void prepare_write(RunContext& ctx); void* port_data(PortType port_type, SampleCount offset); const void* port_data(PortType port_type, SampleCount offset) const; @@ -169,10 +169,10 @@ public: } /// Audio buffers only - float peak(const RunContext& context) const; + float peak(const RunContext& ctx) const; /// Sequence buffers only - void prepare_output_write(RunContext& context); + void prepare_output_write(RunContext& ctx); /// Sequence buffers only bool append_event(int64_t frames, @@ -202,10 +202,10 @@ public: void update_value_buffer(SampleCount offset); /// Set/add to audio buffer from the Sequence of Float in `src` - void render_sequence(const RunContext& context, const Buffer* src, bool add); + void render_sequence(const RunContext& ctx, const Buffer* src, bool add); #ifndef NDEBUG - void dump_cv(const RunContext& context) const; + void dump_cv(const RunContext& ctx) const; #endif void set_capacity(uint32_t capacity) { _capacity = capacity; } diff --git a/src/server/CompiledGraph.cpp b/src/server/CompiledGraph.cpp index b9841191..dbd8b062 100644 --- a/src/server/CompiledGraph.cpp +++ b/src/server/CompiledGraph.cpp @@ -258,9 +258,9 @@ CompiledGraph::compile_block(BlockImpl* n, } void -CompiledGraph::run(RunContext& context) +CompiledGraph::run(RunContext& ctx) { - _master->run(context); + _master->run(ctx); } void diff --git a/src/server/CompiledGraph.hpp b/src/server/CompiledGraph.hpp index 959fb18e..d2815bff 100644 --- a/src/server/CompiledGraph.hpp +++ b/src/server/CompiledGraph.hpp @@ -46,7 +46,7 @@ class CompiledGraph : public Raul::Maid::Disposable public: static MPtr compile(Raul::Maid& maid, GraphImpl& graph); - void run(RunContext& context); + void run(RunContext& ctx); private: friend class Raul::Maid; ///< Allow make_managed to construct diff --git a/src/server/ControlBindings.cpp b/src/server/ControlBindings.cpp index 4664b590..75acd7b2 100644 --- a/src/server/ControlBindings.cpp +++ b/src/server/ControlBindings.cpp @@ -220,18 +220,18 @@ ControlBindings::start_learn(PortImpl* port) } static void -get_range(RunContext& context, const PortImpl* port, float* min, float* max) +get_range(RunContext& ctx, const PortImpl* port, float* min, float* max) { *min = port->minimum().get(); *max = port->maximum().get(); if (port->is_sample_rate()) { - *min *= context.engine().sample_rate(); - *max *= context.engine().sample_rate(); + *min *= ctx.engine().sample_rate(); + *max *= ctx.engine().sample_rate(); } } float -ControlBindings::control_to_port_value(RunContext& context, +ControlBindings::control_to_port_value(RunContext& ctx, const PortImpl* port, Type type, int16_t value) @@ -258,13 +258,13 @@ ControlBindings::control_to_port_value(RunContext& context, float min = 0.0f; float max = 1.0f; - get_range(context, port, &min, &max); + get_range(ctx, port, &min, &max); return normal * (max - min) + min; } int16_t -ControlBindings::port_value_to_control(RunContext& context, +ControlBindings::port_value_to_control(RunContext& ctx, PortImpl* port, Type type, const Atom& value_atom) @@ -275,7 +275,7 @@ ControlBindings::port_value_to_control(RunContext& context, float min = 0.0f; float max = 1.0f; - get_range(context, port, &min, &max); + get_range(ctx, port, &min, &max); const float value = value_atom.get(); float normal = (value - min) / (max - min); @@ -337,29 +337,29 @@ forge_binding(const URIs& uris, } void -ControlBindings::set_port_value(RunContext& context, +ControlBindings::set_port_value(RunContext& ctx, PortImpl* port, Type type, int16_t value) const { float min = 0.0f; float max = 1.0f; - get_range(context, port, &min, &max); + get_range(ctx, port, &min, &max); - const float val = control_to_port_value(context, port, type, value); + const float val = control_to_port_value(ctx, port, type, value); // TODO: Set port value property so it is saved - port->set_control_value(context, context.start(), val); + port->set_control_value(ctx, ctx.start(), val); - URIs& uris = context.engine().world().uris(); - context.notify(uris.ingen_value, context.start(), port, - sizeof(float), _forge.Float, &val); + URIs& uris = ctx.engine().world().uris(); + ctx.notify(uris.ingen_value, ctx.start(), port, + sizeof(float), _forge.Float, &val); } bool -ControlBindings::finish_learn(RunContext& context, Key key) +ControlBindings::finish_learn(RunContext& ctx, Key key) { - const ingen::URIs& uris = context.engine().world().uris(); + const ingen::URIs& uris = ctx.engine().world().uris(); Binding* binding = _learn_binding.exchange(nullptr); if (!binding || (key.type == Type::MIDI_NOTE && !binding->port->is_toggled())) { return false; @@ -373,10 +373,10 @@ ControlBindings::finish_learn(RunContext& context, Key key) lv2_atom_forge_set_buffer(&_forge, reinterpret_cast(buf), sizeof(buf)); forge_binding(uris, &_forge, key.type, key.num); const LV2_Atom* atom = buf; - context.notify(uris.midi_binding, - context.start(), - binding->port, - atom->size, atom->type, LV2_ATOM_BODY_CONST(atom)); + ctx.notify(uris.midi_binding, + ctx.start(), + binding->port, + atom->size, atom->type, LV2_ATOM_BODY_CONST(atom)); return true; } diff --git a/src/server/ControlBindings.hpp b/src/server/ControlBindings.hpp index 7505aad8..8fff58ce 100644 --- a/src/server/ControlBindings.hpp +++ b/src/server/ControlBindings.hpp @@ -125,19 +125,19 @@ private: static Key midi_event_key(uint16_t size, const uint8_t* buf, uint16_t& value); - void set_port_value(RunContext& context, + void set_port_value(RunContext& ctx, PortImpl* port, Type type, int16_t value) const; - bool finish_learn(RunContext& context, Key key); + bool finish_learn(RunContext& ctx, Key key); - static float control_to_port_value(RunContext& context, - const PortImpl* port, - Type type, - int16_t value); + static float control_to_port_value(RunContext& ctx, + const PortImpl* port, + Type type, + int16_t value); - static int16_t port_value_to_control(RunContext& context, + static int16_t port_value_to_control(RunContext& ctx, PortImpl* port, Type type, const Atom& value_atom); diff --git a/src/server/DirectDriver.hpp b/src/server/DirectDriver.hpp index bb949a14..119c2d27 100644 --- a/src/server/DirectDriver.hpp +++ b/src/server/DirectDriver.hpp @@ -60,11 +60,11 @@ public: return nullptr; } - void add_port(RunContext& context, EnginePort* port) override { + void add_port(RunContext&, EnginePort* port) override { _ports.push_back(*port); } - void remove_port(RunContext& context, EnginePort* port) override { + void remove_port(RunContext&, EnginePort* port) override { _ports.erase(_ports.iterator_to(*port)); } @@ -88,7 +88,7 @@ public: return _engine.run_context().start(); } - void append_time_events(RunContext& context, Buffer& buffer) override {} + void append_time_events(RunContext&, Buffer&) override {} int real_time_priority() override { return 60; } diff --git a/src/server/Driver.hpp b/src/server/Driver.hpp index 4da04a55..92867021 100644 --- a/src/server/Driver.hpp +++ b/src/server/Driver.hpp @@ -56,7 +56,7 @@ public: virtual EnginePort* get_port(const Raul::Path& path) = 0; /** Add a system visible port (e.g. a port on the root graph). */ - virtual void add_port(RunContext& context, EnginePort* port) = 0; + virtual void add_port(RunContext& ctx, EnginePort* port) = 0; /** Remove a system visible port. * @@ -64,7 +64,7 @@ public: * destroy the port. To actually remove the system port, unregister_port() * must be called later in another thread. */ - virtual void remove_port(RunContext& context, EnginePort* port) = 0; + virtual void remove_port(RunContext& ctx, EnginePort* port) = 0; /** Return true iff driver supports dynamic adding/removing of ports. */ virtual bool dynamic_ports() const { return false; } @@ -97,8 +97,7 @@ public: virtual SampleCount frame_time() const = 0; /** Append time events for this cycle to `buffer`. */ - virtual void append_time_events(RunContext& context, - Buffer& buffer) = 0; + virtual void append_time_events(RunContext& ctx, Buffer& buffer) = 0; /** Return the real-time priority of the audio thread, or -1. */ virtual int real_time_priority() = 0; diff --git a/src/server/DuplexPort.cpp b/src/server/DuplexPort.cpp index bc827b54..7ba466a7 100644 --- a/src/server/DuplexPort.cpp +++ b/src/server/DuplexPort.cpp @@ -201,46 +201,46 @@ DuplexPort::prepare_poly(BufferFactory& bufs, uint32_t poly) } bool -DuplexPort::apply_poly(RunContext& context, uint32_t poly) +DuplexPort::apply_poly(RunContext& ctx, uint32_t poly) { if (!parent()->parent() || poly != parent()->parent_graph()->internal_poly()) { return false; } - return PortImpl::apply_poly(context, poly); + return PortImpl::apply_poly(ctx, poly); } void -DuplexPort::pre_process(RunContext& context) +DuplexPort::pre_process(RunContext& ctx) { if (_is_output) { /* This is a graph output, which is an input from the internal perspective. Prepare buffers for write so plugins can deliver to them */ for (uint32_t v = 0; v < _poly; ++v) { - _voices->at(v).buffer->prepare_write(context); + _voices->at(v).buffer->prepare_write(ctx); } } else { /* This is a a graph input, which is an output from the internal perspective. Do whatever a normal block's input port does to prepare input for reading. */ - InputPort::pre_process(context); - InputPort::pre_run(context); + InputPort::pre_process(ctx); + InputPort::pre_run(ctx); } } void -DuplexPort::post_process(RunContext& context) +DuplexPort::post_process(RunContext& ctx) { if (_is_output) { /* This is a graph output, which is an input from the internal perspective. Mix down input delivered by plugins so output (external perspective) is ready. */ - InputPort::pre_process(context); - InputPort::pre_run(context); + InputPort::pre_process(ctx); + InputPort::pre_run(ctx); } - monitor(context); + monitor(ctx); } SampleCount diff --git a/src/server/DuplexPort.hpp b/src/server/DuplexPort.hpp index 6b3d0ae6..075c7aba 100644 --- a/src/server/DuplexPort.hpp +++ b/src/server/DuplexPort.hpp @@ -81,11 +81,11 @@ public: void on_property(const URI& uri, const Atom& value) override; - uint32_t max_tail_poly(RunContext& context) const override; + uint32_t max_tail_poly(RunContext& ctx) const override; 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; bool get_buffers(BufferFactory& bufs, PortImpl::GetFn get, @@ -105,8 +105,8 @@ public: bool setup_buffers(RunContext& ctx, BufferFactory& bufs, uint32_t poly) override; - void pre_process(RunContext& context) override; - void post_process(RunContext& context) override; + void pre_process(RunContext& ctx) override; + void post_process(RunContext& ctx) override; SampleCount next_value_offset(SampleCount offset, SampleCount end) const override; diff --git a/src/server/Engine.hpp b/src/server/Engine.hpp index 45379ad1..c62a8d94 100644 --- a/src/server/Engine.hpp +++ b/src/server/Engine.hpp @@ -114,7 +114,7 @@ public: * * This value is comparable to the value returned by current_time(). */ - inline uint64_t cycle_start_time(const RunContext& context) const { + inline uint64_t cycle_start_time(const RunContext&) const { return _cycle_start_time; } diff --git a/src/server/Event.hpp b/src/server/Event.hpp index a8d6979b..8fc71be1 100644 --- a/src/server/Event.hpp +++ b/src/server/Event.hpp @@ -69,7 +69,7 @@ public: virtual bool pre_process(PreProcessContext& ctx) = 0; /** Execute this event in the audio thread (realtime). */ - virtual void execute(RunContext& context) = 0; + virtual void execute(RunContext& ctx) = 0; /** Post-process event after execution (non-realtime). */ virtual void post_process() = 0; diff --git a/src/server/GraphImpl.cpp b/src/server/GraphImpl.cpp index 502b5465..a494293d 100644 --- a/src/server/GraphImpl.cpp +++ b/src/server/GraphImpl.cpp @@ -157,11 +157,11 @@ GraphImpl::deactivate() } void -GraphImpl::disable(RunContext& context) +GraphImpl::disable(RunContext& ctx) { _process = false; for (auto& o : _outputs) { - o.clear_buffers(context); + o.clear_buffers(ctx); } } @@ -181,7 +181,7 @@ GraphImpl::prepare_internal_poly(BufferFactory& bufs, uint32_t poly) } bool -GraphImpl::apply_internal_poly(RunContext& context, +GraphImpl::apply_internal_poly(RunContext& ctx, BufferFactory& bufs, Raul::Maid&, uint32_t poly) @@ -189,14 +189,14 @@ GraphImpl::apply_internal_poly(RunContext& context, // TODO: Subgraph dynamic polyphony (i.e. changing port polyphony) for (auto& b : _blocks) { - b.apply_poly(context, poly); + b.apply_poly(ctx, poly); } for (auto& b : _blocks) { for (uint32_t j = 0; j < b.num_ports(); ++j) { PortImpl* const port = b.port_impl(j); if (port->is_input() && dynamic_cast(port)->direct_connect()) { - port->setup_buffers(context, bufs, port->poly()); + port->setup_buffers(ctx, bufs, port->poly()); } port->connect_buffers(); } @@ -204,7 +204,7 @@ GraphImpl::apply_internal_poly(RunContext& context, const bool polyphonic = parent_graph() && (poly == parent_graph()->internal_poly_process()); for (auto& o : _outputs) { - o.setup_buffers(context, bufs, polyphonic ? poly : 1); + o.setup_buffers(ctx, bufs, polyphonic ? poly : 1); } _poly_process = poly; @@ -212,52 +212,52 @@ GraphImpl::apply_internal_poly(RunContext& context, } void -GraphImpl::pre_process(RunContext& context) +GraphImpl::pre_process(RunContext& ctx) { // Mix down input ports and connect buffers for (uint32_t i = 0; i < num_ports(); ++i) { PortImpl* const port = _ports->at(i); if (!port->is_driver_port()) { - port->pre_process(context); - port->pre_run(context); + port->pre_process(ctx); + port->pre_run(ctx); port->connect_buffers(); } } } void -GraphImpl::process(RunContext& context) +GraphImpl::process(RunContext& ctx) { if (!_process) { return; } - pre_process(context); - run(context); - post_process(context); + pre_process(ctx); + run(ctx); + post_process(ctx); } void -GraphImpl::run(RunContext& context) +GraphImpl::run(RunContext& ctx) { if (_compiled_graph) { - _compiled_graph->run(context); + _compiled_graph->run(ctx); } } void -GraphImpl::set_buffer_size(RunContext& context, +GraphImpl::set_buffer_size(RunContext& ctx, BufferFactory& bufs, LV2_URID type, uint32_t size) { - BlockImpl::set_buffer_size(context, bufs, type, size); + BlockImpl::set_buffer_size(ctx, bufs, type, size); if (_compiled_graph) { // FIXME // for (size_t i = 0; i < _compiled_graph->size(); ++i) { // const CompiledBlock& block = (*_compiled_graph)[i]; - // block.block()->set_buffer_size(context, bufs, type, size); + // block.block()->set_buffer_size(ctx, bufs, type, size); // } } } diff --git a/src/server/GraphImpl.hpp b/src/server/GraphImpl.hpp index 04e3ea99..ccd11013 100644 --- a/src/server/GraphImpl.hpp +++ b/src/server/GraphImpl.hpp @@ -68,11 +68,11 @@ public: void activate(BufferFactory& bufs) override; void deactivate() override; - void pre_process(RunContext& context) override; - void process(RunContext& context) override; - void run(RunContext& context) override; + void pre_process(RunContext& ctx) override; + void process(RunContext& ctx) override; + void run(RunContext& ctx) override; - void set_buffer_size(RunContext& context, + void set_buffer_size(RunContext& ctx, BufferFactory& bufs, LV2_URID type, uint32_t size) override; @@ -88,12 +88,12 @@ public: * * Audio thread. * - * \param context Process context + * \param ctx Process context * \param bufs New set of buffers * \param poly Must be < the most recent value passed to prepare_internal_poly. * \param maid Any objects no longer needed will be pushed to this */ - bool apply_internal_poly(RunContext& context, + bool apply_internal_poly(RunContext& ctx, BufferFactory& bufs, Raul::Maid& maid, uint32_t poly); @@ -178,7 +178,7 @@ public: /** Whether to run this graph's DSP bits in the audio thread */ bool enabled() const { return _process; } void enable() { _process = true; } - void disable(RunContext& context); + void disable(RunContext& ctx); uint32_t internal_poly() const { return _poly_pre; } uint32_t internal_poly_process() const { return _poly_process; } diff --git a/src/server/InputPort.cpp b/src/server/InputPort.cpp index 15df4d60..d238398a 100644 --- a/src/server/InputPort.cpp +++ b/src/server/InputPort.cpp @@ -57,9 +57,9 @@ InputPort::InputPort(BufferFactory& bufs, } bool -InputPort::apply_poly(RunContext& context, const uint32_t poly) +InputPort::apply_poly(RunContext& ctx, const uint32_t poly) { - const bool ret = PortImpl::apply_poly(context, poly); + const bool ret = PortImpl::apply_poly(ctx, poly); (void)ret; assert(_voices->size() >= (ret ? poly : 1)); @@ -144,37 +144,37 @@ InputPort::max_tail_poly(RunContext&) const } void -InputPort::pre_process(RunContext& context) +InputPort::pre_process(RunContext& ctx) { if (_arcs.empty()) { // No incoming arcs, just handle user-set value for (uint32_t v = 0; v < _poly; ++v) { // Update set state - update_set_state(context, v); + update_set_state(ctx, v); // Prepare for write in case a set event executes this cycle if (!_parent->is_main()) { - buffer(v)->prepare_write(context); + buffer(v)->prepare_write(ctx); } } } else if (direct_connect()) { // Directly connected, use source's buffer directly for (uint32_t v = 0; v < _poly; ++v) { - _voices->at(v).buffer = _arcs.front().buffer(context, v); + _voices->at(v).buffer = _arcs.front().buffer(ctx, v); } } else { // Mix down to local buffers in pre_run() for (uint32_t v = 0; v < _poly; ++v) { - buffer(v)->prepare_write(context); + buffer(v)->prepare_write(ctx); } } } void -InputPort::pre_run(RunContext& context) +InputPort::pre_run(RunContext& ctx) { if ((_user_buffer || !_arcs.empty()) && !direct_connect()) { - const uint32_t src_poly = max_tail_poly(context); + const uint32_t src_poly = max_tail_poly(ctx); const uint32_t max_n_srcs = _arcs.size() * src_poly + 1; for (uint32_t v = 0; v < _poly; ++v) { @@ -196,24 +196,24 @@ InputPort::pre_run(RunContext& context) // P -> 1 or 1 -> 1: all tail voices => each head voice for (uint32_t w = 0; w < arc.tail()->poly(); ++w) { assert(n_srcs < max_n_srcs); - srcs[n_srcs++] = arc.buffer(context, w).get(); + srcs[n_srcs++] = arc.buffer(ctx, w).get(); assert(srcs[n_srcs - 1]); } } else { // P -> P or 1 -> P: tail voice => corresponding head voice assert(n_srcs < max_n_srcs); - srcs[n_srcs++] = arc.buffer(context, v).get(); + srcs[n_srcs++] = arc.buffer(ctx, v).get(); assert(srcs[n_srcs - 1]); } } // Then mix them into our buffer for this voice - mix(context, buffer(v).get(), srcs, n_srcs); - update_values(context.offset(), v); + mix(ctx, buffer(v).get(), srcs, n_srcs); + update_values(ctx.offset(), v); } } else if (is_a(PortType::CONTROL)) { for (uint32_t v = 0; v < _poly; ++v) { - update_values(context.offset(), v); + update_values(ctx.offset(), v); } } } @@ -238,10 +238,10 @@ InputPort::next_value_offset(SampleCount offset, SampleCount end) const } void -InputPort::post_process(RunContext& context) +InputPort::post_process(RunContext& ctx) { if (!_arcs.empty() || _force_monitor_update) { - monitor(context, _force_monitor_update); + monitor(ctx, _force_monitor_update); _force_monitor_update = false; } diff --git a/src/server/InputPort.hpp b/src/server/InputPort.hpp index 35ddb2b9..dfe8b92a 100644 --- a/src/server/InputPort.hpp +++ b/src/server/InputPort.hpp @@ -72,9 +72,9 @@ public: boost::intrusive::constant_time_size>; /** Return the maximum polyphony of an output connected to this input. */ - virtual uint32_t max_tail_poly(RunContext& context) const; + virtual uint32_t max_tail_poly(RunContext& ctx) const; - bool apply_poly(RunContext& context, uint32_t poly) override; + bool apply_poly(RunContext& ctx, uint32_t poly) override; /** Add an arc. Realtime safe. * @@ -83,7 +83,7 @@ public: * * setup_buffers() must be called later for the change to take effect. */ - void add_arc(RunContext& context, ArcImpl& c); + void add_arc(RunContext& ctx, ArcImpl& c); /** Remove an arc. Realtime safe. * @@ -105,13 +105,13 @@ public: setup_buffers(RunContext& ctx, BufferFactory& bufs, uint32_t poly) override; /** Set up buffer pointers. */ - void pre_process(RunContext& context) override; + void pre_process(RunContext& ctx) override; /** Prepare buffer for access, mixing if necessary. */ - void pre_run(RunContext& context) override; + void pre_run(RunContext& ctx) override; /** Prepare buffer for next process cycle. */ - void post_process(RunContext& context) override; + void post_process(RunContext& ctx) override; SampleCount next_value_offset(SampleCount offset, SampleCount end) const override; diff --git a/src/server/InternalBlock.cpp b/src/server/InternalBlock.cpp index 3cea7698..4aa4cff2 100644 --- a/src/server/InternalBlock.cpp +++ b/src/server/InternalBlock.cpp @@ -70,12 +70,12 @@ InternalBlock::duplicate(Engine& engine, } void -InternalBlock::pre_process(RunContext& context) +InternalBlock::pre_process(RunContext& ctx) { for (uint32_t i = 0; i < num_ports(); ++i) { PortImpl* const port = _ports->at(i); if (port->is_input()) { - port->pre_process(context); + port->pre_process(ctx); } else if (port->buffer_type() == _plugin->uris().atom_Sequence) { /* Output sequences are initialized in LV2 format, an atom:Chunk with size set to the capacity of the buffer. Internal nodes diff --git a/src/server/InternalBlock.hpp b/src/server/InternalBlock.hpp index e7f0ca95..7e2e3fed 100644 --- a/src/server/InternalBlock.hpp +++ b/src/server/InternalBlock.hpp @@ -44,7 +44,7 @@ public: const Raul::Symbol& symbol, GraphImpl* parent) override; - void pre_process(RunContext& context) override; + void pre_process(RunContext& ctx) override; }; } // namespace server diff --git a/src/server/JackDriver.cpp b/src/server/JackDriver.cpp index 852e23ae..1e27207b 100644 --- a/src/server/JackDriver.cpp +++ b/src/server/JackDriver.cpp @@ -221,13 +221,13 @@ JackDriver::get_port(const Raul::Path& path) } void -JackDriver::add_port(RunContext& context, EnginePort* port) +JackDriver::add_port(RunContext& ctx, EnginePort* port) { _ports.push_back(*port); DuplexPort* graph_port = port->graph_port(); if (graph_port->is_a(PortType::AUDIO) || graph_port->is_a(PortType::CV)) { - const SampleCount nframes = context.nframes(); + const SampleCount nframes = ctx.nframes(); auto* jport = static_cast(port->handle()); void* jbuf = jack_port_get_buffer(jport, nframes); @@ -240,7 +240,7 @@ JackDriver::add_port(RunContext& context, EnginePort* port) } void -JackDriver::remove_port(RunContext& context, EnginePort* port) +JackDriver::remove_port(RunContext&, EnginePort* port) { _ports.erase(_ports.iterator_to(*port)); } @@ -356,10 +356,10 @@ JackDriver::create_port(DuplexPort* graph_port) } void -JackDriver::pre_process_port(RunContext& context, EnginePort* port) +JackDriver::pre_process_port(RunContext& ctx, EnginePort* port) { - const URIs& uris = context.engine().world().uris(); - const SampleCount nframes = context.nframes(); + const URIs& uris = ctx.engine().world().uris(); + const SampleCount nframes = ctx.nframes(); auto* jack_port = static_cast(port->handle()); DuplexPort* graph_port = port->graph_port(); Buffer* graph_buf = graph_port->buffer(0).get(); @@ -368,12 +368,12 @@ JackDriver::pre_process_port(RunContext& context, EnginePort* port) if (graph_port->is_a(PortType::AUDIO) || graph_port->is_a(PortType::CV)) { graph_port->set_driver_buffer(jack_buf, nframes * sizeof(float)); if (graph_port->is_input()) { - graph_port->monitor(context); + graph_port->monitor(ctx); } else { graph_port->buffer(0)->clear(); // TODO: Avoid when possible } } else if (graph_port->buffer_type() == uris.atom_Sequence) { - graph_buf->prepare_write(context); + graph_buf->prepare_write(ctx); if (graph_port->is_input()) { // Copy events from Jack port buffer into graph port buffer const jack_nframes_t event_count = jack_midi_get_event_count(jack_buf); @@ -386,15 +386,15 @@ JackDriver::pre_process_port(RunContext& context, EnginePort* port) } } } - graph_port->monitor(context); + graph_port->monitor(ctx); } } void -JackDriver::post_process_port(RunContext& context, EnginePort* port) const +JackDriver::post_process_port(RunContext& ctx, EnginePort* port) const { - const URIs& uris = context.engine().world().uris(); - const SampleCount nframes = context.nframes(); + const URIs& uris = ctx.engine().world().uris(); + const SampleCount nframes = ctx.nframes(); auto* jack_port = static_cast(port->handle()); DuplexPort* graph_port = port->graph_port(); void* jack_buf = port->buffer(); @@ -431,10 +431,9 @@ JackDriver::post_process_port(RunContext& context, EnginePort* port) const } void -JackDriver::append_time_events(RunContext& context, - Buffer& buffer) +JackDriver::append_time_events(RunContext& ctx, Buffer& buffer) { - const URIs& uris = context.engine().world().uris(); + const URIs& uris = ctx.engine().world().uris(); const jack_position_t* pos = &_position; const bool rolling = (_transport_state == JackTransportRolling); diff --git a/src/server/JackDriver.hpp b/src/server/JackDriver.hpp index fa71779c..1e21442a 100644 --- a/src/server/JackDriver.hpp +++ b/src/server/JackDriver.hpp @@ -76,8 +76,8 @@ public: void rename_port(const Raul::Path& old_path, const Raul::Path& new_path) override; void port_property(const Raul::Path& path, const URI& uri, const Atom& value) override; - void add_port(RunContext& context, EnginePort* port) override; - void remove_port(RunContext& context, EnginePort* port) override; + void add_port(RunContext& ctx, EnginePort* port) override; + void remove_port(RunContext& ctx, EnginePort* port) override; void register_port(EnginePort& port) override; void unregister_port(EnginePort& port) override; @@ -86,7 +86,7 @@ public: inline const jack_position_t* position() { return &_position; } inline jack_transport_state_t transport_state() { return _transport_state; } - void append_time_events(RunContext& context, Buffer& buffer) override; + void append_time_events(RunContext& ctx, Buffer& buffer) override; int real_time_priority() override { return jack_client_real_time_priority(_client); @@ -124,8 +124,8 @@ private: } #endif - void pre_process_port(RunContext& context, EnginePort* port); - void post_process_port(RunContext& context, EnginePort* port) const; + void pre_process_port(RunContext& ctx, EnginePort* port); + void post_process_port(RunContext& ctx, EnginePort* port) const; void port_property_internal(const jack_port_t* jport, const URI& uri, diff --git a/src/server/LV2Block.cpp b/src/server/LV2Block.cpp index d82ef595..bc6561d3 100644 --- a/src/server/LV2Block.cpp +++ b/src/server/LV2Block.cpp @@ -197,7 +197,7 @@ LV2Block::prepare_poly(BufferFactory& bufs, uint32_t poly) } bool -LV2Block::apply_poly(RunContext& context, uint32_t poly) +LV2Block::apply_poly(RunContext& ctx, uint32_t poly) { if (!_polyphonic) { poly = 1; @@ -208,7 +208,7 @@ LV2Block::apply_poly(RunContext& context, uint32_t poly) } assert(poly <= _instances->size()); - return BlockImpl::apply_poly(context, poly); + return BlockImpl::apply_poly(ctx, poly); } /** Instantiate self from LV2 plugin descriptor. @@ -583,15 +583,15 @@ LV2Block::work(uint32_t size, const void* data) } void -LV2Block::run(RunContext& context) +LV2Block::run(RunContext& ctx) { for (uint32_t i = 0; i < _polyphony; ++i) { - lilv_instance_run(instance(i), context.nframes()); + lilv_instance_run(instance(i), ctx.nframes()); } } void -LV2Block::post_process(RunContext& context) +LV2Block::post_process(RunContext& ctx) { /* Handle any worker responses. Note that this may write to output ports, so must be done first to prevent clobbering worker responses and @@ -602,7 +602,7 @@ LV2Block::post_process(RunContext& context) Response& r = _responses.front(); _worker_iface->work_response(inst, r.size, r.data); _responses.pop_front(); - context.engine().maid()->dispose(&r); + ctx.engine().maid()->dispose(&r); } if (_worker_iface->end_run) { @@ -611,7 +611,7 @@ LV2Block::post_process(RunContext& context) } /* Run cycle truly finished, finalise output ports. */ - BlockImpl::post_process(context); + BlockImpl::post_process(ctx); } LilvState* diff --git a/src/server/LV2Block.hpp b/src/server/LV2Block.hpp index e935ade1..eee2443d 100644 --- a/src/server/LV2Block.hpp +++ b/src/server/LV2Block.hpp @@ -68,15 +68,15 @@ public: GraphImpl* parent) override; 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 activate(BufferFactory& bufs) override; void deactivate() override; LV2_Worker_Status work(uint32_t size, const void* data); - void run(RunContext& context) override; - void post_process(RunContext& context) override; + void run(RunContext& ctx) override; + void post_process(RunContext& ctx) override; LilvState* load_preset(const URI& uri) override; diff --git a/src/server/NodeImpl.hpp b/src/server/NodeImpl.hpp index 1b73e792..6a61c852 100644 --- a/src/server/NodeImpl.hpp +++ b/src/server/NodeImpl.hpp @@ -78,10 +78,10 @@ public: /** Apply a new (external) polyphony value. * - * \param context Process context (process thread only). + * \param ctx Process context (process thread only). * \param poly Must be <= the most recent value passed to prepare_poly. */ - virtual bool apply_poly(RunContext& context, uint32_t poly) = 0; + virtual bool apply_poly(RunContext& ctx, uint32_t poly) = 0; /** Return true iff this is main (the top level Node). * diff --git a/src/server/PortAudioDriver.cpp b/src/server/PortAudioDriver.cpp index 91ed73f7..98490f76 100644 --- a/src/server/PortAudioDriver.cpp +++ b/src/server/PortAudioDriver.cpp @@ -171,13 +171,13 @@ PortAudioDriver::get_port(const Raul::Path& path) } void -PortAudioDriver::add_port(RunContext& context, EnginePort* port) +PortAudioDriver::add_port(RunContext&, EnginePort* port) { _ports.push_back(*port); } void -PortAudioDriver::remove_port(RunContext& context, EnginePort* port) +PortAudioDriver::remove_port(RunContext&, EnginePort* port) { _ports.erase(_ports.iterator_to(*port)); } @@ -235,7 +235,7 @@ PortAudioDriver::create_port(DuplexPort* graph_port) } void -PortAudioDriver::pre_process_port(RunContext& context, +PortAudioDriver::pre_process_port(RunContext&, EnginePort* port, const void* inputs, void* outputs) @@ -261,7 +261,7 @@ PortAudioDriver::pre_process_port(RunContext& context, } void -PortAudioDriver::post_process_port(RunContext& context, +PortAudioDriver::post_process_port(RunContext&, EnginePort* port, const void* inputs, void* outputs) diff --git a/src/server/PortAudioDriver.hpp b/src/server/PortAudioDriver.hpp index 3b7c6a94..94fd29b9 100644 --- a/src/server/PortAudioDriver.hpp +++ b/src/server/PortAudioDriver.hpp @@ -63,12 +63,12 @@ public: void rename_port(const Raul::Path& old_path, const Raul::Path& new_path) override; void port_property(const Raul::Path& path, const URI& uri, const Atom& value) override; - void add_port(RunContext& context, EnginePort* port) override; - void remove_port(RunContext& context, EnginePort* port) override; + void add_port(RunContext& ctx, EnginePort* port) override; + void remove_port(RunContext& ctx, EnginePort* port) override; void register_port(EnginePort& port) override; void unregister_port(EnginePort& port) override; - void append_time_events(RunContext& context, Buffer& buffer) override {} + void append_time_events(RunContext& ctx, Buffer& buffer) override {} SampleCount frame_time() const override; @@ -98,12 +98,12 @@ private: const PaStreamCallbackTimeInfo* time, PaStreamCallbackFlags flags); - void pre_process_port(RunContext& context, + void pre_process_port(RunContext& ctx, EnginePort* port, const void* inputs, void* outputs); - void post_process_port(RunContext& context, + void post_process_port(RunContext& ctx, EnginePort* port, const void* inputs, void* outputs); diff --git a/src/server/PortImpl.cpp b/src/server/PortImpl.cpp index 0fa389e6..ae7281dd 100644 --- a/src/server/PortImpl.cpp +++ b/src/server/PortImpl.cpp @@ -230,18 +230,18 @@ PortImpl::cache_properties() } void -PortImpl::set_control_value(const RunContext& context, +PortImpl::set_control_value(const RunContext& ctx, FrameTime time, Sample value) { for (uint32_t v = 0; v < _poly; ++v) { - update_set_state(context, v); - set_voice_value(context, v, time, value); + update_set_state(ctx, v); + set_voice_value(ctx, v, time, value); } } void -PortImpl::set_voice_value(const RunContext& context, +PortImpl::set_voice_value(const RunContext& ctx, uint32_t voice, FrameTime time, Sample value) @@ -253,35 +253,35 @@ PortImpl::set_voice_value(const RunContext& context, reinterpret_cast(buffer(voice)->value())) ->body = value; } - _voices->at(voice).set_state.set(context, context.start(), value); + _voices->at(voice).set_state.set(ctx, ctx.start(), value); break; case PortType::AUDIO: case PortType::CV: { // Time may be at end so internal blocks can set triggers - assert(time >= context.start()); - assert(time <= context.start() + context.nframes()); + assert(time >= ctx.start()); + assert(time <= ctx.start() + ctx.nframes()); - const FrameTime offset = time - context.start(); - if (offset < context.nframes()) { - buffer(voice)->set_block(value, offset, context.nframes()); + const FrameTime offset = time - ctx.start(); + if (offset < ctx.nframes()) { + buffer(voice)->set_block(value, offset, ctx.nframes()); } /* else, this is a set at context.nframes(), used to reset a CV port's value for the next block, particularly for triggers on the last frame of a block (set nframes-1 to 1, then nframes to 0). */ - _voices->at(voice).set_state.set(context, time, value); + _voices->at(voice).set_state.set(ctx, time, value); } break; case PortType::ATOM: if (buffer(voice)->is_sequence()) { - const FrameTime offset = time - context.start(); + const FrameTime offset = time - ctx.start(); // Same deal as above - if (offset < context.nframes()) { + if (offset < ctx.nframes()) { buffer(voice)->append_event(offset, sizeof(value), _bufs.uris().atom_Float, reinterpret_cast(&value)); } - _voices->at(voice).set_state.set(context, time, value); + _voices->at(voice).set_state.set(ctx, time, value); } else { #ifndef NDEBUG fprintf(stderr, @@ -295,7 +295,7 @@ PortImpl::set_voice_value(const RunContext& context, } void -PortImpl::update_set_state(const RunContext& context, uint32_t v) +PortImpl::update_set_state(const RunContext& ctx, uint32_t v) { Voice& voice = _voices->at(v); SetState& state = voice.set_state; @@ -304,12 +304,12 @@ PortImpl::update_set_state(const RunContext& context, uint32_t v) case SetState::State::SET: break; case SetState::State::SET_CYCLE_1: - if (state.time < context.start() && + if (state.time < ctx.start() && buf->is_sequence() && buf->value_type() == _bufs.uris().atom_Float && !_parent->is_main()) { buf->clear(); - state.time = context.start(); + state.time = ctx.start(); } state.state = SetState::State::SET; break; @@ -323,7 +323,7 @@ PortImpl::update_set_state(const RunContext& context, uint32_t v) 0, sizeof(float), _bufs.uris().atom_Float, reinterpret_cast(&state.value)); } else { - buf->set_block(state.value, 0, context.nframes()); + buf->set_block(state.value, 0, ctx.nframes()); } state.state = SetState::State::SET_CYCLE_1; break; @@ -355,7 +355,7 @@ PortImpl::prepare_poly(BufferFactory& bufs, uint32_t poly) } bool -PortImpl::apply_poly(RunContext& context, uint32_t poly) +PortImpl::apply_poly(RunContext& ctx, uint32_t poly) { if (_parent->is_main() || (_type == PortType::ATOM && !_value.is_valid())) { @@ -372,7 +372,7 @@ PortImpl::apply_poly(RunContext& context, uint32_t poly) _voices = std::move(_prepared_voices); if (is_a(PortType::CONTROL) || is_a(PortType::CV)) { - set_control_value(context, context.start(), _value.get()); + set_control_value(ctx, ctx.start(), _value.get()); } assert(_voices->size() >= poly); @@ -444,14 +444,14 @@ PortImpl::clear_buffers(const RunContext& ctx) } void -PortImpl::monitor(RunContext& context, bool send_now) +PortImpl::monitor(RunContext& ctx, bool send_now) { - if (!context.must_notify(this)) { + if (!ctx.must_notify(this)) { return; } - const uint32_t period = monitor_period(context.engine()); - _frames_since_monitor += context.nframes(); + const uint32_t period = monitor_period(ctx.engine()); + _frames_since_monitor += ctx.nframes(); const bool time_to_send = send_now || _frames_since_monitor >= period; const bool is_sequence = (_type.id() == PortType::ATOM && @@ -460,8 +460,8 @@ PortImpl::monitor(RunContext& context, bool send_now) return; } - Forge& forge = context.engine().world().forge(); - URIs& uris = context.engine().world().uris(); + Forge& forge = ctx.engine().world().forge(); + URIs& uris = ctx.engine().world().uris(); LV2_URID key = 0; float val = 0.0f; switch (_type.id()) { @@ -469,7 +469,7 @@ PortImpl::monitor(RunContext& context, bool send_now) break; case PortType::AUDIO: key = uris.ingen_activity; - val = _peak = std::max(_peak, buffer(0)->peak(context)); + val = _peak = std::max(_peak, buffer(0)->peak(ctx)); break; case PortType::CONTROL: case PortType::CV: @@ -487,12 +487,12 @@ PortImpl::monitor(RunContext& context, bool send_now) /* Sequence explicitly monitored, send everything. */ const auto* seq = reinterpret_cast(atom); LV2_ATOM_SEQUENCE_FOREACH(seq, ev) { - context.notify(uris.ingen_activity, - context.start() + ev->time.frames, - this, - ev->body.size, - ev->body.type, - LV2_ATOM_BODY(&ev->body)); + ctx.notify(uris.ingen_activity, + ctx.start() + ev->time.frames, + this, + ev->body.size, + ev->body.type, + LV2_ATOM_BODY(&ev->body)); } } else if (value && value->type == _bufs.uris().atom_Float) { /* Float sequence, monitor as a control. */ @@ -501,12 +501,12 @@ PortImpl::monitor(RunContext& context, bool send_now) } else if (atom->size > sizeof(LV2_Atom_Sequence_Body)) { /* General sequence, send activity for blinkenlights. */ const int32_t one = 1; - context.notify(uris.ingen_activity, - context.start(), - this, - sizeof(int32_t), - static_cast(uris.atom_Bool), - &one); + ctx.notify(uris.ingen_activity, + ctx.start(), + this, + sizeof(int32_t), + static_cast(uris.atom_Bool), + &one); _force_monitor_update = false; } } @@ -514,8 +514,7 @@ PortImpl::monitor(RunContext& context, bool send_now) _frames_since_monitor = _frames_since_monitor % period; if (key && val != _monitor_value) { - if (context.notify(key, context.start(), this, - sizeof(float), forge.Float, &val)) { + if (ctx.notify(key, ctx.start(), this, sizeof(float), forge.Float, &val)) { /* Update frames since last update to conceptually zero, but keep the remainder to preserve load balancing. */ _frames_since_monitor = _frames_since_monitor % period; @@ -552,27 +551,32 @@ PortImpl::update_values(SampleCount offset, uint32_t voice) const } void -PortImpl::pre_process(RunContext& context) +PortImpl::pre_process(RunContext& ctx) { if (!_connected_flag.test_and_set(std::memory_order_acquire)) { connect_buffers(); - clear_buffers(context); + clear_buffers(ctx); } for (uint32_t v = 0; v < _poly; ++v) { - _voices->at(v).buffer->prepare_output_write(context); + _voices->at(v).buffer->prepare_output_write(ctx); } } void -PortImpl::post_process(RunContext& context) +PortImpl::pre_run(RunContext&) +{ +} + +void +PortImpl::post_process(RunContext& ctx) { for (uint32_t v = 0; v < _poly; ++v) { - update_set_state(context, v); + update_set_state(ctx, v); update_values(0, v); } - monitor(context); + monitor(ctx); } } // namespace server diff --git a/src/server/PortImpl.hpp b/src/server/PortImpl.hpp index fba24f06..05664ee5 100644 --- a/src/server/PortImpl.hpp +++ b/src/server/PortImpl.hpp @@ -63,10 +63,10 @@ public: SetState() : state(State::SET), value(0), time(0) {} - void set(const RunContext& context, FrameTime t, Sample v) { + void set(const RunContext& ctx, FrameTime t, Sample v) { time = t; value = v; - state = (time == context.start() + state = (time == ctx.start() ? State::SET : State::HALF_SET_CYCLE_1); } @@ -102,7 +102,7 @@ public: BlockImpl* parent_block() const { return reinterpret_cast(_parent); } /** Set the the voices (buffers) for this port in the audio thread. */ - void set_voices(RunContext& context, MPtr&& voices); + void set_voices(RunContext& ctx, MPtr&& voices); /** Prepare for a new (external) polyphony value. * @@ -115,7 +115,7 @@ public: * Audio thread. * \a poly Must be < the most recent value passed to prepare_poly. */ - bool apply_poly(RunContext& context, uint32_t poly) override; + bool apply_poly(RunContext& ctx, uint32_t poly) override; /** Return the number of arcs (pre-process thraed). */ virtual size_t num_arcs() const { return 0; } @@ -140,14 +140,14 @@ public: return _prepared_voices->at(voice).buffer; } - void update_set_state(const RunContext& context, uint32_t v); + void update_set_state(const RunContext& ctx, uint32_t v); - void set_voice_value(const RunContext& context, + void set_voice_value(const RunContext& ctx, uint32_t voice, FrameTime time, Sample value); - void set_control_value(const RunContext& context, + void set_control_value(const RunContext& ctx, FrameTime time, Sample value); @@ -164,9 +164,9 @@ public: bool is_driver_port() const { return _is_driver_port; } /** Called once per process cycle */ - virtual void pre_process(RunContext& context); - virtual void pre_run(RunContext& context) {} - virtual void post_process(RunContext& context); + virtual void pre_process(RunContext& ctx); + virtual void pre_run(RunContext& ctx); + virtual void post_process(RunContext& ctx); /** Clear/silence all buffers */ virtual void clear_buffers(const RunContext& ctx); @@ -212,7 +212,7 @@ public: return (_prepared_voices) ? _prepared_voices->size() : 1; } - void set_buffer_size(RunContext& context, BufferFactory& bufs, size_t size); + void set_buffer_size(RunContext& ctx, BufferFactory& bufs, size_t size); /** Return true iff this port is explicitly monitored. * @@ -226,7 +226,7 @@ public: void enable_monitoring(bool monitored) { _monitored = monitored; } /** Monitor port value and broadcast to clients periodically. */ - void monitor(RunContext& context, bool send_now=false); + void monitor(RunContext& ctx, bool send_now=false); BufferFactory& bufs() const { return _bufs; } diff --git a/src/server/PostProcessor.hpp b/src/server/PostProcessor.hpp index 2733b209..ab8ba6bc 100644 --- a/src/server/PostProcessor.hpp +++ b/src/server/PostProcessor.hpp @@ -50,7 +50,7 @@ public: /** Push a list of events on to the process queue. realtime-safe, not thread-safe. */ - void append(RunContext& context, Event* first, Event* last); + void append(RunContext& ctx, Event* first, Event* last); /** Post-process and delete all pending events */ void process(); diff --git a/src/server/PreProcessor.cpp b/src/server/PreProcessor.cpp index 33da71d7..b2f0fd46 100644 --- a/src/server/PreProcessor.cpp +++ b/src/server/PreProcessor.cpp @@ -82,7 +82,7 @@ PreProcessor::event(Event* const ev, Event::Mode mode) } unsigned -PreProcessor::process(RunContext& context, PostProcessor& dest, size_t limit) +PreProcessor::process(RunContext& ctx, PostProcessor& dest, size_t limit) { Event* const head = _head.load(); size_t n_processed = 0; @@ -115,15 +115,15 @@ PreProcessor::process(RunContext& context, PostProcessor& dest, size_t limit) if (_block_state == BlockState::BLOCKED) { break; // Waiting for PRE_UNBLOCKED - } else if (ev->time() < context.start()) { - ev->set_time(context.start()); // Too late, nudge to context start + } else if (ev->time() < ctx.start()) { + ev->set_time(ctx.start()); // Too late, nudge to context start } else if (_block_state != BlockState::PROCESSING && - ev->time() >= context.end()) { + ev->time() >= ctx.end()) { break; // Event is for a future cycle } // Execute event - ev->execute(context); + ev->execute(ctx); ++n_processed; // Unblock pre-processing if this is a non-bundled atomic event @@ -144,9 +144,9 @@ PreProcessor::process(RunContext& context, PostProcessor& dest, size_t limit) if (n_processed > 0) { #ifndef NDEBUG - Engine& engine = context.engine(); + Engine& engine = ctx.engine(); if (engine.world().conf().option("trace").get()) { - const uint64_t start = engine.cycle_start_time(context); + const uint64_t start = engine.cycle_start_time(ctx); const uint64_t end = engine.current_time(); fprintf(stderr, "Processed %zu events in %u us\n", n_processed, static_cast(end - start)); @@ -155,7 +155,7 @@ PreProcessor::process(RunContext& context, PostProcessor& dest, size_t limit) auto* next = static_cast(last->next()); last->next(nullptr); - dest.append(context, head, last); + dest.append(ctx, head, last); // Since _head was not null, we know it hasn't been changed since _head = next; diff --git a/src/server/PreProcessor.hpp b/src/server/PreProcessor.hpp index 8d15c0a6..54f185c3 100644 --- a/src/server/PreProcessor.hpp +++ b/src/server/PreProcessor.hpp @@ -52,7 +52,7 @@ public: /** Process events for a cycle. * @return The number of events processed. */ - unsigned process(RunContext& context, + unsigned process(RunContext& ctx, PostProcessor& dest, size_t limit = 0); diff --git a/src/server/Task.cpp b/src/server/Task.cpp index b61a08eb..ec9568b3 100644 --- a/src/server/Task.cpp +++ b/src/server/Task.cpp @@ -27,16 +27,16 @@ namespace ingen { namespace server { void -Task::run(RunContext& context) +Task::run(RunContext& ctx) { switch (_mode) { case Mode::SINGLE: // fprintf(stderr, "%u run %s\n", context.id(), _block->path().c_str()); - _block->process(context); + _block->process(ctx); break; case Mode::SEQUENTIAL: for (const auto& task : _children) { - task->run(context); + task->run(ctx); } break; case Mode::PARALLEL: @@ -48,16 +48,16 @@ Task::run(RunContext& context) // Grab the first sub-task _next = 0; _done_end = 0; - Task* t = steal(context); + Task* t = steal(ctx); // Allow other threads to steal sub-tasks - context.claim_task(this); + ctx.claim_task(this); // Run available tasks until this task is finished - for (; t; t = get_task(context)) { - t->run(context); + for (; t; t = get_task(ctx)) { + t->run(ctx); } - context.claim_task(nullptr); + ctx.claim_task(nullptr); break; } @@ -78,10 +78,10 @@ Task::steal(RunContext&) } Task* -Task::get_task(RunContext& context) +Task::get_task(RunContext& ctx) { // Attempt to "steal" a task from ourselves - Task* t = steal(context); + Task* t = steal(ctx); if (t) { return t; } @@ -97,7 +97,7 @@ Task::get_task(RunContext& context) } // All child tasks claimed, but some are unfinished, steal a task - if ((t = context.steal_task())) { + if ((t = ctx.steal_task())) { return t; } diff --git a/src/server/Task.hpp b/src/server/Task.hpp index e8b658c3..9f1e6dae 100644 --- a/src/server/Task.hpp +++ b/src/server/Task.hpp @@ -70,7 +70,7 @@ public: } /** Run task in the given context. */ - void run(RunContext& context); + void run(RunContext& ctx); /** Pretty print task to the given stream (recursively). */ void dump(const std::function& sink, @@ -84,7 +84,7 @@ public: static std::unique_ptr simplify(std::unique_ptr&& task); /** Steal a child task from this task (succeeds for PARALLEL only). */ - Task* steal(RunContext& context); + Task* steal(RunContext& ctx); /** Prepend a child to this task. */ void push_front(Task&& task) { @@ -103,7 +103,7 @@ private: Task(const Task&) = delete; Task& operator=(const Task&) = delete; - Task* get_task(RunContext& context); + Task* get_task(RunContext& ctx); void append(std::unique_ptr&& t) { _children.emplace_back(std::move(t)); diff --git a/src/server/events/Connect.cpp b/src/server/events/Connect.cpp index 2df73b21..eabcad73 100644 --- a/src/server/events/Connect.cpp +++ b/src/server/events/Connect.cpp @@ -151,12 +151,12 @@ Connect::pre_process(PreProcessContext& ctx) } void -Connect::execute(RunContext& context) +Connect::execute(RunContext& ctx) { if (_status == Status::SUCCESS) { - _head->add_arc(context, *_arc.get()); + _head->add_arc(ctx, *_arc.get()); if (!_head->is_driver_port()) { - _head->set_voices(context, std::move(_voices)); + _head->set_voices(ctx, std::move(_voices)); } _head->connect_buffers(); if (_compiled_graph) { diff --git a/src/server/events/Connect.hpp b/src/server/events/Connect.hpp index adc80afc..305ad7a8 100644 --- a/src/server/events/Connect.hpp +++ b/src/server/events/Connect.hpp @@ -44,7 +44,7 @@ public: const ingen::Connect& msg); bool pre_process(PreProcessContext& ctx) override; - void execute(RunContext& context) override; + void execute(RunContext& ctx) override; void post_process() override; void undo(Interface& target) override; diff --git a/src/server/events/Copy.hpp b/src/server/events/Copy.hpp index 26673a55..aa1eae5d 100644 --- a/src/server/events/Copy.hpp +++ b/src/server/events/Copy.hpp @@ -41,7 +41,7 @@ public: const ingen::Copy& msg); bool pre_process(PreProcessContext& ctx) override; - void execute(RunContext& context) override; + void execute(RunContext& ctx) override; void post_process() override; void undo(Interface& target) override; diff --git a/src/server/events/CreateBlock.hpp b/src/server/events/CreateBlock.hpp index 00f58008..a9f43a80 100644 --- a/src/server/events/CreateBlock.hpp +++ b/src/server/events/CreateBlock.hpp @@ -46,7 +46,7 @@ public: Properties& properties); bool pre_process(PreProcessContext& ctx) override; - void execute(RunContext& context) override; + void execute(RunContext& ctx) override; void post_process() override; void undo(Interface& target) override; diff --git a/src/server/events/CreateGraph.cpp b/src/server/events/CreateGraph.cpp index 4e031276..7a1d9a75 100644 --- a/src/server/events/CreateGraph.cpp +++ b/src/server/events/CreateGraph.cpp @@ -188,7 +188,7 @@ CreateGraph::pre_process(PreProcessContext& ctx) } void -CreateGraph::execute(RunContext& context) +CreateGraph::execute(RunContext& ctx) { if (_graph) { if (_parent) { @@ -201,7 +201,7 @@ CreateGraph::execute(RunContext& context) } for (const auto& ev : _child_events) { - ev->execute(context); + ev->execute(ctx); } } } diff --git a/src/server/events/CreateGraph.hpp b/src/server/events/CreateGraph.hpp index dadb644e..4ab3f4af 100644 --- a/src/server/events/CreateGraph.hpp +++ b/src/server/events/CreateGraph.hpp @@ -48,7 +48,7 @@ public: const Properties& properties); bool pre_process(PreProcessContext& ctx) override; - void execute(RunContext& context) override; + void execute(RunContext& ctx) override; void post_process() override; void undo(Interface& target) override; diff --git a/src/server/events/CreatePort.cpp b/src/server/events/CreatePort.cpp index e6862731..2520378c 100644 --- a/src/server/events/CreatePort.cpp +++ b/src/server/events/CreatePort.cpp @@ -180,7 +180,7 @@ CreatePort::pre_process(PreProcessContext&) } void -CreatePort::execute(RunContext& context) +CreatePort::execute(RunContext& ctx) { if (_status == Status::SUCCESS) { const MPtr& old_ports = _graph->external_ports(); @@ -196,7 +196,7 @@ CreatePort::execute(RunContext& context) _graph->set_external_ports(std::move(_ports_array)); if (_engine_port) { - _engine.driver()->add_port(context, _engine_port); + _engine.driver()->add_port(ctx, _engine_port); } } } diff --git a/src/server/events/CreatePort.hpp b/src/server/events/CreatePort.hpp index 8137328d..9ad8987a 100644 --- a/src/server/events/CreatePort.hpp +++ b/src/server/events/CreatePort.hpp @@ -52,7 +52,7 @@ public: const Properties& properties); bool pre_process(PreProcessContext& ctx) override; - void execute(RunContext& context) override; + void execute(RunContext& ctx) override; void post_process() override; void undo(Interface& target) override; diff --git a/src/server/events/Delete.cpp b/src/server/events/Delete.cpp index e91ab5ef..d0a77a31 100644 --- a/src/server/events/Delete.cpp +++ b/src/server/events/Delete.cpp @@ -138,18 +138,18 @@ Delete::pre_process(PreProcessContext& ctx) } void -Delete::execute(RunContext& context) +Delete::execute(RunContext& ctx) { if (_status != Status::SUCCESS) { return; } if (_disconnect_event) { - _disconnect_event->execute(context); + _disconnect_event->execute(ctx); } if (!_removed_bindings.empty()) { - _engine.control_bindings()->remove(context, _removed_bindings); + _engine.control_bindings()->remove(ctx, _removed_bindings); } GraphImpl* parent = _block ? _block->parent_graph() : nullptr; @@ -158,7 +158,7 @@ Delete::execute(RunContext& context) for (size_t i = 0; i < _ports_array->size(); ++i) { PortImpl* const port = _ports_array->at(i); if (port->index() != i) { - port->set_index(context, i); + port->set_index(ctx, i); } } @@ -167,7 +167,7 @@ Delete::execute(RunContext& context) parent->set_external_ports(std::move(_ports_array)); if (_engine_port) { - _engine.driver()->remove_port(context, _engine_port); + _engine.driver()->remove_port(ctx, _engine_port); } } diff --git a/src/server/events/Delete.hpp b/src/server/events/Delete.hpp index 6b3149e9..a84c2969 100644 --- a/src/server/events/Delete.hpp +++ b/src/server/events/Delete.hpp @@ -53,7 +53,7 @@ public: ~Delete(); bool pre_process(PreProcessContext& ctx) override; - void execute(RunContext& context) override; + void execute(RunContext& ctx) override; void post_process() override; void undo(Interface& target) override; diff --git a/src/server/events/Delta.cpp b/src/server/events/Delta.cpp index eb70d046..28919a50 100644 --- a/src/server/events/Delta.cpp +++ b/src/server/events/Delta.cpp @@ -474,7 +474,7 @@ Delta::pre_process(PreProcessContext& ctx) } void -Delta::execute(RunContext& context) +Delta::execute(RunContext& ctx) { if (_status != Status::SUCCESS || _preset) { return; @@ -484,16 +484,16 @@ Delta::execute(RunContext& context) if (_create_event) { _create_event->set_time(_time); - _create_event->execute(context); + _create_event->execute(ctx); } for (auto& s : _set_events) { s->set_time(_time); - s->execute(context); + s->execute(ctx); } if (!_removed_bindings.empty()) { - _engine.control_bindings()->remove(context, _removed_bindings); + _engine.control_bindings()->remove(ctx, _removed_bindings); } auto* const object = dynamic_cast(_object); @@ -518,7 +518,7 @@ Delta::execute(RunContext& context) } _graph->enable(); } else { - _graph->disable(context); + _graph->disable(ctx); } } else if (block) { block->set_enabled(value.get()); @@ -528,15 +528,15 @@ Delta::execute(RunContext& context) if (object) { if (value.get()) { auto* parent = reinterpret_cast(object->parent()); - object->apply_poly(context, parent->internal_poly_process()); + object->apply_poly(ctx, parent->internal_poly_process()); } else { - object->apply_poly(context, 1); + object->apply_poly(ctx, 1); } } } break; case SpecialType::POLYPHONY: if (_graph && - !_graph->apply_internal_poly(context, + !_graph->apply_internal_poly(ctx, *_engine.buffer_factory(), *_engine.maid(), value.get())) { @@ -545,12 +545,12 @@ Delta::execute(RunContext& context) break; case SpecialType::PORT_INDEX: if (port) { - port->set_index(context, value.get()); + port->set_index(ctx, value.get()); } break; case SpecialType::CONTROL_BINDING: if (port) { - if (!_engine.control_bindings()->set_port_binding(context, port, _binding, value)) { + if (!_engine.control_bindings()->set_port_binding(ctx, port, _binding, value)) { _status = Status::BAD_VALUE; } } else if (block) { diff --git a/src/server/events/Delta.hpp b/src/server/events/Delta.hpp index 1dce2663..629fd77c 100644 --- a/src/server/events/Delta.hpp +++ b/src/server/events/Delta.hpp @@ -70,7 +70,7 @@ public: uint32_t type); bool pre_process(PreProcessContext& ctx) override; - void execute(RunContext& context) override; + void execute(RunContext& ctx) override; void post_process() override; void undo(Interface& target) override; diff --git a/src/server/events/Disconnect.cpp b/src/server/events/Disconnect.cpp index 531d70af..2c689a6a 100644 --- a/src/server/events/Disconnect.cpp +++ b/src/server/events/Disconnect.cpp @@ -165,7 +165,7 @@ Disconnect::pre_process(PreProcessContext& ctx) } bool -Disconnect::Impl::execute(RunContext& context, bool set_head_buffers) +Disconnect::Impl::execute(RunContext& ctx, bool set_head_buffers) { if (!_arc) { return false; @@ -178,9 +178,9 @@ Disconnect::Impl::execute(RunContext& context, bool set_head_buffers) if (set_head_buffers) { if (_voices) { - _head->set_voices(context, std::move(_voices)); + _head->set_voices(ctx, std::move(_voices)); } else { - _head->setup_buffers(context, *_engine.buffer_factory(), _head->poly()); + _head->setup_buffers(ctx, *_engine.buffer_factory(), _head->poly()); } _head->connect_buffers(); } else { @@ -191,10 +191,10 @@ Disconnect::Impl::execute(RunContext& context, bool set_head_buffers) } void -Disconnect::execute(RunContext& context) +Disconnect::execute(RunContext& ctx) { if (_status == Status::SUCCESS) { - if (_impl->execute(context, true)) { + if (_impl->execute(ctx, true)) { if (_compiled_graph) { _graph->set_compiled_graph(std::move(_compiled_graph)); } diff --git a/src/server/events/Disconnect.hpp b/src/server/events/Disconnect.hpp index ec638c73..4b5f6aea 100644 --- a/src/server/events/Disconnect.hpp +++ b/src/server/events/Disconnect.hpp @@ -43,7 +43,7 @@ public: const ingen::Disconnect& msg); bool pre_process(PreProcessContext& ctx) override; - void execute(RunContext& context) override; + void execute(RunContext& ctx) override; void post_process() override; void undo(Interface& target) override; @@ -51,7 +51,7 @@ public: public: Impl(Engine& e, GraphImpl* graph, PortImpl* t, InputPort* h); - bool execute(RunContext& context, bool set_head_buffers); + bool execute(RunContext& ctx, bool set_head_buffers); inline PortImpl* tail() { return _tail; } inline InputPort* head() { return _head; } diff --git a/src/server/events/DisconnectAll.cpp b/src/server/events/DisconnectAll.cpp index 4444bb26..cc4284ff 100644 --- a/src/server/events/DisconnectAll.cpp +++ b/src/server/events/DisconnectAll.cpp @@ -143,11 +143,11 @@ DisconnectAll::pre_process(PreProcessContext& ctx) } void -DisconnectAll::execute(RunContext& context) +DisconnectAll::execute(RunContext& ctx) { if (_status == Status::SUCCESS) { for (auto& i : _impls) { - i->execute(context, + i->execute(ctx, !_deleting || (i->head()->parent_block() != _block)); } } diff --git a/src/server/events/DisconnectAll.hpp b/src/server/events/DisconnectAll.hpp index 9ab908c1..7be48d82 100644 --- a/src/server/events/DisconnectAll.hpp +++ b/src/server/events/DisconnectAll.hpp @@ -55,7 +55,7 @@ public: ~DisconnectAll(); bool pre_process(PreProcessContext& ctx) override; - void execute(RunContext& context) override; + void execute(RunContext& ctx) override; void post_process() override; void undo(Interface& target) override; diff --git a/src/server/events/Get.cpp b/src/server/events/Get.cpp index 2335c09f..9194226d 100644 --- a/src/server/events/Get.cpp +++ b/src/server/events/Get.cpp @@ -83,6 +83,11 @@ Get::pre_process(PreProcessContext&) } } +void +Get::execute(RunContext&) +{ +} + void Get::post_process() { diff --git a/src/server/events/Get.hpp b/src/server/events/Get.hpp index e24c9998..0c3d053d 100644 --- a/src/server/events/Get.hpp +++ b/src/server/events/Get.hpp @@ -45,7 +45,7 @@ public: const ingen::Get& msg); bool pre_process(PreProcessContext& ctx) override; - void execute(RunContext& context) override {} + void execute(RunContext&) override; void post_process() override; private: diff --git a/src/server/events/Mark.cpp b/src/server/events/Mark.cpp index eb50e4a0..103c5b3c 100644 --- a/src/server/events/Mark.cpp +++ b/src/server/events/Mark.cpp @@ -45,7 +45,7 @@ Mark::Mark(Engine& engine, {} void -Mark::mark(PreProcessContext& ctx) +Mark::mark(PreProcessContext&) { const UPtr& stack = ((_mode == Mode::UNDO) ? _engine.redo_stack() diff --git a/src/server/events/Mark.hpp b/src/server/events/Mark.hpp index bff38f06..2bcdafb2 100644 --- a/src/server/events/Mark.hpp +++ b/src/server/events/Mark.hpp @@ -52,7 +52,7 @@ public: void mark(PreProcessContext& ctx) override; bool pre_process(PreProcessContext& ctx) override; - void execute(RunContext& context) override; + void execute(RunContext& ctx) override; void post_process() override; Execution get_execution() const override; diff --git a/src/server/events/Move.cpp b/src/server/events/Move.cpp index f6a39f1f..d7262143 100644 --- a/src/server/events/Move.cpp +++ b/src/server/events/Move.cpp @@ -69,7 +69,7 @@ Move::pre_process(PreProcessContext&) } void -Move::execute(RunContext& context) +Move::execute(RunContext&) { } diff --git a/src/server/events/Move.hpp b/src/server/events/Move.hpp index b4487b78..5c71ce96 100644 --- a/src/server/events/Move.hpp +++ b/src/server/events/Move.hpp @@ -42,7 +42,7 @@ public: const ingen::Move& msg); bool pre_process(PreProcessContext& ctx) override; - void execute(RunContext& context) override; + void execute(RunContext& ctx) override; void post_process() override; void undo(Interface& target) override; diff --git a/src/server/events/SetPortValue.cpp b/src/server/events/SetPortValue.cpp index f341737c..66511a0c 100644 --- a/src/server/events/SetPortValue.cpp +++ b/src/server/events/SetPortValue.cpp @@ -80,15 +80,15 @@ SetPortValue::pre_process(PreProcessContext&) } void -SetPortValue::execute(RunContext& context) +SetPortValue::execute(RunContext& ctx) { - assert(_time >= context.start() && _time <= context.end()); - apply(context); - _engine.control_bindings()->port_value_changed(context, _port, _binding, _value); + assert(_time >= ctx.start() && _time <= ctx.end()); + apply(ctx); + _engine.control_bindings()->port_value_changed(ctx, _port, _binding, _value); } void -SetPortValue::apply(RunContext& context) +SetPortValue::apply(RunContext& ctx) { if (_status != Status::SUCCESS) { return; @@ -98,22 +98,22 @@ SetPortValue::apply(RunContext& context) Buffer* buf = _port->buffer(0).get(); if (_buffer) { - if (_port->user_buffer(context)) { - buf = _port->user_buffer(context).get(); + if (_port->user_buffer(ctx)) { + buf = _port->user_buffer(ctx).get(); } else { - _port->set_user_buffer(context, _buffer); + _port->set_user_buffer(ctx, _buffer); buf = _buffer.get(); } } if (buf->type() == uris.atom_Sound || buf->type() == uris.atom_Float) { if (_value.type() == uris.forge.Float) { - _port->set_control_value(context, _time, _value.get()); + _port->set_control_value(ctx, _time, _value.get()); } else { _status = Status::TYPE_MISMATCH; } } else if (buf->type() == uris.atom_Sequence) { - if (!buf->append_event(_time - context.start(), + if (!buf->append_event(_time - ctx.start(), _value.size(), _value.type(), reinterpret_cast(_value.get_body()))) { diff --git a/src/server/events/SetPortValue.hpp b/src/server/events/SetPortValue.hpp index 99d55af3..df30d514 100644 --- a/src/server/events/SetPortValue.hpp +++ b/src/server/events/SetPortValue.hpp @@ -50,13 +50,13 @@ public: bool synthetic = false); bool pre_process(PreProcessContext& ctx) override; - void execute(RunContext& context) override; + void execute(RunContext& ctx) override; void post_process() override; bool synthetic() const { return _synthetic; } private: - void apply(RunContext& context); + void apply(RunContext& ctx); PortImpl* _port; const Atom _value; diff --git a/src/server/events/Undo.cpp b/src/server/events/Undo.cpp index 0741e60d..9a60c15f 100644 --- a/src/server/events/Undo.cpp +++ b/src/server/events/Undo.cpp @@ -73,7 +73,7 @@ Undo::pre_process(PreProcessContext&) } void -Undo::execute(RunContext& context) +Undo::execute(RunContext&) { } diff --git a/src/server/events/Undo.hpp b/src/server/events/Undo.hpp index e36ebaad..1fdaa4dd 100644 --- a/src/server/events/Undo.hpp +++ b/src/server/events/Undo.hpp @@ -43,7 +43,7 @@ public: const ingen::Redo& msg); bool pre_process(PreProcessContext& ctx) override; - void execute(RunContext& context) override; + void execute(RunContext& ctx) override; void post_process() override; private: diff --git a/src/server/ingen_lv2.cpp b/src/server/ingen_lv2.cpp index 84ecf5ba..576e7659 100644 --- a/src/server/ingen_lv2.cpp +++ b/src/server/ingen_lv2.cpp @@ -97,7 +97,7 @@ namespace server { class LV2Driver; -void signal_main(RunContext& context, LV2Driver* driver); +void signal_main(RunContext& ctx, LV2Driver* driver); inline size_t ui_ring_size(SampleCount block_length) @@ -138,9 +138,9 @@ public: bool dynamic_ports() const override { return !_instantiated; } - void pre_process_port(RunContext& context, EnginePort* port) { + void pre_process_port(RunContext& ctx, EnginePort* port) { const URIs& uris = _engine.world().uris(); - const SampleCount nframes = context.nframes(); + const SampleCount nframes = ctx.nframes(); DuplexPort* graph_port = port->graph_port(); Buffer* graph_buf = graph_port->buffer(0).get(); void* lv2_buf = port->buffer(); @@ -171,13 +171,13 @@ public: } if (graph_port->is_input()) { - graph_port->monitor(context); + graph_port->monitor(ctx); } else { - graph_buf->prepare_write(context); + graph_buf->prepare_write(ctx); } } - static void post_process_port(RunContext& context, EnginePort* port) { + static void post_process_port(RunContext&, EnginePort* port) { DuplexPort* graph_port = port->graph_port(); // No copying necessary, host buffers are used directly @@ -231,7 +231,7 @@ public: } /** Add a port. Called only during init or restore. */ - void add_port(RunContext& context, EnginePort* port) override { + void add_port(RunContext&, EnginePort* port) override { const uint32_t index = port->graph_port()->index(); if (_ports.size() <= index) { _ports.resize(index + 1); @@ -240,7 +240,7 @@ public: } /** Remove a port. Called only during init or restore. */ - void remove_port(RunContext& context, EnginePort* port) override { + void remove_port(RunContext&, EnginePort* port) override { const uint32_t index = port->graph_port()->index(); _ports[index] = nullptr; } @@ -265,7 +265,7 @@ public: return new EnginePort(graph_port); } - void append_time_events(RunContext& context, Buffer& buffer) override { + void append_time_events(RunContext&, Buffer& buffer) override { const URIs& uris = _engine.world().uris(); auto* seq = static_cast(_ports[0]->buffer()); @@ -339,7 +339,7 @@ public: free(buf); } - void flush_to_ui(RunContext& context) { + void flush_to_ui(RunContext&) { if (_ports.size() < 2) { _engine.log().rt_error("Standard control ports are not present\n"); return; 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(); @@ -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(); @@ -172,48 +172,48 @@ NoteNode::run(RunContext& context) static_cast(LV2_ATOM_BODY_CONST(&ev->body)); const FrameTime time = - context.start() + static_cast(ev->time.frames); + ctx.start() + static_cast(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(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(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(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; - void free_voice(RunContext& context, uint32_t voice, FrameTime time); + void free_voice(RunContext& ctx, uint32_t voice, FrameTime time); MPtr _voices; MPtr _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(); @@ -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(); 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(note_num)); + _note_port->set_control_value(ctx, time, static_cast(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; } diff --git a/src/server/mix.cpp b/src/server/mix.cpp index 75d31931..6bd36ab1 100644 --- a/src/server/mix.cpp +++ b/src/server/mix.cpp @@ -35,13 +35,13 @@ is_end(const Buffer* buf, const LV2_Atom_Event* ev) } void -mix(const RunContext& context, +mix(const RunContext& ctx, Buffer* dst, const Buffer*const* srcs, uint32_t num_srcs) { if (num_srcs == 1) { - dst->copy(context, srcs[0]); + dst->copy(ctx, srcs[0]); } else if (dst->is_control()) { Sample* const out = dst->samples(); out[0] = srcs[0]->value_at(0); @@ -50,11 +50,11 @@ mix(const RunContext& context, } } else if (dst->is_audio()) { // Copy the first source - dst->copy(context, srcs[0]); + dst->copy(ctx, srcs[0]); // Mix in the rest Sample* __restrict const out = dst->samples(); - const SampleCount end = context.nframes(); + const SampleCount end = ctx.nframes(); for (uint32_t i = 1; i < num_srcs; ++i) { const Sample* __restrict const in = srcs[i]->samples(); if (srcs[i]->is_control()) { // control => audio @@ -66,7 +66,7 @@ mix(const RunContext& context, out[i] += in[i]; } } else if (srcs[i]->is_sequence()) { // sequence => audio - dst->render_sequence(context, srcs[i], true); + dst->render_sequence(ctx, srcs[i], true); } } } else if (dst->is_sequence()) { diff --git a/src/server/mix.hpp b/src/server/mix.hpp index 1878200c..75e139d3 100644 --- a/src/server/mix.hpp +++ b/src/server/mix.hpp @@ -26,7 +26,7 @@ class Buffer; class RunContext; void -mix(const RunContext& context, +mix(const RunContext& ctx, Buffer* dst, const Buffer*const* srcs, uint32_t num_srcs); -- cgit v1.2.1