2 Copyright (C) 2014 Waves Audio Ltd.
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 "waves_audioport.h"
21 #include "ardour/runtime_functions.h"
22 #include "pbd/malign.h"
24 using namespace ARDOUR;
26 WavesAudioPort::WavesAudioPort (const std::string& port_name, PortFlags flags)
27 : WavesDataPort (port_name, flags)
29 aligned_malloc ((void**)&_buffer, MAX_BUFFER_SIZE_BYTES, 32 /*32 byte alignment*/);
30 memset (_buffer, 0, MAX_BUFFER_SIZE_BYTES);
33 WavesAudioPort::~WavesAudioPort ()
35 aligned_free (_buffer);
39 void* WavesAudioPort::get_buffer (pframes_t nframes)
43 std::vector<WavesDataPort*>::const_iterator it = get_connections ().begin ();
45 if (it != get_connections ().end ()) {
46 /* In fact, the static casting to (const WavesAudioPort*) is not that safe.
47 * However, mixing the buffers is assumed in the time critical conditions.
48 * Base class WavesDataPort takes is supposed to provide enough consistentcy
52 // get first buffer data
53 // use optimized function to fill the buffer intialy
54 ARDOUR::copy_vector (_buffer, ((const WavesAudioPort*)*it)->const_buffer (), nframes);
58 for (; it != get_connections ().end (); ++it) {
59 Sample* tgt = buffer ();
60 const Sample* src = ((const WavesAudioPort*)*it)->const_buffer ();
62 // use otimized function to mix the buffers
63 ARDOUR::mix_buffers_no_gain (tgt, src, nframes);
72 WavesAudioPort::_wipe_buffer()
74 memset (_buffer, 0, sizeof (_buffer));