diff options
-rw-r--r-- | src/server/AudioBuffer.cpp | 51 | ||||
-rw-r--r-- | src/server/AudioBuffer.hpp | 8 | ||||
-rw-r--r-- | src/server/Buffer.hpp | 1 | ||||
-rw-r--r-- | src/server/ControlBindings.cpp | 9 | ||||
-rw-r--r-- | src/server/InputPort.cpp | 4 | ||||
-rw-r--r-- | src/server/InputPort.hpp | 2 | ||||
-rw-r--r-- | src/server/JackDriver.cpp | 1 | ||||
-rw-r--r-- | src/server/LV2Node.cpp | 4 | ||||
-rw-r--r-- | src/server/NodeImpl.cpp | 12 | ||||
-rw-r--r-- | src/server/OutputPort.cpp | 5 | ||||
-rw-r--r-- | src/server/PortImpl.cpp | 101 | ||||
-rw-r--r-- | src/server/PortImpl.hpp | 21 | ||||
-rw-r--r-- | src/server/events/Delta.cpp | 2 | ||||
-rw-r--r-- | src/server/events/Disconnect.cpp | 3 | ||||
-rw-r--r-- | src/server/events/SetPortValue.cpp | 8 | ||||
-rw-r--r-- | src/server/internals/Controller.cpp | 8 | ||||
-rw-r--r-- | src/server/internals/Note.cpp | 23 | ||||
-rw-r--r-- | src/server/internals/Trigger.cpp | 21 |
18 files changed, 152 insertions, 132 deletions
diff --git a/src/server/AudioBuffer.cpp b/src/server/AudioBuffer.cpp index 0b42435f..9cd267ee 100644 --- a/src/server/AudioBuffer.cpp +++ b/src/server/AudioBuffer.cpp @@ -32,9 +32,6 @@ namespace Server { AudioBuffer::AudioBuffer(BufferFactory& bufs, LV2_URID type, uint32_t size) : Buffer(bufs, type, size) - , _state(OK) - , _set_value(0) - , _set_time(0) { assert(size >= sizeof(LV2_Atom) + sizeof(Sample)); assert(this->capacity() >= size); @@ -60,36 +57,6 @@ AudioBuffer::clear() { assert(nframes() != 0); set_block(0, 0, nframes() - 1); - _state = OK; -} - -/** Set value of buffer to @a val after @a start_sample. - * - * The Buffer will handle setting the intial portion of the buffer to the - * value on the next cycle automatically (if @a start_sample is > 0), as - * long as pre_process() is called every cycle. - */ -void -AudioBuffer::set_value(Sample val, FrameTime cycle_start, FrameTime time) -{ - if (is_control()) - time = cycle_start; - - const FrameTime offset = time - cycle_start; - assert(nframes() != 0); - assert(offset <= nframes()); - - if (offset < nframes()) { - set_block(val, offset, nframes() - 1); - - if (offset == 0) - _state = OK; - else - _state = HALF_SET_CYCLE_1; - } // else trigger at very end of block - - _set_time = time; - _set_value = val; } /** Set a block of buffer to @a val. @@ -160,23 +127,5 @@ AudioBuffer::peak(Context& context) const return peak; } -void -AudioBuffer::prepare_read(Context& context) -{ - assert(nframes() != 0); - switch (_state) { - case HALF_SET_CYCLE_1: - if (context.start() > _set_time) - _state = HALF_SET_CYCLE_2; - break; - case HALF_SET_CYCLE_2: - set_block(_set_value, 0, nframes() - 1); - _state = OK; - break; - default: - break; - } -} - } // namespace Server } // namespace Ingen diff --git a/src/server/AudioBuffer.hpp b/src/server/AudioBuffer.hpp index 69558a1f..e8bfa411 100644 --- a/src/server/AudioBuffer.hpp +++ b/src/server/AudioBuffer.hpp @@ -40,7 +40,6 @@ public: void clear(); - void set_value(Sample val, FrameTime cycle_start, FrameTime time); void set_block(Sample val, size_t start_offset, size_t end_offset); void copy(const Sample* src, size_t start_sample, size_t end_sample); void copy(Context& context, const Buffer* src); @@ -66,17 +65,10 @@ public: return data()[offset]; } - void prepare_read(Context& context); void prepare_write(Context& context) {} private: - enum State { OK, HALF_SET_CYCLE_1, HALF_SET_CYCLE_2 }; - LV2_Atom_Vector* vector() { return (LV2_Atom_Vector*)atom(); } - - State _state; ///< State of buffer for setting values next cycle - Sample _set_value; ///< Value set by set_value (for completing the set next cycle) - FrameTime _set_time; ///< Time _set_value was set (to reset next cycle) }; } // namespace Server diff --git a/src/server/Buffer.hpp b/src/server/Buffer.hpp index ee8f2361..84eaf516 100644 --- a/src/server/Buffer.hpp +++ b/src/server/Buffer.hpp @@ -46,7 +46,6 @@ public: virtual void clear(); virtual void resize(uint32_t size); virtual void copy(Context& context, const Buffer* src); - virtual void prepare_read(Context& context) {} virtual void prepare_write(Context& context); void* port_data(PortType port_type, SampleCount offset); diff --git a/src/server/ControlBindings.cpp b/src/server/ControlBindings.cpp index cec5a83c..1bb0e5f6 100644 --- a/src/server/ControlBindings.cpp +++ b/src/server/ControlBindings.cpp @@ -320,14 +320,9 @@ ControlBindings::set_port_value(ProcessContext& context, const Raul::Atom port_value(control_to_port_value(context, port, type, value)); - port->set_value(port_value); - assert(port_value.type() == port->bufs().forge().Float); - assert(dynamic_cast<AudioBuffer*>(port->buffer(0).get())); - - for (uint32_t v = 0; v < port->poly(); ++v) - reinterpret_cast<AudioBuffer*>(port->buffer(v).get())->set_value( - port_value.get_float(), context.start(), context.start()); + port->set_value(port_value); // FIXME: not thread safe + port->set_control_value(context, context.start(), port_value.get_float()); URIs& uris = context.engine().world()->uris(); context.notify(uris.ingen_value, context.start(), port, diff --git a/src/server/InputPort.cpp b/src/server/InputPort.cpp index 796bfe52..901a409a 100644 --- a/src/server/InputPort.cpp +++ b/src/server/InputPort.cpp @@ -175,12 +175,11 @@ InputPort::pre_process(Context& context) if (_edges.empty()) { for (uint32_t v = 0; v < _poly; ++v) { - buffer(v)->prepare_read(context); + update_set_state(context, v); } } else if (direct_connect()) { for (uint32_t v = 0; v < _poly; ++v) { _buffers->at(v) = _edges.front().buffer(v); - _buffers->at(v)->prepare_read(context); } } else { uint32_t max_num_srcs = 1; @@ -196,7 +195,6 @@ InputPort::pre_process(Context& context) } mix(context, bufs().uris(), buffer(v).get(), srcs, num_srcs); - buffer(v)->prepare_read(context); } } diff --git a/src/server/InputPort.hpp b/src/server/InputPort.hpp index 0dbf3550..db614efa 100644 --- a/src/server/InputPort.hpp +++ b/src/server/InputPort.hpp @@ -92,7 +92,7 @@ public: protected: size_t _num_edges; ///< Pre-process thread - Edges _edges; + Edges _edges; ///< Audio thread }; } // namespace Server diff --git a/src/server/JackDriver.cpp b/src/server/JackDriver.cpp index 78600b77..8d030bf3 100644 --- a/src/server/JackDriver.cpp +++ b/src/server/JackDriver.cpp @@ -162,7 +162,6 @@ JackPort::post_process(ProcessContext& context) } else if (_patch_port->buffer_type() == _patch_port->bufs().uris().atom_Sequence) { Buffer* patch_buf = (Buffer*)_patch_port->buffer(0).get(); - patch_buf->prepare_read(context); jack_midi_clear_buffer(_buffer); LV2_Atom_Sequence* seq = (LV2_Atom_Sequence*)patch_buf->atom(); diff --git a/src/server/LV2Node.cpp b/src/server/LV2Node.cpp index 5861a068..367d438c 100644 --- a/src/server/LV2Node.cpp +++ b/src/server/LV2Node.cpp @@ -101,8 +101,8 @@ LV2Node::make_instance(URIs& uris, if (buffer) { if (port->is_a(PortType::CV) || port->is_a(PortType::CONTROL)) { - ((AudioBuffer*)buffer)->set_value( - port->value().get_float(), 0, 0); + AudioBuffer* abuf = (AudioBuffer*)buffer; + abuf->set_block(port->value().get_float(), 0, abuf->nframes() - 1); } else { buffer->clear(); } diff --git a/src/server/NodeImpl.cpp b/src/server/NodeImpl.cpp index 914d9906..57c2d075 100644 --- a/src/server/NodeImpl.cpp +++ b/src/server/NodeImpl.cpp @@ -82,17 +82,7 @@ NodeImpl::activate(BufferFactory& bufs) PortImpl* const port = _ports->at(p); port->setup_buffers(bufs.engine().message_context(), bufs, port->poly()); port->connect_buffers(); - for (uint32_t v = 0; v < _polyphony; ++v) { - Buffer* const buf = port->buffer(v).get(); - if (buf) { - if (port->is_a(PortType::CONTROL) || port->is_a(PortType::CV)) { - ((AudioBuffer*)buf)->set_value( - port->value().get_float(), 0, 0); - } else { - buf->clear(); - } - } - } + port->clear_buffers(); } } diff --git a/src/server/OutputPort.cpp b/src/server/OutputPort.cpp index 4c790c0b..6b5ba5ed 100644 --- a/src/server/OutputPort.cpp +++ b/src/server/OutputPort.cpp @@ -69,8 +69,9 @@ OutputPort::pre_process(Context& context) void OutputPort::post_process(Context& context) { - for (uint32_t v = 0; v < _poly; ++v) - _buffers->at(v)->prepare_read(context); + for (uint32_t v = 0; v < _poly; ++v) { + update_set_state(context, v); + } if (_broadcast) broadcast_value(context, false); diff --git a/src/server/PortImpl.cpp b/src/server/PortImpl.cpp index 8c044d7b..5a4ca349 100644 --- a/src/server/PortImpl.cpp +++ b/src/server/PortImpl.cpp @@ -52,6 +52,8 @@ PortImpl::PortImpl(BufferFactory& bufs, , _min(bufs.forge().make(0.0f)) , _max(bufs.forge().make(1.0f)) , _last_broadcasted_value(value) + , _set_states(new Raul::Array<SetState>(static_cast<size_t>(poly))) + , _prepared_set_states(NULL) , _buffers(new Raul::Array<BufferRef>(static_cast<size_t>(poly))) , _prepared_buffers(NULL) , _broadcast(false) @@ -132,6 +134,62 @@ PortImpl::cache_properties() _bufs.uris().lv2_toggled); } +void +PortImpl::set_control_value(Context& context, FrameTime time, Sample value) +{ + for (uint32_t v = 0; v < poly(); ++v) { + set_voice_value(context, v, time, value); + } +} + +void +PortImpl::set_voice_value(Context& context, uint32_t voice, FrameTime time, Sample value) +{ + // Time may be at end so internal nodes can set single sample triggers + assert(time >= context.start()); + assert(time <= context.start() + context.nframes()); + + if (_type == PortType::CONTROL) { + time = context.start(); + } + + FrameTime offset = time - context.start(); + FrameTime last = (_type == PortType::CONTROL) ? 0 : context.nframes() - 1; + if (offset < context.nframes()) { + AudioBuffer* const abuf = dynamic_cast<AudioBuffer*>(buffer(voice).get()); + abuf->set_block(value, offset, last); + } // else trigger at very end of block, and set to 0 at start of next block + + SetState& state = _set_states->at(voice); + state.state = (offset == 0) ? SetState::SET : SetState::HALF_SET_CYCLE_1; + state.time = time; + state.value = value; +} + +void +PortImpl::update_set_state(Context& context, uint32_t voice) +{ + SetState& state = _set_states->at(voice); + switch (state.state) { + case SetState::HALF_SET_CYCLE_1: + if (context.start() > state.time) { + state.state = SetState::HALF_SET_CYCLE_2; + } + break; + case SetState::HALF_SET_CYCLE_2: { + AudioBuffer* const abuf = dynamic_cast<AudioBuffer*>(buffer(voice).get()); + abuf->set_block(state.value, 0, context.nframes() - 1); + for (unsigned i = 0; i < context.nframes(); ++i) { + assert(abuf->data()[i] == state.value); + } + state.state = SetState::SET; + break; + } + default: + break; + } +} + bool PortImpl::prepare_poly(BufferFactory& bufs, uint32_t poly) { @@ -150,10 +208,18 @@ PortImpl::prepare_poly(BufferFactory& bufs, uint32_t poly) delete _prepared_buffers; _prepared_buffers = NULL; } + + if (_prepared_set_states && _prepared_set_states->size() != poly) { + delete _prepared_set_states; + _prepared_set_states = NULL; + } if (!_prepared_buffers) _prepared_buffers = new Raul::Array<BufferRef>(poly, *_buffers, NULL); + if (!_prepared_set_states) + _prepared_set_states = new Raul::Array<SetState>(poly, *_set_states, SetState()); + get_buffers(bufs.engine().message_context(), bufs, _prepared_buffers, @@ -176,6 +242,7 @@ PortImpl::apply_poly(ProcessContext& context, Raul::Maid& maid, uint32_t poly) } assert(poly == _prepared_buffers->size()); + assert(poly == _prepared_set_states->size()); _poly = poly; @@ -184,15 +251,19 @@ PortImpl::apply_poly(ProcessContext& context, Raul::Maid& maid, uint32_t poly) assert(_buffers == _prepared_buffers); _prepared_buffers = NULL; - if (is_a(PortType::CONTROL) || is_a(PortType::CV)) - for (uint32_t v = 0; v < _poly; ++v) - if (_buffers->at(v)) - boost::static_pointer_cast<AudioBuffer>( - _buffers->at(v))->set_value(_value.get_float(), 0, 0); + maid.push(_set_states); + _set_states = _prepared_set_states; + _prepared_set_states = NULL; + + if (is_a(PortType::CONTROL) || is_a(PortType::CV)) { + set_control_value(context, context.start(), _value.get_float()); + } assert(_buffers->size() >= poly); + assert(_set_states->size() >= poly); assert(this->poly() == poly); assert(!_prepared_buffers); + assert(!_prepared_set_states); return true; } @@ -225,8 +296,24 @@ PortImpl::recycle_buffers() void PortImpl::clear_buffers() { - for (uint32_t v = 0; v < _poly; ++v) - buffer(v)->clear(); + switch (_type.symbol()) { + case PortType::AUDIO: + case PortType::CONTROL: + case PortType::CV: + for (uint32_t v = 0; v < _poly; ++v) { + AudioBuffer* abuf = (AudioBuffer*)buffer(0).get(); + abuf->set_block(_value.get_float(), 0, abuf->nframes() - 1); + SetState& state = _set_states->at(v); + state.state = SetState::SET; + state.value = _value.get_float(); + state.time = 0; + } + break; + default: + for (uint32_t v = 0; v < _poly; ++v) { + buffer(v)->clear(); + } + } } void diff --git a/src/server/PortImpl.hpp b/src/server/PortImpl.hpp index 459c1858..f4a8975b 100644 --- a/src/server/PortImpl.hpp +++ b/src/server/PortImpl.hpp @@ -98,6 +98,15 @@ public: return _prepared_buffers->at(voice); } + void update_set_state(Context& context, uint32_t voice); + + void set_voice_value(Context& context, + uint32_t voice, + FrameTime time, + Sample value); + + void set_control_value(Context& context, FrameTime time, Sample value); + /** Called once per process cycle */ virtual void pre_process(Context& context) = 0; virtual void post_process(Context& context) = 0; @@ -175,6 +184,16 @@ protected: const Raul::Atom& value, size_t buffer_size); + struct SetState { + enum State { SET, HALF_SET_CYCLE_1, HALF_SET_CYCLE_2 }; + + SetState() : state(SET), value(0), time(0) {} + + State state; ///< State of buffer for setting control value + Sample value; ///< Value currently being set + FrameTime time; ///< Time value was set + }; + BufferFactory& _bufs; uint32_t _index; uint32_t _poly; @@ -185,6 +204,8 @@ protected: Raul::Atom _min; Raul::Atom _max; Raul::Atom _last_broadcasted_value; + Raul::Array<SetState>* _set_states; + Raul::Array<SetState>* _prepared_set_states; Raul::Array<BufferRef>* _buffers; Raul::Array<BufferRef>* _prepared_buffers; bool _broadcast; diff --git a/src/server/events/Delta.cpp b/src/server/events/Delta.cpp index 6892ccbc..b1408d7a 100644 --- a/src/server/events/Delta.cpp +++ b/src/server/events/Delta.cpp @@ -38,7 +38,7 @@ #define LOG(s) s << "[Delta] " // #define DUMP 1 -// #include "ingen/URIMap.hpp" +#include "ingen/URIMap.hpp" namespace Ingen { namespace Server { diff --git a/src/server/events/Disconnect.cpp b/src/server/events/Disconnect.cpp index e797c6a7..413ded5f 100644 --- a/src/server/events/Disconnect.cpp +++ b/src/server/events/Disconnect.cpp @@ -101,7 +101,8 @@ Disconnect::Impl::Impl(Engine& e, const float value = is_control ? _dst_input_port->value().get_float() : 0; for (uint32_t i = 0; i < _buffers->size(); ++i) { if (is_control) { - PtrCast<AudioBuffer>(_buffers->at(i))->set_value(value, 0, 0); + AudioBuffer* abuf = dynamic_cast<AudioBuffer*>(_buffers->at(i).get()); + abuf->set_block(value, 0, abuf->nframes() - 1); } else { _buffers->at(i)->clear(); } diff --git a/src/server/events/SetPortValue.cpp b/src/server/events/SetPortValue.cpp index 52d17c32..f2fa48f3 100644 --- a/src/server/events/SetPortValue.cpp +++ b/src/server/events/SetPortValue.cpp @@ -99,17 +99,13 @@ SetPortValue::apply(Context& context) Ingen::URIs& uris = _engine.world()->uris(); Buffer* const buf = _port->buffer(0).get(); - AudioBuffer* const abuf = dynamic_cast<AudioBuffer*>(buf); - if (abuf) { + if (buf->type() == uris.atom_Sound || buf->type() == uris.atom_Float) { if (_value.type() != uris.forge.Float) { _status = TYPE_MISMATCH; return; } - for (uint32_t v = 0; v < _port->poly(); ++v) { - ((AudioBuffer*)_port->buffer(v).get())->set_value( - _value.get_float(), context.start(), _time); - } + _port->set_control_value(context, _time, _value.get_float()); } else if (buf->type() == uris.atom_Sequence) { buf->prepare_write(context); // FIXME: incorrect if (buf->append_event(_time - context.start(), diff --git a/src/server/internals/Controller.cpp b/src/server/internals/Controller.cpp index 85f69442..571918fe 100644 --- a/src/server/internals/Controller.cpp +++ b/src/server/internals/Controller.cpp @@ -117,8 +117,7 @@ ControllerNode::control(ProcessContext& context, uint8_t control_num, uint8_t va if (_learning) { // FIXME: not thread safe _param_port->set_value(context.engine().world()->forge().make(control_num)); - ((AudioBuffer*)_param_port->buffer(0).get())->set_value( - (float)control_num, context.start(), context.end()); + _param_port->set_control_value(context, time, control_num); _param_port->broadcast_value(context, true); _learning = false; } @@ -139,8 +138,9 @@ ControllerNode::control(ProcessContext& context, uint8_t control_num, uint8_t va scaled_value = ((nval) * (max_port_val - min_port_val)) + min_port_val; } - if (control_num == ((AudioBuffer*)_param_port->buffer(0).get())->value_at(0)) - ((AudioBuffer*)_audio_port->buffer(0).get())->set_value(scaled_value, context.start(), time); + if (control_num == ((AudioBuffer*)_param_port->buffer(0).get())->value_at(0)) { + _audio_port->set_control_value(context, time, scaled_value); + } } } // namespace Internals diff --git a/src/server/internals/Note.cpp b/src/server/internals/Note.cpp index 1292686d..e72e2d38 100644 --- a/src/server/internals/Note.cpp +++ b/src/server/internals/Note.cpp @@ -259,18 +259,11 @@ NoteNode::note_on(ProcessContext& context, uint8_t note_num, uint8_t velocity, F assert(_keys[voice->note].state == Key::Key::ON_ASSIGNED); assert(_keys[voice->note].voice == voice_num); - ((AudioBuffer*)_freq_port->buffer(voice_num).get())->set_value( - note_to_freq(note_num), context.start(), time); - ((AudioBuffer*)_vel_port->buffer(voice_num).get())->set_value( - velocity/127.0, context.start(), time); - ((AudioBuffer*)_gate_port->buffer(voice_num).get())->set_value( - 1.0f, context.start(), time); - - // trigger (one sample) - ((AudioBuffer*)_trig_port->buffer(voice_num).get())->set_value( - 1.0f, context.start(), time); - ((AudioBuffer*)_trig_port->buffer(voice_num).get())->set_value( - 0.0f, context.start(), time + 1); + _freq_port->set_voice_value(context, voice_num, time, note_to_freq(note_num)); + _vel_port->set_voice_value(context, voice_num, time, velocity / 127.0f); + _gate_port->set_voice_value(context, voice_num, time, 1.0f); + _trig_port->set_voice_value(context, voice_num, time, 1.0f); + _trig_port->set_voice_value(context, voice_num, time + 1, 0.0f); assert(key->state == Key::Key::ON_ASSIGNED); assert(voice->state == Voice::Voice::ACTIVE); @@ -339,7 +332,7 @@ NoteNode::free_voice(ProcessContext& context, uint32_t voice, FrameTime time) assert(replace_key->state == Key::ON_UNASSIGNED); // Change the freq but leave the gate high and don't retrigger - ((AudioBuffer*)_freq_port->buffer(voice).get())->set_value(note_to_freq(replace_key_num), context.start(), time); + _freq_port->set_voice_value(context, voice, time, note_to_freq(replace_key_num)); replace_key->state = Key::ON_ASSIGNED; replace_key->voice = voice; @@ -351,7 +344,7 @@ NoteNode::free_voice(ProcessContext& context, uint32_t voice, FrameTime time) #ifdef NOTE_DEBUG LOG(Raul::debug) << "Note off: key " << (int)(*_voices)[voice].note << " voice " << voice << endl; #endif - ((AudioBuffer*)_gate_port->buffer(voice).get())->set_value(0.0f, context.start(), time); + _gate_port->set_voice_value(context, voice, time, 0.0f); (*_voices)[voice].state = Voice::FREE; } } @@ -368,7 +361,7 @@ NoteNode::all_notes_off(ProcessContext& context, FrameTime time) // FIXME: set all keys to Key::OFF? for (uint32_t i = 0; i < _polyphony; ++i) { - ((AudioBuffer*)_gate_port->buffer(i).get())->set_value(0.0f, context.start(), time); + _gate_port->set_voice_value(context, i, time, 0.0f); (*_voices)[i].state = Voice::FREE; } } diff --git a/src/server/internals/Trigger.cpp b/src/server/internals/Trigger.cpp index 699c31f1..4c4c6ab6 100644 --- a/src/server/internals/Trigger.cpp +++ b/src/server/internals/Trigger.cpp @@ -23,6 +23,7 @@ #include "raul/midi_events.h" #include "AudioBuffer.hpp" +#include "Engine.hpp" #include "InputPort.hpp" #include "InternalPlugin.hpp" #include "OutputPort.hpp" @@ -114,8 +115,7 @@ TriggerNode::process(ProcessContext& context) case MIDI_CMD_CONTROL: if (buf[1] == MIDI_CTL_ALL_NOTES_OFF || buf[1] == MIDI_CTL_ALL_SOUNDS_OFF) { - ((AudioBuffer*)_gate_port->buffer(0).get())->set_value( - 0.0f, context.start(), time); + _gate_port->set_control_value(context, time, 0.0f); } default: break; @@ -132,10 +132,9 @@ TriggerNode::note_on(ProcessContext& context, uint8_t note_num, uint8_t velocity assert(time >= context.start() && time <= context.end()); if (_learning) { - // FIXME - //_note_port->set_value(note_num); - ((AudioBuffer*)_note_port->buffer(0).get())->set_value( - (float)note_num, context.start(), context.end()); + // FIXME: not thread safe + _note_port->set_value(context.engine().world()->forge().make(note_num)); + _note_port->set_control_value(context, time, note_num); _note_port->broadcast_value(context, true); _learning = false; } @@ -146,10 +145,10 @@ TriggerNode::note_on(ProcessContext& context, uint8_t note_num, uint8_t velocity Sample filter_note = ((AudioBuffer*)_note_port->buffer(0).get())->value_at(0); if (filter_note >= 0.0 && filter_note < 127.0 && (note_num == (uint8_t)filter_note)) { - ((AudioBuffer*)_gate_port->buffer(0).get())->set_value(1.0f, context.start(), time); - ((AudioBuffer*)_trig_port->buffer(0).get())->set_value(1.0f, context.start(), time); - ((AudioBuffer*)_trig_port->buffer(0).get())->set_value(0.0f, context.start(), time + 1); - ((AudioBuffer*)_vel_port->buffer(0).get())->set_value(velocity / 127.0f, context.start(), time); + _gate_port->set_control_value(context, time, 1.0f); + _trig_port->set_control_value(context, time, 1.0f); + _trig_port->set_control_value(context, time + 1, 0.0f); + _vel_port->set_control_value(context, time, velocity / 127.0f); assert(((AudioBuffer*)_trig_port->buffer(0).get())->data()[time - context.start()] == 1.0f); } } @@ -160,7 +159,7 @@ TriggerNode::note_off(ProcessContext& context, uint8_t note_num, FrameTime time) assert(time >= context.start() && time <= context.end()); if (note_num == lrintf(((AudioBuffer*)_note_port->buffer(0).get())->value_at(0))) - ((AudioBuffer*)_gate_port->buffer(0).get())->set_value(0.0f, context.start(), time); + _gate_port->set_control_value(context, time, 0.0f); } } // namespace Internals |