diff options
Diffstat (limited to 'src/libs/engine/InputPort.cpp')
-rw-r--r-- | src/libs/engine/InputPort.cpp | 152 |
1 files changed, 76 insertions, 76 deletions
diff --git a/src/libs/engine/InputPort.cpp b/src/libs/engine/InputPort.cpp index 6fbd500f..2a369521 100644 --- a/src/libs/engine/InputPort.cpp +++ b/src/libs/engine/InputPort.cpp @@ -47,35 +47,35 @@ template<typename T> void InputPort<T>::add_connection(ListNode<TypedConnection<T>*>* const c) { - m_connections.push_back(c); + _connections.push_back(c); - bool modify_buffers = !m_fixed_buffers; - //if (modify_buffers && m_is_tied) - // modify_buffers = !m_tied_port->fixed_buffers(); + bool modify_buffers = !_fixed_buffers; + //if (modify_buffers && _is_tied) + // modify_buffers = !_tied_port->fixed_buffers(); if (modify_buffers) { - if (m_connections.size() == 1) { + if (_connections.size() == 1) { // Use buffer directly to avoid copying for (size_t i=0; i < _poly; ++i) { - m_buffers.at(i)->join(c->elem()->buffer(i)); - //if (m_is_tied) - // m_tied_port->buffer(i)->join(m_buffers.at(i)); - assert(m_buffers.at(i)->data() == c->elem()->buffer(i)->data()); + _buffers.at(i)->join(c->elem()->buffer(i)); + //if (_is_tied) + // _tied_port->buffer(i)->join(_buffers.at(i)); + assert(_buffers.at(i)->data() == c->elem()->buffer(i)->data()); } - } else if (m_connections.size() == 2) { + } else if (_connections.size() == 2) { // Used to directly use single connection buffer, now there's two // so have to use local ones again and mix down for (size_t i=0; i < _poly; ++i) { - m_buffers.at(i)->unjoin(); - //if (m_is_tied) - // m_tied_port->buffer(i)->join(m_buffers.at(i)); + _buffers.at(i)->unjoin(); + //if (_is_tied) + // _tied_port->buffer(i)->join(_buffers.at(i)); } } TypedPort<T>::connect_buffers(); } - //assert( ! m_is_tied || m_tied_port != NULL); - //assert( ! m_is_tied || m_buffers.at(0)->data() == m_tied_port->buffer(0)->data()); + //assert( ! _is_tied || _tied_port != NULL); + //assert( ! _is_tied || _buffers.at(0)->data() == _tied_port->buffer(0)->data()); } template void InputPort<Sample>::add_connection(ListNode<TypedConnection<Sample>*>* const c); template void InputPort<MidiMessage>::add_connection(ListNode<TypedConnection<MidiMessage>*>* const c); @@ -87,16 +87,16 @@ template <typename T> ListNode<TypedConnection<T>*>* InputPort<T>::remove_connection(const OutputPort<T>* const src_port) { - bool modify_buffers = !m_fixed_buffers; - //if (modify_buffers && m_is_tied) - // modify_buffers = !m_tied_port->fixed_buffers(); + bool modify_buffers = !_fixed_buffers; + //if (modify_buffers && _is_tied) + // modify_buffers = !_tied_port->fixed_buffers(); typedef typename List<TypedConnection<T>*>::iterator TypedConnectionListIterator; bool found = false; ListNode<TypedConnection<T>*>* connection = NULL; - for (TypedConnectionListIterator i = m_connections.begin(); i != m_connections.end(); ++i) { + for (TypedConnectionListIterator i = _connections.begin(); i != _connections.end(); ++i) { if ((*i)->src_port()->path() == src_port->path()) { - connection = m_connections.remove(i); + connection = _connections.remove(i); found = true; } } @@ -105,21 +105,21 @@ InputPort<T>::remove_connection(const OutputPort<T>* const src_port) cerr << "WARNING: [InputPort<T>::remove_connection] Connection not found !" << endl; exit(EXIT_FAILURE); } else { - if (m_connections.size() == 0) { + if (_connections.size() == 0) { for (size_t i=0; i < _poly; ++i) { // Use a local buffer - if (modify_buffers && m_buffers.at(i)->is_joined()) - m_buffers.at(i)->unjoin(); - m_buffers.at(i)->clear(); // Write silence - //if (m_is_tied) - //m_tied_port->buffer(i)->join(m_buffers.at(i)); + if (modify_buffers && _buffers.at(i)->is_joined()) + _buffers.at(i)->unjoin(); + _buffers.at(i)->clear(); // Write silence + //if (_is_tied) + //m_tied_port->buffer(i)->join(_buffers.at(i)); } - } else if (modify_buffers && m_connections.size() == 1) { + } else if (modify_buffers && _connections.size() == 1) { // Share a buffer for (size_t i=0; i < _poly; ++i) { - m_buffers.at(i)->join((*m_connections.begin())->buffer(i)); - //if (m_is_tied) - // m_tied_port->buffer(i)->join(m_buffers.at(i)); + _buffers.at(i)->join((*_connections.begin())->buffer(i)); + //if (_is_tied) + // _tied_port->buffer(i)->join(_buffers.at(i)); } } } @@ -127,8 +127,8 @@ InputPort<T>::remove_connection(const OutputPort<T>* const src_port) if (modify_buffers) TypedPort<T>::connect_buffers(); - //assert( ! m_is_tied || m_tied_port != NULL); - //assert( ! m_is_tied || m_buffers.at(0)->data() == m_tied_port->buffer(0)->data()); + //assert( ! _is_tied || _tied_port != NULL); + //assert( ! _is_tied || _buffers.at(0)->data() == _tied_port->buffer(0)->data()); return connection; } @@ -145,7 +145,7 @@ bool InputPort<T>::is_connected_to(const OutputPort<T>* const port) const { typedef typename List<TypedConnection<T>*>::const_iterator TypedConnectionListIterator; - for (TypedConnectionListIterator i = m_connections.begin(); i != m_connections.end(); ++i) + for (TypedConnectionListIterator i = _connections.begin(); i != _connections.end(); ++i) if ((*i)->src_port() == port) return true; @@ -162,27 +162,27 @@ template<> void InputPort<Sample>::process(SampleCount nframes, FrameTime start, FrameTime end) { - //assert(!m_is_tied || m_tied_port != NULL); + //assert(!_is_tied || _tied_port != NULL); typedef List<TypedConnection<Sample>*>::iterator TypedConnectionListIterator; bool do_mixdown = true; - if (m_connections.size() == 0) return; + if (_connections.size() == 0) return; - for (TypedConnectionListIterator c = m_connections.begin(); c != m_connections.end(); ++c) + for (TypedConnectionListIterator c = _connections.begin(); c != _connections.end(); ++c) (*c)->process(nframes, start, end); // If only one connection, buffer is (maybe) used directly (no copying) - if (m_connections.size() == 1) { + if (_connections.size() == 1) { // Buffer changed since connection - if (m_buffers.at(0)->data() != (*m_connections.begin())->buffer(0)->data()) { - if (m_fixed_buffers) { // || (m_is_tied && m_tied_port->fixed_buffers())) { + if (_buffers.at(0)->data() != (*_connections.begin())->buffer(0)->data()) { + if (_fixed_buffers) { // || (_is_tied && _tied_port->fixed_buffers())) { // can't change buffer, must copy do_mixdown = true; } else { // zero-copy - assert(m_buffers.at(0)->is_joined()); - m_buffers.at(0)->join((*m_connections.begin())->buffer(0)); + assert(_buffers.at(0)->is_joined()); + _buffers.at(0)->join((*_connections.begin())->buffer(0)); do_mixdown = false; } connect_buffers(); @@ -194,24 +194,24 @@ InputPort<Sample>::process(SampleCount nframes, FrameTime start, FrameTime end) //cerr << path() << " mixing: " << do_mixdown << endl; if (!do_mixdown) { - assert(m_buffers.at(0)->data() == (*m_connections.begin())->buffer(0)->data()); + assert(_buffers.at(0)->data() == (*_connections.begin())->buffer(0)->data()); return; } - /*assert(!m_is_tied || m_tied_port != NULL); - assert(!m_is_tied || m_buffers.at(0)->data() == m_tied_port->buffer(0)->data());*/ + /*assert(!_is_tied || _tied_port != NULL); + assert(!_is_tied || _buffers.at(0)->data() == _tied_port->buffer(0)->data());*/ for (size_t voice=0; voice < _poly; ++voice) { // Copy first connection - m_buffers.at(voice)->copy((*m_connections.begin())->buffer(voice), 0, _buffer_size-1); + _buffers.at(voice)->copy((*_connections.begin())->buffer(voice), 0, _buffer_size-1); // Accumulate the rest - if (m_connections.size() > 1) { + if (_connections.size() > 1) { - TypedConnectionListIterator c = m_connections.begin(); + TypedConnectionListIterator c = _connections.begin(); - for (++c; c != m_connections.end(); ++c) - m_buffers.at(voice)->accumulate((*c)->buffer(voice), 0, _buffer_size-1); + for (++c; c != _connections.end(); ++c) + _buffers.at(voice)->accumulate((*c)->buffer(voice), 0, _buffer_size-1); } } } @@ -225,9 +225,9 @@ template <> void InputPort<MidiMessage>::process(SampleCount nframes, FrameTime start, FrameTime end) { - //assert(!m_is_tied || m_tied_port != NULL); + //assert(!_is_tied || _tied_port != NULL); - const size_t num_ins = m_connections.size(); + const size_t num_ins = _connections.size(); bool do_mixdown = true; assert(num_ins == 0 || num_ins == 1); @@ -235,67 +235,67 @@ InputPort<MidiMessage>::process(SampleCount nframes, FrameTime start, FrameTime typedef List<TypedConnection<MidiMessage>*>::iterator TypedConnectionListIterator; assert(_poly == 1); - for (TypedConnectionListIterator c = m_connections.begin(); c != m_connections.end(); ++c) + for (TypedConnectionListIterator 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 (m_buffers.at(0) != (*m_connections.begin())->buffer(0)) { - if (m_fixed_buffers) { // || (m_is_tied && m_tied_port->fixed_buffers())) { + 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 - m_buffers.at(0)->join((*m_connections.begin())->buffer(0)); - //if (m_is_tied) - // m_tied_port->buffer(0)->join(m_buffers.at(0)); + _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(!m_is_tied || m_tied_port != NULL); - //assert(!m_is_tied || m_buffers.at(0)->data() == m_tied_port->buffer(0)->data()); - //assert(!m_is_tied || m_buffers.at(0)->filled_size() == m_tied_port->buffer(0)->filled_size()); - assert(do_mixdown || m_buffers.at(0)->filled_size() == - (*m_connections.begin())->src_port()->buffer(0)->filled_size()); + //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) { - m_buffers.at(0)->filled_size( - (*m_connections.begin())->src_port()->buffer(0)->filled_size()); + _buffers.at(0)->filled_size( + (*_connections.begin())->src_port()->buffer(0)->filled_size()); - //if (m_is_tied) - // m_tied_port->buffer(0)->filled_size(m_buffers.at(0)->filled_size()); + //if (_is_tied) + // _tied_port->buffer(0)->filled_size(_buffers.at(0)->filled_size()); - assert(m_buffers.at(0)->filled_size() == - (*m_connections.begin())->src_port()->buffer(0)->filled_size()); + assert(_buffers.at(0)->filled_size() == + (*_connections.begin())->src_port()->buffer(0)->filled_size()); } else { // Mixing not implemented - m_buffers.at(0)->clear(); + _buffers.at(0)->clear(); } } - //assert(!m_is_tied || m_buffers.at(0)->data() == m_tied_port->buffer(0)->data()); + //assert(!_is_tied || _buffers.at(0)->data() == _tied_port->buffer(0)->data()); - if (!do_mixdown || m_buffers.at(0)->filled_size() == 0 || num_ins == 0) + 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(!m_is_tied || m_tied_port != NULL); - //assert(!m_is_tied || m_buffers.at(0)->data() == m_tied_port->buffer(0)->data()); + //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 < m_buffers.at(0)->filled_size(); ++i) - m_buffers.at(0)[i] = (*m_connections.begin())->buffer(0)[i]; + for (size_t i=0; i < _buffers.at(0)->filled_size(); ++i) + _buffers.at(0)[i] = (*_connections.begin())->buffer(0)[i]; } @@ -306,7 +306,7 @@ InputPort<T>::set_buffer_size(size_t size) TypedPort<T>::set_buffer_size(size); assert(_buffer_size = size); - for (typename List<TypedConnection<T>*>::iterator c = m_connections.begin(); c != m_connections.end(); ++c) + for (typename List<TypedConnection<T>*>::iterator c = _connections.begin(); c != _connections.end(); ++c) (*c)->set_buffer_size(size); } |