diff options
author | David Robillard <d@drobilla.net> | 2012-07-31 15:12:38 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2012-07-31 15:12:38 +0000 |
commit | 8d559e4991a491b612e63d5a4deff0ab48a3d3dd (patch) | |
tree | 06da8b1d71f8068f12bc3f476b90734b67d9120c /src | |
parent | a41af6e41d60f8724809486b94ce1e6281c3bc31 (diff) | |
download | ingen-8d559e4991a491b612e63d5a4deff0ab48a3d3dd.tar.gz ingen-8d559e4991a491b612e63d5a4deff0ab48a3d3dd.tar.bz2 ingen-8d559e4991a491b612e63d5a4deff0ab48a3d3dd.zip |
Merge AudioBuffer into Buffer and avoid all the casting.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4584 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r-- | src/server/AudioBuffer.cpp | 112 | ||||
-rw-r--r-- | src/server/AudioBuffer.hpp | 76 | ||||
-rw-r--r-- | src/server/Buffer.cpp | 68 | ||||
-rw-r--r-- | src/server/Buffer.hpp | 34 | ||||
-rw-r--r-- | src/server/BufferFactory.cpp | 21 | ||||
-rw-r--r-- | src/server/ControlBindings.cpp | 1 | ||||
-rw-r--r-- | src/server/JackDriver.cpp | 14 | ||||
-rw-r--r-- | src/server/LV2Node.cpp | 4 | ||||
-rw-r--r-- | src/server/NodeImpl.cpp | 2 | ||||
-rw-r--r-- | src/server/PortImpl.cpp | 18 | ||||
-rw-r--r-- | src/server/events/Disconnect.cpp | 5 | ||||
-rw-r--r-- | src/server/events/SetPortValue.cpp | 1 | ||||
-rw-r--r-- | src/server/ingen_lv2.cpp | 13 | ||||
-rw-r--r-- | src/server/internals/Controller.cpp | 9 | ||||
-rw-r--r-- | src/server/internals/Delay.cpp | 13 | ||||
-rw-r--r-- | src/server/internals/Note.cpp | 1 | ||||
-rw-r--r-- | src/server/internals/Trigger.cpp | 7 | ||||
-rw-r--r-- | src/server/mix.cpp | 11 | ||||
-rw-r--r-- | src/server/wscript | 1 |
19 files changed, 141 insertions, 270 deletions
diff --git a/src/server/AudioBuffer.cpp b/src/server/AudioBuffer.cpp deleted file mode 100644 index 719b06e3..00000000 --- a/src/server/AudioBuffer.cpp +++ /dev/null @@ -1,112 +0,0 @@ -/* - This file is part of Ingen. - Copyright 2007-2012 David Robillard <http://drobilla.net/> - - Ingen is free software: you can redistribute it and/or modify it under the - terms of the GNU Affero General Public License as published by the Free - Software Foundation, either version 3 of the License, or any later version. - - Ingen is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU Affero General Public License for details. - - You should have received a copy of the GNU Affero General Public License - along with Ingen. If not, see <http://www.gnu.org/licenses/>. -*/ - -#include <assert.h> -#include <stddef.h> -#include <stdint.h> - -#include "lv2/lv2plug.in/ns/ext/atom/atom.h" - -#include "AudioBuffer.hpp" - -using namespace std; - -/* TODO: Be sure these functions are vectorized by GCC when its vectorizer - * stops sucking. Probably a good idea to inline them as well */ - -namespace Ingen { -namespace Server { - -AudioBuffer::AudioBuffer(BufferFactory& bufs, LV2_URID type, uint32_t size) - : Buffer(bufs, type, size) -{ - assert(size >= sizeof(LV2_Atom) + sizeof(Sample)); - assert(this->capacity() >= size); - assert(data()); - - if (type == bufs.uris().atom_Sound) { - // Audio port (Vector of float) - LV2_Atom_Vector* vec = (LV2_Atom_Vector*)_atom; - vec->body.child_size = sizeof(float); - vec->body.child_type = bufs.uris().atom_Float; - } - - _atom->size = size - sizeof(LV2_Atom); - _atom->type = type; - - clear(); -} - -/** Empty (ie zero) the buffer. - */ -void -AudioBuffer::clear() -{ - assert(nframes() != 0); - set_block(0, 0, nframes() - 1); -} - -/** Set a block of buffer to @a val. - * - * @a start_sample and @a end_sample define the inclusive range to be set. - */ -void -AudioBuffer::set_block(Sample val, size_t start_offset, size_t end_offset) -{ - assert(end_offset >= start_offset); - assert(end_offset < nframes()); - - Sample* const buf = data(); - assert(buf); - - for (size_t i = start_offset; i <= end_offset; ++i) - buf[i] = val; -} - -void -AudioBuffer::copy(Context& context, const Buffer* src) -{ - const AudioBuffer* src_abuf = dynamic_cast<const AudioBuffer*>(src); - if (!src_abuf) { - clear(); - return; - } - - if (src_abuf->is_control() == is_control()) { - // Rates match, direct copy - Buffer::copy(context, src); - } else if (!src_abuf->is_control() && is_control()) { - // Audio => Control - data()[0] = src_abuf->data()[context.offset()]; - } else if (src_abuf->is_control() && !is_control()) { - // Control => Audio - data()[context.offset()] = src_abuf->data()[0]; - } -} - -float -AudioBuffer::peak(Context& context) const -{ - float peak = 0.0f; - // FIXME: use context time range? - for (FrameTime i = 0; i < nframes(); ++i) { - peak = fmaxf(peak, value_at(i)); - } - return peak; -} - -} // namespace Server -} // namespace Ingen diff --git a/src/server/AudioBuffer.hpp b/src/server/AudioBuffer.hpp deleted file mode 100644 index ca519650..00000000 --- a/src/server/AudioBuffer.hpp +++ /dev/null @@ -1,76 +0,0 @@ -/* - This file is part of Ingen. - Copyright 2007-2012 David Robillard <http://drobilla.net/> - - Ingen is free software: you can redistribute it and/or modify it under the - terms of the GNU Affero General Public License as published by the Free - Software Foundation, either version 3 of the License, or any later version. - - Ingen is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU Affero General Public License for details. - - You should have received a copy of the GNU Affero General Public License - along with Ingen. If not, see <http://www.gnu.org/licenses/>. -*/ - -#ifndef INGEN_ENGINE_AUDIOBUFFER_HPP -#define INGEN_ENGINE_AUDIOBUFFER_HPP - -#include <cassert> -#include <cmath> -#include <cstddef> - -#include <boost/utility.hpp> - -#include "ingen/URIs.hpp" - -#include "Buffer.hpp" -#include "BufferFactory.hpp" -#include "Context.hpp" -#include "types.hpp" - -namespace Ingen { -namespace Server { - -class AudioBuffer : public Buffer -{ -public: - AudioBuffer(BufferFactory& bufs, LV2_URID type, uint32_t size); - - void clear(); - - void set_block(Sample val, size_t start_offset, size_t end_offset); - void copy(Context& context, const Buffer* src); - - float peak(Context& context) const; - - inline bool is_control() const { return _type == _factory.uris().atom_Float; } - - inline Sample* data() const { - return (is_control()) - ? (Sample*)LV2_ATOM_BODY(atom()) - : (Sample*)LV2_ATOM_CONTENTS(LV2_Atom_Vector, atom()); - } - - inline SampleCount nframes() const { - return (is_control()) - ? 1 - : (_capacity - sizeof(LV2_Atom_Vector)) / sizeof(Sample); - } - - inline Sample& value_at(size_t offset) const { - assert(offset < nframes()); - return data()[offset]; - } - - void prepare_write(Context& context) {} - -private: - LV2_Atom_Vector* vector() { return (LV2_Atom_Vector*)atom(); } -}; - -} // namespace Server -} // namespace Ingen - -#endif // INGEN_ENGINE_AUDIOBUFFER_HPP diff --git a/src/server/Buffer.cpp b/src/server/Buffer.cpp index e877533a..4de832e9 100644 --- a/src/server/Buffer.cpp +++ b/src/server/Buffer.cpp @@ -17,6 +17,7 @@ #define __STDC_LIMIT_MACROS 1 #include <assert.h> +#include <math.h> #include <stdint.h> #include <string.h> @@ -56,8 +57,15 @@ Buffer::Buffer(BufferFactory& bufs, LV2_URID type, uint32_t capacity) } memset(_atom, 0, capacity); + _atom->size = capacity - sizeof(LV2_Atom); _atom->type = type; - assert(_atom->type != 1); + + if (type == bufs.uris().atom_Sound) { + // Audio port (Vector of float) + LV2_Atom_Vector* vec = (LV2_Atom_Vector*)_atom; + vec->body.child_size = sizeof(float); + vec->body.child_type = bufs.uris().atom_Float; + } clear(); } @@ -67,6 +75,24 @@ Buffer::~Buffer() free(_atom); } +bool +Buffer::is_audio() const +{ + return _type == _factory.uris().atom_Sound; +} + +bool +Buffer::is_control() const +{ + return _type == _factory.uris().atom_Float; +} + +bool +Buffer::is_sequence() const +{ + return _type == _factory.uris().atom_Sequence; +} + void Buffer::recycle() { @@ -76,17 +102,38 @@ Buffer::recycle() void Buffer::clear() { - _atom->size = 0; + if (is_audio() || is_control()) { + _atom->size = _capacity - sizeof(LV2_Atom); + set_block(0, 0, nframes() - 1); + } else if (is_sequence()) { + _atom->size = sizeof(LV2_Atom_Sequence_Body); + } } void Buffer::copy(Context& context, const Buffer* src) { - // Copy only if src is a POD object that fits - if (src->_atom->type != 0 && sizeof(LV2_Atom) + src->_atom->size <= capacity()) { + if (_type == src->type() && src->_atom->size + sizeof(LV2_Atom) <= _capacity) { memcpy(_atom, src->_atom, sizeof(LV2_Atom) + src->_atom->size); + } else if (src->is_audio() && is_control()) { + samples()[0] = src->samples()[context.offset()]; + } else if (src->is_control() && is_audio()) { + samples()[context.offset()] = src->samples()[0]; + } else { + clear(); + } +} + +void +Buffer::set_block(Sample val, size_t start_offset, size_t end_offset) +{ + assert(end_offset >= start_offset); + assert(end_offset < nframes()); + + Sample* const buf = samples(); + for (size_t i = start_offset; i <= end_offset; ++i) { + buf[i] = val; } - assert(_atom->type != 1); } void @@ -130,6 +177,17 @@ Buffer::port_data(PortType port_type, SampleCount offset) const const_cast<Buffer*>(this)->port_data(port_type, offset)); } +float +Buffer::peak(const Context& context) const +{ + float peak = 0.0f; + const Sample* const buf = samples(); + for (FrameTime i = 0; i < context.nframes(); ++i) { + peak = fmaxf(peak, buf[i]); + } + return peak; +} + void Buffer::prepare_write(Context& context) { diff --git a/src/server/Buffer.hpp b/src/server/Buffer.hpp index 84eaf516..d9c9b36f 100644 --- a/src/server/Buffer.hpp +++ b/src/server/Buffer.hpp @@ -43,9 +43,14 @@ class Buffer : public boost::noncopyable, public Raul::Deletable public: Buffer(BufferFactory& bufs, LV2_URID type, uint32_t capacity); + bool is_audio() const; + bool is_control() const; + bool is_sequence() const; + virtual void clear(); virtual void resize(uint32_t size); virtual void copy(Context& context, const Buffer* src); + virtual void set_block(Sample val, size_t start_offset, size_t end_offset); virtual void prepare_write(Context& context); void* port_data(PortType port_type, SampleCount offset); @@ -54,6 +59,35 @@ public: LV2_URID type() const { return _type; } uint32_t capacity() const { return _capacity; } + /// Audio buffers only + inline Sample* samples() const { + if (is_control()) { + return (Sample*)LV2_ATOM_BODY(atom()); + } else if (is_audio()) { + return (Sample*)LV2_ATOM_CONTENTS(LV2_Atom_Vector, atom()); + } + return NULL; + } + + /// Audio buffers only + inline SampleCount nframes() const { + if (is_control()) { + return 1; + } else if (is_audio()) { + return (_capacity - sizeof(LV2_Atom_Vector)) / sizeof(Sample); + } + return 0; + } + + /// Audio buffers only + inline Sample& value_at(size_t offset) const { + assert(offset < nframes()); + return samples()[offset]; + } + + /// Audio buffers only + float peak(const Context& context) const; + /// Sequence buffers only void prepare_output_write(Context& context); diff --git a/src/server/BufferFactory.cpp b/src/server/BufferFactory.cpp index 59da152f..720a4639 100644 --- a/src/server/BufferFactory.cpp +++ b/src/server/BufferFactory.cpp @@ -17,7 +17,6 @@ #include "ingen/URIs.hpp" #include "raul/log.hpp" -#include "AudioBuffer.hpp" #include "BufferFactory.hpp" #include "Driver.hpp" #include "Engine.hpp" @@ -126,26 +125,16 @@ BufferFactory::silent_buffer() BufferRef BufferFactory::create(LV2_URID type, uint32_t capacity) { - Buffer* buffer = NULL; - if (capacity == 0) { capacity = default_size(type); } - if (type == _uris.atom_Float) { - assert(capacity >= sizeof(LV2_Atom_Float)); - buffer = new AudioBuffer(*this, type, capacity); - } else if (type == _uris.atom_Sound) { - assert(capacity >= default_size(_uris.atom_Sound)); - buffer = new AudioBuffer(*this, type, capacity); - } else { - buffer = new Buffer(*this, type, capacity); - } - - buffer->atom()->type = type; + assert(type != _uris.atom_Float || + capacity >= sizeof(LV2_Atom_Float)); + assert(type != _uris.atom_Sound || + capacity >= default_size(_uris.atom_Sound)); - assert(buffer); - return BufferRef(buffer); + return BufferRef(new Buffer(*this, type, capacity)); } void diff --git a/src/server/ControlBindings.cpp b/src/server/ControlBindings.cpp index 1bb0e5f6..4a4e1a04 100644 --- a/src/server/ControlBindings.cpp +++ b/src/server/ControlBindings.cpp @@ -23,7 +23,6 @@ #include "raul/log.hpp" #include "raul/midi_events.h" -#include "AudioBuffer.hpp" #include "ControlBindings.hpp" #include "Engine.hpp" #include "PortImpl.hpp" diff --git a/src/server/JackDriver.cpp b/src/server/JackDriver.cpp index b21a3c58..b3c2fc6c 100644 --- a/src/server/JackDriver.cpp +++ b/src/server/JackDriver.cpp @@ -33,7 +33,6 @@ #include "raul/List.hpp" #include "raul/log.hpp" -#include "AudioBuffer.hpp" #include "DuplexPort.hpp" #include "Engine.hpp" #include "JackDriver.hpp" @@ -112,13 +111,13 @@ JackPort::pre_process(ProcessContext& context) _buffer = jack_port_get_buffer(_jack_port, nframes); if (!is_input()) { - ((AudioBuffer*)_patch_port->buffer(0).get())->clear(); + _patch_port->buffer(0)->clear(); return; } if (_patch_port->is_a(PortType::AUDIO)) { - AudioBuffer* patch_buf = (AudioBuffer*)_patch_port->buffer(0).get(); - memcpy(patch_buf->data(), _buffer, nframes * sizeof(float)); + Buffer* patch_buf = _patch_port->buffer(0).get(); + memcpy(patch_buf->samples(), _buffer, nframes * sizeof(float)); } else if (_patch_port->buffer_type() == _patch_port->bufs().uris().atom_Sequence) { Buffer* patch_buf = (Buffer*)_patch_port->buffer(0).get(); @@ -155,12 +154,11 @@ JackPort::post_process(ProcessContext& context) _patch_port->post_process(context); if (_patch_port->is_a(PortType::AUDIO)) { - AudioBuffer* patch_buf = (AudioBuffer*)_patch_port->buffer(0).get(); - - memcpy(_buffer, patch_buf->data(), nframes * sizeof(Sample)); + Buffer* patch_buf = _patch_port->buffer(0).get(); + memcpy(_buffer, patch_buf->samples(), nframes * sizeof(Sample)); } else if (_patch_port->buffer_type() == _patch_port->bufs().uris().atom_Sequence) { - Buffer* patch_buf = (Buffer*)_patch_port->buffer(0).get(); + Buffer* patch_buf = _patch_port->buffer(0).get(); jack_midi_clear_buffer(_buffer); diff --git a/src/server/LV2Node.cpp b/src/server/LV2Node.cpp index 367d438c..5b2e2487 100644 --- a/src/server/LV2Node.cpp +++ b/src/server/LV2Node.cpp @@ -30,7 +30,6 @@ #include "ingen/URIMap.hpp" #include "ingen/URIs.hpp" -#include "AudioBuffer.hpp" #include "Driver.hpp" #include "Engine.hpp" #include "InputPort.hpp" @@ -101,8 +100,7 @@ LV2Node::make_instance(URIs& uris, if (buffer) { if (port->is_a(PortType::CV) || port->is_a(PortType::CONTROL)) { - AudioBuffer* abuf = (AudioBuffer*)buffer; - abuf->set_block(port->value().get_float(), 0, abuf->nframes() - 1); + buffer->set_block(port->value().get_float(), 0, buffer->nframes() - 1); } else { buffer->clear(); } diff --git a/src/server/NodeImpl.cpp b/src/server/NodeImpl.cpp index 57c2d075..791396c1 100644 --- a/src/server/NodeImpl.cpp +++ b/src/server/NodeImpl.cpp @@ -19,7 +19,7 @@ #include "raul/Array.hpp" -#include "AudioBuffer.hpp" +#include "BufferFactory.hpp" #include "Engine.hpp" #include "NodeImpl.hpp" #include "PatchImpl.hpp" diff --git a/src/server/PortImpl.cpp b/src/server/PortImpl.cpp index 5a4ca349..a336439f 100644 --- a/src/server/PortImpl.cpp +++ b/src/server/PortImpl.cpp @@ -19,7 +19,6 @@ #include "raul/Array.hpp" #include "raul/Maid.hpp" -#include "AudioBuffer.hpp" #include "BufferFactory.hpp" #include "Engine.hpp" #include "NodeImpl.hpp" @@ -156,8 +155,7 @@ PortImpl::set_voice_value(Context& context, uint32_t voice, FrameTime time, Samp 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); + buffer(voice)->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); @@ -177,11 +175,7 @@ PortImpl::update_set_state(Context& context, uint32_t voice) } 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); - } + buffer(voice)->set_block(state.value, 0, context.nframes() - 1); state.state = SetState::SET; break; } @@ -301,8 +295,8 @@ PortImpl::clear_buffers() 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); + Buffer* buf = buffer(v).get(); + buf->set_block(_value.get_float(), 0, buf->nframes() - 1); SetState& state = _set_states->at(v); state.state = SetState::SET; state.value = _value.get_float(); @@ -328,12 +322,12 @@ PortImpl::broadcast_value(Context& context, bool force) break; case PortType::AUDIO: key = uris.ingen_activity; - val = forge.make(((AudioBuffer*)buffer(0).get())->peak(context)); + val = forge.make(buffer(0)->peak(context)); break; case PortType::CONTROL: case PortType::CV: key = uris.ingen_value; - val = forge.make(((AudioBuffer*)buffer(0).get())->value_at(0)); + val = forge.make(buffer(0)->value_at(0)); break; case PortType::ATOM: if (_buffer_type == _bufs.uris().atom_Sequence) { diff --git a/src/server/events/Disconnect.cpp b/src/server/events/Disconnect.cpp index 413ded5f..c84dd7a3 100644 --- a/src/server/events/Disconnect.cpp +++ b/src/server/events/Disconnect.cpp @@ -22,7 +22,6 @@ #include "raul/Path.hpp" #include "raul/log.hpp" -#include "AudioBuffer.hpp" #include "Broadcaster.hpp" #include "EdgeImpl.hpp" #include "DuplexPort.hpp" @@ -101,8 +100,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) { - AudioBuffer* abuf = dynamic_cast<AudioBuffer*>(_buffers->at(i).get()); - abuf->set_block(value, 0, abuf->nframes() - 1); + Buffer* buf = _buffers->at(i).get(); + buf->set_block(value, 0, buf->nframes() - 1); } else { _buffers->at(i)->clear(); } diff --git a/src/server/events/SetPortValue.cpp b/src/server/events/SetPortValue.cpp index f2fa48f3..1ecdf285 100644 --- a/src/server/events/SetPortValue.cpp +++ b/src/server/events/SetPortValue.cpp @@ -19,7 +19,6 @@ #include "ingen/World.hpp" #include "raul/log.hpp" -#include "AudioBuffer.hpp" #include "Broadcaster.hpp" #include "ControlBindings.hpp" #include "Driver.hpp" diff --git a/src/server/ingen_lv2.cpp b/src/server/ingen_lv2.cpp index 8c8dce2c..feb63a3a 100644 --- a/src/server/ingen_lv2.cpp +++ b/src/server/ingen_lv2.cpp @@ -42,7 +42,6 @@ #include "raul/Thread.hpp" #include "raul/log.hpp" -#include "AudioBuffer.hpp" #include "EnginePort.hpp" #include "Driver.hpp" #include "Engine.hpp" @@ -100,11 +99,11 @@ public: if (_patch_port->is_a(PortType::AUDIO) || _patch_port->is_a(PortType::CV)) { - AudioBuffer* patch_buf = (AudioBuffer*)_patch_port->buffer(0).get(); - memcpy(patch_buf->data(), _buffer, context.nframes() * sizeof(float)); + Buffer* patch_buf = _patch_port->buffer(0).get(); + memcpy(patch_buf->samples(), _buffer, context.nframes() * sizeof(float)); } else if (_patch_port->is_a(PortType::CONTROL)) { - AudioBuffer* patch_buf = (AudioBuffer*)_patch_port->buffer(0).get(); - memcpy(patch_buf->data(), _buffer, sizeof(float)); + Buffer* patch_buf = _patch_port->buffer(0).get(); + memcpy(patch_buf->samples(), _buffer, sizeof(float)); } else { LV2_Atom_Sequence* seq = (LV2_Atom_Sequence*)_buffer; bool enqueued = false; @@ -136,8 +135,8 @@ public: } if (_patch_port->is_a(PortType::AUDIO)) { - AudioBuffer* patch_buf = (AudioBuffer*)_patch_port->buffer(0).get(); - memcpy((Sample*)_buffer, patch_buf->data(), context.nframes() * sizeof(Sample)); + Buffer* patch_buf = _patch_port->buffer(0).get(); + memcpy((Sample*)_buffer, patch_buf->samples(), context.nframes() * sizeof(Sample)); } } diff --git a/src/server/internals/Controller.cpp b/src/server/internals/Controller.cpp index 571918fe..6c0e6858 100644 --- a/src/server/internals/Controller.cpp +++ b/src/server/internals/Controller.cpp @@ -23,7 +23,6 @@ #include "lv2/lv2plug.in/ns/ext/atom/util.h" #include "raul/midi_events.h" -#include "AudioBuffer.hpp" #include "Engine.hpp" #include "InputPort.hpp" #include "InternalPlugin.hpp" @@ -122,9 +121,9 @@ ControllerNode::control(ProcessContext& context, uint8_t control_num, uint8_t va _learning = false; } - const Sample min_port_val = ((AudioBuffer*)_min_port->buffer(0).get())->value_at(0); - const Sample max_port_val = ((AudioBuffer*)_max_port->buffer(0).get())->value_at(0); - const Sample log_port_val = ((AudioBuffer*)_log_port->buffer(0).get())->value_at(0); + const Sample min_port_val = _min_port->buffer(0)->value_at(0); + const Sample max_port_val = _max_port->buffer(0)->value_at(0); + const Sample log_port_val = _log_port->buffer(0)->value_at(0); if (log_port_val > 0.0f) { // haaaaack, stupid negatives and logarithms @@ -138,7 +137,7 @@ 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)) { + if (control_num == _param_port->buffer(0)->value_at(0)) { _audio_port->set_control_value(context, time, scaled_value); } } diff --git a/src/server/internals/Delay.cpp b/src/server/internals/Delay.cpp index 9e7f0afd..f478bd67 100644 --- a/src/server/internals/Delay.cpp +++ b/src/server/internals/Delay.cpp @@ -25,7 +25,6 @@ #include "raul/log.hpp" #include "raul/midi_events.h" -#include "AudioBuffer.hpp" #include "Driver.hpp" #include "Engine.hpp" #include "InputPort.hpp" @@ -144,17 +143,17 @@ static inline float cube_interp(const float fr, const float inm1, const float void DelayNode::process(ProcessContext& context) { - AudioBuffer* const delay_buf = (AudioBuffer*)_delay_port->buffer(0).get(); - AudioBuffer* const in_buf = (AudioBuffer*)_in_port->buffer(0).get(); - AudioBuffer* const out_buf = (AudioBuffer*)_out_port->buffer(0).get(); + Buffer* const delay_buf = _delay_port->buffer(0).get(); + Buffer* const in_buf = _in_port->buffer(0).get(); + Buffer* const out_buf = _out_port->buffer(0).get(); NodeImpl::pre_process(context); DelayNode* plugin_data = this; - const float* const in = in_buf->data(); - float* const out = out_buf->data(); - const float delay_time = delay_buf->data()[0]; + const float* const in = in_buf->samples(); + float* const out = out_buf->samples(); + const float delay_time = delay_buf->samples()[0]; const uint32_t buffer_mask = plugin_data->_buffer_mask; const SampleRate sample_rate = context.engine().driver()->sample_rate(); float delay_samples = plugin_data->_delay_samples; diff --git a/src/server/internals/Note.cpp b/src/server/internals/Note.cpp index e72e2d38..3bb7273a 100644 --- a/src/server/internals/Note.cpp +++ b/src/server/internals/Note.cpp @@ -24,7 +24,6 @@ #include "raul/log.hpp" #include "raul/midi_events.h" -#include "AudioBuffer.hpp" #include "Driver.hpp" #include "InputPort.hpp" #include "InternalPlugin.hpp" diff --git a/src/server/internals/Trigger.cpp b/src/server/internals/Trigger.cpp index 4c4c6ab6..55184b1f 100644 --- a/src/server/internals/Trigger.cpp +++ b/src/server/internals/Trigger.cpp @@ -22,7 +22,6 @@ #include "raul/log.hpp" #include "raul/midi_events.h" -#include "AudioBuffer.hpp" #include "Engine.hpp" #include "InputPort.hpp" #include "InternalPlugin.hpp" @@ -143,13 +142,13 @@ TriggerNode::note_on(ProcessContext& context, uint8_t note_num, uint8_t velocity LOG(Raul::debug) << path() << " note " << (int)note_num << " on @ " << time << endl; #endif - Sample filter_note = ((AudioBuffer*)_note_port->buffer(0).get())->value_at(0); + Sample filter_note = _note_port->buffer(0)->value_at(0); if (filter_note >= 0.0 && filter_note < 127.0 && (note_num == (uint8_t)filter_note)) { _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); + assert(_trig_port->buffer(0)->samples()[time - context.start()] == 1.0f); } } @@ -158,7 +157,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))) + if (note_num == lrintf(_note_port->buffer(0)->value_at(0))) _gate_port->set_control_value(context, time, 0.0f); } diff --git a/src/server/mix.cpp b/src/server/mix.cpp index be1a9f9f..56cb4326 100644 --- a/src/server/mix.cpp +++ b/src/server/mix.cpp @@ -19,7 +19,6 @@ #include "ingen/URIs.hpp" #include "raul/log.hpp" -#include "AudioBuffer.hpp" #include "Buffer.hpp" #include "Context.hpp" @@ -27,10 +26,10 @@ namespace Ingen { namespace Server { static inline void -audio_accumulate(Context& context, AudioBuffer* dst, const AudioBuffer* src) +audio_accumulate(Context& context, Buffer* dst, const Buffer* src) { - Sample* const dst_buf = dst->data(); - const Sample* const src_buf = src->data(); + Sample* const dst_buf = dst->samples(); + const Sample* const src_buf = src->samples(); if (dst->is_control()) { if (src->is_control()) { // control => control @@ -83,9 +82,7 @@ mix(Context& context, // Mix in the rest for (uint32_t i = 1; i < num_srcs; ++i) { assert(is_audio(uris, srcs[i]->type())); - audio_accumulate(context, - (AudioBuffer*)dst, - (const AudioBuffer*)srcs[i]); + audio_accumulate(context, dst, srcs[i]); } } else { assert(dst->type() == uris.atom_Sequence); diff --git a/src/server/wscript b/src/server/wscript index 023408de..c333250a 100644 --- a/src/server/wscript +++ b/src/server/wscript @@ -3,7 +3,6 @@ from waflib.extras import autowaf as autowaf def build(bld): core_source = ''' - AudioBuffer.cpp Broadcaster.cpp Buffer.cpp BufferFactory.cpp |