- for (PortSet::iterator i = _outputs.begin(); i != _outputs.end(); ++i) {
- i->get_buffer(nframes,offset).silence (nframes, offset);
- }
-}
-
-/** Deliver bufs to the IO's output ports
- *
- * This function should automatically do whatever it necessary to correctly deliver bufs
- * to the outputs, eg applying gain or pan or whatever else needs to be done.
- */
-void
-IO::deliver_output (BufferSet& bufs, nframes_t start_frame, nframes_t end_frame, nframes_t nframes, nframes_t offset)
-{
- // FIXME: type specific code doesn't actually need to be here, it will go away in time
-
- /* ********** AUDIO ********** */
-
- // Apply gain if gain automation isn't playing
- if ( ! apply_gain_automation) {
-
- gain_t dg = _gain; // desired gain
-
- {
- Glib::Mutex::Lock dm (declick_lock, Glib::TRY_LOCK);
-
- if (dm.locked()) {
- dg = _desired_gain;
- }
-
- }
-
- if (dg != _gain || dg != 1.0) {
- Amp::run_in_place(bufs, nframes, _gain, dg, _phase_invert);
- _gain = dg;
- }
- }
-
- /* do this so that any processing that comes after deliver_outputs()
- can use the output buffers.
- */
-
- output_buffers().attach_buffers (_outputs, nframes, offset);
-
- // Use the panner to distribute audio to output port buffers
-
- if (0 && _panner && _panner->npanners() && !_panner->bypassed()) {
-
- /* blech .. we shouldn't be creating and tearing this down every process()
- cycle. XXX fix me to not waste cycles and do memory allocation etc.
- */
-
- _panner->run_out_of_place(bufs, output_buffers(), start_frame, end_frame, nframes, offset);
-
- } else {
-
- /* do a 1:1 copy of data to output ports */
-
- if (bufs.count().n_audio() > 0 && _outputs.count().n_audio () > 0) {
- copy_to_outputs (bufs, DataType::AUDIO, nframes, offset);
- }
- if (bufs.count().n_midi() > 0 && _outputs.count().n_midi () > 0) {
- copy_to_outputs (bufs, DataType::MIDI, nframes, offset);
- }
- }
-}
-
-void
-IO::copy_to_outputs (BufferSet& bufs, DataType type, nframes_t nframes, nframes_t offset)
-{
- // Copy any buffers 1:1 to outputs
-
- PortSet::iterator o = _outputs.begin(type);
- BufferSet::iterator i = bufs.begin(type);
- BufferSet::iterator prev = i;
-
- while (i != bufs.end(type) && o != _outputs.end (type)) {
-
- Buffer& port_buffer (o->get_buffer (nframes, offset));
- port_buffer.read_from (*i, nframes, offset);
-
- prev = i;
- ++i;
- ++o;
- }
-
- /* extra outputs get a copy of the last buffer */
-
- while (o != _outputs.end(type)) {
- Buffer& port_buffer (o->get_buffer (nframes, offset));
- port_buffer.read_from(*prev, nframes, offset);
- ++o;
- }
-}
-
-void
-IO::collect_input (BufferSet& outs, nframes_t nframes, nframes_t offset)
-{
- assert(outs.available() >= n_inputs());
-
- if (n_inputs() == ChanCount::ZERO)
- return;
-
- outs.set_count(n_inputs());
-
- for (DataType::iterator t = DataType::begin(); t != DataType::end(); ++t) {
-
- BufferSet::iterator o = outs.begin(*t);
- PortSet::iterator e = _inputs.end (*t);
- for (PortSet::iterator i = _inputs.begin(*t); i != e; ++i, ++o) {
- Buffer& b (i->get_buffer (nframes,offset));
- o->read_from (b, nframes, offset);
- }
-