diff options
author | David Robillard <d@drobilla.net> | 2007-04-08 19:33:14 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2007-04-08 19:33:14 +0000 |
commit | c34d7b6e9354529b6e83c136857e798c63b256fe (patch) | |
tree | 5ff63c162597f026f81c82e22a77e02b7da10eea /src/libs | |
parent | 40e4cf5d669a654728881a00a3659fc3bca0e546 (diff) | |
download | ingen-c34d7b6e9354529b6e83c136857e798c63b256fe.tar.gz ingen-c34d7b6e9354529b6e83c136857e798c63b256fe.tar.bz2 ingen-c34d7b6e9354529b6e83c136857e798c63b256fe.zip |
Fixed audio output.
git-svn-id: http://svn.drobilla.net/lad/ingen@425 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/libs')
-rw-r--r-- | src/libs/engine/DuplexPort.cpp | 26 | ||||
-rw-r--r-- | src/libs/engine/InputPort.cpp | 82 | ||||
-rw-r--r-- | src/libs/engine/Patch.cpp | 17 |
3 files changed, 22 insertions, 103 deletions
diff --git a/src/libs/engine/DuplexPort.cpp b/src/libs/engine/DuplexPort.cpp index c498c774..a71f18b8 100644 --- a/src/libs/engine/DuplexPort.cpp +++ b/src/libs/engine/DuplexPort.cpp @@ -43,26 +43,24 @@ DuplexPort::DuplexPort(Node* parent, const string& name, size_t index, size_t po void DuplexPort::pre_process(SampleCount nframes, FrameTime start, FrameTime end) { - if (_is_output) { - for (size_t i=0; i < _poly; ++i) - _buffers.at(i)->prepare_write(nframes); - } else { - for (size_t i=0; i < _poly; ++i) - _buffers.at(i)->prepare_read(nframes); - } + // Think about it... + + if (_is_output) + InputPort::pre_process(nframes, start, end); + else + OutputPort::pre_process(nframes, start, end); } void DuplexPort::post_process(SampleCount nframes, FrameTime start, FrameTime end) { - if (_is_output) { - for (size_t i=0; i < _poly; ++i) - _buffers.at(i)->prepare_read(nframes); - } else { - for (size_t i=0; i < _poly; ++i) - _buffers.at(i)->prepare_write(nframes); - } + // Think about it... + + if (_is_output) + InputPort::pre_process(nframes, start, end); + else + OutputPort::pre_process(nframes, start, end); } diff --git a/src/libs/engine/InputPort.cpp b/src/libs/engine/InputPort.cpp index 0e149abe..a0a65d79 100644 --- a/src/libs/engine/InputPort.cpp +++ b/src/libs/engine/InputPort.cpp @@ -205,88 +205,6 @@ InputPort::pre_process(SampleCount nframes, FrameTime start, FrameTime end) } } -#if 0 - -/** Prepare buffer for access, realtime safe. - * - * MIDI mixing not yet implemented. - */ -void -InputPort<MidiBuffer>::process(SampleCount nframes, FrameTime start, FrameTime end) -{ - //assert(!_is_tied || _tied_port != NULL); - - const size_t num_ins = _connections.size(); - bool do_mixdown = true; - - assert(num_ins == 0 || num_ins == 1); - - assert(_poly == 1); - - for (Connections::iterator c = _connections.begin(); c != _connections.end(); ++c) - (*c)->process(nframes, start, end); - - - // If only one connection, buffer is used directly (no copying) - if (num_ins == 1) { - // Buffer changed since connection - if (_buffers.at(0) != (*_connections.begin())->buffer(0)) { - if (_fixed_buffers) { // || (_is_tied && _tied_port->fixed_buffers())) { - // can't change buffer, must copy - do_mixdown = true; - } else { - // zero-copy - _buffers.at(0)->join((*_connections.begin())->buffer(0)); - //if (_is_tied) - // _tied_port->buffer(0)->join(_buffers.at(0)); - do_mixdown = false; - } - connect_buffers(); - } else { - do_mixdown = false; - } - //assert(!_is_tied || _tied_port != NULL); - //assert(!_is_tied || _buffers.at(0)->data() == _tied_port->buffer(0)->data()); - //assert(!_is_tied || _buffers.at(0)->filled_size() == _tied_port->buffer(0)->filled_size()); - assert(do_mixdown || _buffers.at(0)->filled_size() == - (*_connections.begin())->src_port()->buffer(0)->filled_size()); - } - - // Get valid buffer size from inbound connections, unless a port on a top-level - // patch (which will be fed by the MidiDriver) - if (_parent->parent() != NULL) { - if (num_ins == 1) { - _buffers.at(0)->filled_size( - (*_connections.begin())->src_port()->buffer(0)->filled_size()); - - //if (_is_tied) - // _tied_port->buffer(0)->filled_size(_buffers.at(0)->filled_size()); - - assert(_buffers.at(0)->filled_size() == - (*_connections.begin())->src_port()->buffer(0)->filled_size()); - } else { - // Mixing not implemented - _buffers.at(0)->clear(); - } - } - - //assert(!_is_tied || _buffers.at(0)->data() == _tied_port->buffer(0)->data()); - - if (!do_mixdown || _buffers.at(0)->filled_size() == 0 || num_ins == 0) - return; - - //cerr << path() << " - Copying MIDI buffer" << endl; - - // Be sure buffers are the same as tied port's, if joined - //assert(!_is_tied || _tied_port != NULL); - //assert(!_is_tied || _buffers.at(0)->data() == _tied_port->buffer(0)->data()); - - if (num_ins > 0) - for (size_t i=0; i < _buffers.at(0)->filled_size(); ++i) - _buffers.at(0)[i] = (*_connections.begin())->buffer(0)[i]; -} -#endif - void InputPort::set_buffer_size(size_t size) diff --git a/src/libs/engine/Patch.cpp b/src/libs/engine/Patch.cpp index ad414642..a81b9ee7 100644 --- a/src/libs/engine/Patch.cpp +++ b/src/libs/engine/Patch.cpp @@ -115,23 +115,26 @@ Patch::process(SampleCount nframes, FrameTime start, FrameTime end) if (_process_order == NULL || !_process) return; - // FIXME: This is far too slow, too much checking every cycle + // FIXME: This is far too slow, too much iteration/conditionals every cycle - // Prepare input ports for nodes to consume - for (Raul::List<Port*>::iterator i = _input_ports.begin(); i != _input_ports.end(); ++i) - (*i)->process(nframes, start, end); + // This breaks MIDI input, somehow (?) + //for (Raul::List<Port*>::iterator i = _input_ports.begin(); i != _input_ports.end(); ++i) + // (*i)->pre_process(nframes, start, end); + for (Raul::List<Port*>::iterator i = _output_ports.begin(); i != _output_ports.end(); ++i) + (*i)->pre_process(nframes, start, end); // Run all nodes (consume input ports) for (size_t i=0; i < _process_order->size(); ++i) { // Could be a gap due to a node removal event (see RemoveNodeEvent.cpp) // Yes, this is ugly - if (_process_order->at(i) != NULL) + if (_process_order->at(i)) _process_order->at(i)->process(nframes, start, end); } - // Prepare output ports (for caller to consume) + for (Raul::List<Port*>::iterator i = _input_ports.begin(); i != _input_ports.end(); ++i) + (*i)->post_process(nframes, start, end); for (Raul::List<Port*>::iterator i = _output_ports.begin(); i != _output_ports.end(); ++i) - (*i)->process(nframes, start, end); + (*i)->post_process(nframes, start, end); } |