2014-04-30 13:46:41 -04:00
|
|
|
/*
|
2014-09-30 20:35:31 -04:00
|
|
|
Copyright (C) 2014 Waves Audio Ltd.
|
2014-04-30 13:46:41 -04:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "waves_audioport.h"
|
2015-05-13 19:11:27 -04:00
|
|
|
#include "ardour/runtime_functions.h"
|
|
|
|
#include "pbd/malign.h"
|
2014-04-30 13:46:41 -04:00
|
|
|
|
|
|
|
using namespace ARDOUR;
|
|
|
|
|
|
|
|
WavesAudioPort::WavesAudioPort (const std::string& port_name, PortFlags flags)
|
2015-10-04 14:51:05 -04:00
|
|
|
: WavesDataPort (port_name, flags)
|
2014-04-30 13:46:41 -04:00
|
|
|
{
|
2015-05-13 19:11:27 -04:00
|
|
|
aligned_malloc ((void**)&_buffer, MAX_BUFFER_SIZE_BYTES, 32 /*32 byte alignment*/);
|
|
|
|
memset (_buffer, 0, MAX_BUFFER_SIZE_BYTES);
|
|
|
|
}
|
|
|
|
|
|
|
|
WavesAudioPort::~WavesAudioPort ()
|
|
|
|
{
|
|
|
|
aligned_free (_buffer);
|
2014-04-30 13:46:41 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void* WavesAudioPort::get_buffer (pframes_t nframes)
|
|
|
|
{
|
|
|
|
if (is_input ()) {
|
2015-10-04 14:51:05 -04:00
|
|
|
|
2014-04-30 13:46:41 -04:00
|
|
|
std::vector<WavesDataPort*>::const_iterator it = get_connections ().begin ();
|
2015-10-04 14:51:05 -04:00
|
|
|
|
2014-04-30 13:46:41 -04:00
|
|
|
if (it != get_connections ().end ()) {
|
2015-05-13 19:11:27 -04:00
|
|
|
/* In fact, the static casting to (const WavesAudioPort*) is not that safe.
|
|
|
|
* However, mixing the buffers is assumed in the time critical conditions.
|
|
|
|
* Base class WavesDataPort takes is supposed to provide enough consistentcy
|
|
|
|
* of the connections.
|
|
|
|
*/
|
|
|
|
|
2015-05-14 10:52:12 -04:00
|
|
|
// get first buffer data
|
|
|
|
// use optimized function to fill the buffer intialy
|
|
|
|
ARDOUR::copy_vector (_buffer, ((const WavesAudioPort*)*it)->const_buffer (), nframes);
|
|
|
|
++it;
|
2015-10-04 14:51:05 -04:00
|
|
|
|
2015-05-14 10:52:12 -04:00
|
|
|
// mix the rest
|
|
|
|
for (; it != get_connections ().end (); ++it) {
|
|
|
|
Sample* tgt = buffer ();
|
|
|
|
const Sample* src = ((const WavesAudioPort*)*it)->const_buffer ();
|
2015-05-13 19:11:27 -04:00
|
|
|
|
2015-05-14 10:52:12 -04:00
|
|
|
// use otimized function to mix the buffers
|
|
|
|
ARDOUR::mix_buffers_no_gain (tgt, src, nframes);
|
2015-05-13 19:11:27 -04:00
|
|
|
}
|
2014-04-30 13:46:41 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return _buffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
WavesAudioPort::_wipe_buffer()
|
|
|
|
{
|
|
|
|
memset (_buffer, 0, sizeof (_buffer));
|
2015-05-12 21:07:09 -04:00
|
|
|
}
|