diff options
author | David Robillard <d@drobilla.net> | 2017-03-20 03:04:15 +0100 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2017-03-20 03:19:33 +0100 |
commit | 59f579df71e52207bcdda15d4abb3562fdc1d6f2 (patch) | |
tree | 0b0749c2b7da1debffebca882bc46cb30ba1bacd /src | |
parent | 8bf529bb24c03ebdce884cf9a4288812bb9b2cd5 (diff) | |
download | ingen-59f579df71e52207bcdda15d4abb3562fdc1d6f2.tar.gz ingen-59f579df71e52207bcdda15d4abb3562fdc1d6f2.tar.bz2 ingen-59f579df71e52207bcdda15d4abb3562fdc1d6f2.zip |
Remove dubious Buffer::nframes() method
Diffstat (limited to 'src')
-rw-r--r-- | src/server/Buffer.hpp | 14 | ||||
-rw-r--r-- | src/server/LV2Block.cpp | 12 | ||||
-rw-r--r-- | src/server/PortImpl.cpp | 2 | ||||
-rw-r--r-- | src/server/events/Disconnect.cpp | 2 |
4 files changed, 11 insertions, 19 deletions
diff --git a/src/server/Buffer.hpp b/src/server/Buffer.hpp index 8742445f..939f1f87 100644 --- a/src/server/Buffer.hpp +++ b/src/server/Buffer.hpp @@ -101,16 +101,6 @@ public: return NULL; } - /// Audio buffers only - inline SampleCount nframes() const { - if (is_control()) { - return 1; - } else if (is_audio()) { - return (_capacity / sizeof(Sample)); - } - return 0; - } - /// Numeric buffers only inline Sample value_at(SampleCount offset) const { if (is_audio() || is_control()) { @@ -126,7 +116,7 @@ public: const SampleCount end) { assert(is_audio() || is_control()); - assert(end <= nframes()); + assert(end <= _capacity / sizeof(Sample)); // Note: Do not change this without ensuring GCC can still vectorize it Sample* const buf = samples() + start; for (SampleCount i = 0; i < (end - start); ++i) { @@ -139,7 +129,7 @@ public: const SampleCount end) { assert(is_audio() || is_control()); - assert(end <= nframes()); + assert(end <= _capacity / sizeof(Sample)); // Note: Do not change this without ensuring GCC can still vectorize it Sample* const buf = samples() + start; for (SampleCount i = 0; i < (end - start); ++i) { diff --git a/src/server/LV2Block.cpp b/src/server/LV2Block.cpp index 82e5f229..77835b67 100644 --- a/src/server/LV2Block.cpp +++ b/src/server/LV2Block.cpp @@ -81,14 +81,14 @@ LV2Block::make_instance(URIs& uris, uint32_t voice, bool preparing) { + const Engine& engine = parent_graph()->engine(); const LilvPlugin* lplug = _lv2_plugin->lilv_plugin(); LilvInstance* inst = lilv_plugin_instantiate( lplug, rate, _features->array()); if (!inst) { - parent_graph()->engine().log().error( - fmt("Failed to instantiate <%1%>\n") - % _lv2_plugin->uri().c_str()); + engine.log().error(fmt("Failed to instantiate <%1%>\n") + % _lv2_plugin->uri().c_str()); return SPtr<Instance>(); } @@ -116,8 +116,10 @@ LV2Block::make_instance(URIs& uris, } if (buffer) { - if (port->is_a(PortType::CV) || port->is_a(PortType::CONTROL)) { - buffer->set_block(port->value().get<float>(), 0, buffer->nframes()); + if (port->is_a(PortType::CONTROL)) { + buffer->samples()[0] = port->value().get<float>(); + } else if (port->is_a(PortType::CV)) { + buffer->set_block(port->value().get<float>(), 0, engine.block_length()); } else { buffer->clear(); } diff --git a/src/server/PortImpl.cpp b/src/server/PortImpl.cpp index 066ac005..45a5a082 100644 --- a/src/server/PortImpl.cpp +++ b/src/server/PortImpl.cpp @@ -415,7 +415,7 @@ PortImpl::clear_buffers(const RunContext& ctx) case PortType::CV: for (uint32_t v = 0; v < _poly; ++v) { Buffer* buf = buffer(v).get(); - buf->set_block(_value.get<float>(), 0, buf->nframes()); + buf->set_block(_value.get<float>(), 0, ctx.nframes()); SetState& state = _voices->at(v).set_state; state.state = SetState::State::SET; state.value = _value.get<float>(); diff --git a/src/server/events/Disconnect.cpp b/src/server/events/Disconnect.cpp index 176f0999..1411e666 100644 --- a/src/server/events/Disconnect.cpp +++ b/src/server/events/Disconnect.cpp @@ -96,7 +96,7 @@ Disconnect::Impl::Impl(Engine& e, const float value = _head->value().get<float>(); for (uint32_t i = 0; i < _voices->size(); ++i) { Buffer* buf = _voices->at(i).buffer.get(); - buf->set_block(value, 0, buf->nframes()); + buf->set_block(value, 0, e.block_length()); } } else { for (uint32_t i = 0; i < _voices->size(); ++i) { |