diff options
author | David Robillard <d@drobilla.net> | 2016-10-14 17:09:01 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2016-10-14 17:47:35 -0400 |
commit | 01e143ed3353de6ef2bd0e4648b9b2a1a72a9959 (patch) | |
tree | c8a87b597fb8f5ade1b508082c93d127ae578266 /src | |
parent | 8d92e5a38e141236b3687e8d775ee5d034127fb8 (diff) | |
download | ingen-01e143ed3353de6ef2bd0e4648b9b2a1a72a9959.tar.gz ingen-01e143ed3353de6ef2bd0e4648b9b2a1a72a9959.tar.bz2 ingen-01e143ed3353de6ef2bd0e4648b9b2a1a72a9959.zip |
Fix sequence ports with values
Diffstat (limited to 'src')
-rw-r--r-- | src/server/ArcImpl.cpp | 1 | ||||
-rw-r--r-- | src/server/Buffer.cpp | 22 | ||||
-rw-r--r-- | src/server/Buffer.hpp | 10 | ||||
-rw-r--r-- | src/server/InputPort.cpp | 6 | ||||
-rw-r--r-- | src/server/events/Delta.cpp | 5 | ||||
-rw-r--r-- | src/server/events/SetPortValue.cpp | 14 | ||||
-rw-r--r-- | src/server/events/SetPortValue.hpp | 2 | ||||
-rw-r--r-- | src/server/internals/Trigger.cpp | 2 |
8 files changed, 41 insertions, 21 deletions
diff --git a/src/server/ArcImpl.cpp b/src/server/ArcImpl.cpp index a351963e..8cdf02b4 100644 --- a/src/server/ArcImpl.cpp +++ b/src/server/ArcImpl.cpp @@ -67,7 +67,6 @@ ArcImpl::buffer(uint32_t voice, SampleCount offset) const _tail->update_values(offset, voice); // Update value buffer return _tail->value_buffer(voice); // Return value buffer } else if (_head->type() == PortType::CV) { - _tail->update_values(offset, voice); // Update initial value // Return full tail buffer below } } diff --git a/src/server/Buffer.cpp b/src/server/Buffer.cpp index e08510a5..1a1f804f 100644 --- a/src/server/Buffer.cpp +++ b/src/server/Buffer.cpp @@ -167,8 +167,10 @@ Buffer::copy(const RunContext& context, const Buffer* src) clear(); } - if (value() && src->value()) { - memcpy(value(), src->value(), lv2_atom_total_size(src->value())); + if (_value_buffer && src->_value_buffer) { + memcpy(_value_buffer->get<LV2_Atom>(), + src->value(), + lv2_atom_total_size(src->value())); } } else if (src->is_audio() && is_control()) { samples()[0] = src->samples()[0]; @@ -374,16 +376,24 @@ Buffer::value() const return _value_buffer ? _value_buffer->get<const LV2_Atom>() : NULL; } -LV2_Atom* -Buffer::value() +void +Buffer::set_value(const Atom& value) { - return _value_buffer ? _value_buffer->get<LV2_Atom>() : NULL; + if (!value.is_valid() || !_value_buffer) { + return; + } + + if (value.size() > _value_buffer->size()) { + _value_buffer = _factory.get_buffer(value.type(), 0, value.size(), false, false); + } + + memcpy(_value_buffer->get<LV2_Atom*>(), value.atom(), sizeof(LV2_Atom) + value.size()); } void Buffer::update_value_buffer(SampleCount offset) { - if (!_value_buffer) { + if (!_value_buffer || !_value_type) { return; } diff --git a/src/server/Buffer.hpp b/src/server/Buffer.hpp index 12556714..d60365f2 100644 --- a/src/server/Buffer.hpp +++ b/src/server/Buffer.hpp @@ -172,13 +172,15 @@ public: bool append_event(int64_t frames, const LV2_Atom* body); /// Value buffer for numeric sequences - BufferRef value_buffer() { return _value_buffer; } - const BufferRef value_buffer() const { return _value_buffer; } + BufferRef value_buffer() { return _value_buffer; } + /// Return the current value const LV2_Atom* value() const; - LV2_Atom* value(); - /// Return offset of the first value change after `offset`. + /// Set/initialise current value in value buffer + void set_value(const Atom& value); + + /// Return offset of the first value change after `offset` SampleCount next_value_offset(SampleCount offset, SampleCount end) const; /// Update value buffer to value as of offset diff --git a/src/server/InputPort.cpp b/src/server/InputPort.cpp index 7754a809..3bc1ed95 100644 --- a/src/server/InputPort.cpp +++ b/src/server/InputPort.cpp @@ -86,7 +86,7 @@ InputPort::get_buffers(BufferFactory& bufs, } return false; - } else if (num_arcs == 1) { + } else if (num_arcs == 1 && !is_a(PortType::ATOM)) { if (real_time) { if (!_arcs.front().must_mix()) { // Single non-mixing connection, use buffers directly @@ -104,6 +104,9 @@ InputPort::get_buffers(BufferFactory& bufs, voices->at(v).buffer = bufs.get_buffer( buffer_type(), _value.type(), _buffer_size, real_time); voices->at(v).buffer->clear(); + if (_value.is_valid()) { + voices->at(v).buffer->set_value(_value); + } } return true; } @@ -202,6 +205,7 @@ InputPort::pre_run(RunContext& context) // Then mix them into our buffer for this voice mix(context, buffer(v).get(), srcs, n_srcs); + update_values(context.offset(), v); } } } diff --git a/src/server/events/Delta.cpp b/src/server/events/Delta.cpp index d2c56f0c..ad4f78a1 100644 --- a/src/server/events/Delta.cpp +++ b/src/server/events/Delta.cpp @@ -97,7 +97,7 @@ Delta::add_set_event(const char* port_symbol, SetPortValue* ev = new SetPortValue( _engine, _request_client, _request_id, _time, - port, Atom(size, type, value), true); + port, Atom(size, type, value), false, true); _set_events.push_back(ev); } @@ -293,7 +293,8 @@ Delta::pre_process(PreProcessContext& ctx) } } else if (key == uris.ingen_value || key == uris.ingen_activity) { SetPortValue* ev = new SetPortValue( - _engine, _request_client, _request_id, _time, port, value); + _engine, _request_client, _request_id, _time, port, value, + key == uris.ingen_activity); _set_events.push_back(ev); } else if (key == uris.midi_binding) { if (port->is_a(PortType::CONTROL) || port->is_a(PortType::CV)) { diff --git a/src/server/events/SetPortValue.cpp b/src/server/events/SetPortValue.cpp index 2af9841b..4ab0271c 100644 --- a/src/server/events/SetPortValue.cpp +++ b/src/server/events/SetPortValue.cpp @@ -40,10 +40,12 @@ SetPortValue::SetPortValue(Engine& engine, SampleCount timestamp, PortImpl* port, const Atom& value, + bool activity, bool synthetic) : Event(engine, client, id, timestamp) , _port(port) , _value(value) + , _activity(activity) , _synthetic(synthetic) { } @@ -60,16 +62,18 @@ SetPortValue::pre_process(PreProcessContext& ctx) return Event::pre_process_done(Status::DIRECTION_MISMATCH, _port->path()); } - // Set value metadata (does not affect buffers) - _port->set_value(_value); - _port->set_property(_engine.world()->uris().ingen_value, _value); + if (!_activity) { + // Set value metadata (does not affect buffers) + _port->set_value(_value); + _port->set_property(_engine.world()->uris().ingen_value, _value); + } _binding = _engine.control_bindings()->port_binding(_port); if (_port->buffer_type() == uris.atom_Sequence) { _buffer = _engine.buffer_factory()->get_buffer( _port->buffer_type(), - _port->value_type(), + 0, _engine.buffer_factory()->default_size(_port->buffer_type()), false, false); @@ -129,7 +133,7 @@ void SetPortValue::post_process() { Broadcaster::Transfer t(*_engine.broadcaster()); - if (respond() == Status::SUCCESS) { + if (respond() == Status::SUCCESS && !_activity) { _engine.broadcaster()->set_property( _port->uri(), _engine.world()->uris().ingen_value, diff --git a/src/server/events/SetPortValue.hpp b/src/server/events/SetPortValue.hpp index 03902acb..07f1bbac 100644 --- a/src/server/events/SetPortValue.hpp +++ b/src/server/events/SetPortValue.hpp @@ -44,6 +44,7 @@ public: SampleCount timestamp, PortImpl* port, const Atom& value, + bool activity, bool synthetic = false); ~SetPortValue(); @@ -61,6 +62,7 @@ private: const Atom _value; BufferRef _buffer; ControlBindings::Key _binding; + bool _activity; bool _synthetic; }; diff --git a/src/server/internals/Trigger.cpp b/src/server/internals/Trigger.cpp index dc703271..68089283 100644 --- a/src/server/internals/Trigger.cpp +++ b/src/server/internals/Trigger.cpp @@ -160,7 +160,6 @@ TriggerNode::note_on(RunContext& context, uint8_t note_num, uint8_t velocity, Fr _learning = false; } - _note_port->update_values(offset, 0); 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); @@ -177,7 +176,6 @@ TriggerNode::note_off(RunContext& context, uint8_t note_num, FrameTime time) assert(time >= context.start() && time <= context.end()); const uint32_t offset = time - context.start(); - _note_port->update_values(offset, 0); if (note_num == lrintf(_note_port->buffer(0)->value_at(offset))) { _gate_port->set_control_value(context, time, 0.0f); return true; |