2 Copyright (C) 2006 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #include <ardour/internal_audio_port.h>
21 #include <ardour/audioengine.h>
23 using namespace ARDOUR;
27 InternalAudioPort::default_mixdown (const list<InternalPort*>& ports, AudioBuffer& dest, nframes_t cnt, nframes_t offset)
29 list<InternalPort*>::const_iterator p = ports.begin();
31 dest.read_from ((dynamic_cast<AudioPort*>(*p))->get_audio_buffer(), cnt, offset);
33 for (; p != ports.end(); ++p) {
34 dest.accumulate_from ((dynamic_cast<AudioPort*>(*p))->get_audio_buffer(), cnt, offset);
38 InternalAudioPort::InternalAudioPort(const string& name, Flags flags)
39 : Port (DataType::AUDIO, flags)
40 , AudioPort (flags, engine->frames_per_cycle())
41 , InternalPort (name, DataType::AUDIO, flags)
43 _mixdown = default_mixdown;
47 InternalAudioPort::set_mixdown_function (void (*func)(const list<InternalPort*>&, AudioBuffer&, nframes_t, nframes_t))
53 InternalAudioPort::reset ()
55 _buffer.resize (engine->frames_per_cycle());
56 _buffer.silence (_buffer.size());
60 InternalAudioPort::get_audio_buffer ()
62 if (_connections.empty()) {
63 return AudioPort::get_audio_buffer();
66 /* XXX what about offset/size being more dynamic ? */
68 (*_mixdown) (_connections, _buffer, _buffer.size(), 0);