From aabcbf7bad012739e02301faeed156fed29a4638 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Fri, 7 Aug 2015 20:10:15 +0200 Subject: VST use scratch buffers for processing. --- libs/ardour/ardour/vst_plugin.h | 4 --- libs/ardour/vst_plugin.cc | 54 ++--------------------------------------- 2 files changed, 2 insertions(+), 56 deletions(-) diff --git a/libs/ardour/ardour/vst_plugin.h b/libs/ardour/ardour/vst_plugin.h index 07eca40042..3450e2a480 100644 --- a/libs/ardour/ardour/vst_plugin.h +++ b/libs/ardour/ardour/vst_plugin.h @@ -97,10 +97,6 @@ protected: AEffect* _plugin; MidiBuffer* _midi_out_buf; -#ifndef VST_IN_PLACE - float ** _audio_out_buf; - uint32_t _audio_out_buf_cnt; -#endif }; } diff --git a/libs/ardour/vst_plugin.cc b/libs/ardour/vst_plugin.cc index b62e18fed8..f18f96318c 100644 --- a/libs/ardour/vst_plugin.cc +++ b/libs/ardour/vst_plugin.cc @@ -35,10 +35,6 @@ #include "i18n.h" -#ifndef VST_IN_PLACE -#define MAX_VST_BUFFERSIZE 8192 -#endif - using namespace std; using namespace PBD; using namespace ARDOUR; @@ -48,22 +44,13 @@ VSTPlugin::VSTPlugin (AudioEngine& engine, Session& session, VSTHandle* handle) , _handle (handle) , _state (0) , _plugin (0) -#ifndef VST_IN_PLACE - , _audio_out_buf (0) - , _audio_out_buf_cnt (0) -#endif { } VSTPlugin::~VSTPlugin () { -#ifndef VST_IN_PLACE - for (uint32_t i = 0; i < _audio_out_buf_cnt; ++i) { - free (_audio_out_buf[i]); - } - free (_audio_out_buf); -#endif + } void @@ -76,23 +63,6 @@ VSTPlugin::set_plugin (AEffect* e) _plugin->dispatcher (_plugin, effSetSampleRate, 0, 0, NULL, (float) _session.frame_rate()); _plugin->dispatcher (_plugin, effSetBlockSize, 0, _session.get_block_size(), NULL, 0.0f); -#ifndef VST_IN_PLACE - if (_audio_out_buf_cnt != _plugin->numOutputs) { - for (uint32_t i = 0; i < _audio_out_buf_cnt; ++i) { - free (_audio_out_buf[i]); - } - free (_audio_out_buf); - _audio_out_buf_cnt = _plugin->numOutputs; - _audio_out_buf = (float**) malloc (_audio_out_buf_cnt * sizeof(float*)); - /* think. Should this be part of the BufferSet ? - * in which case it would be dynamically sized, but then again - * every BufferSet would have N[?] extra VST audio buffers. - */ - for (uint32_t i = 0; i < _audio_out_buf_cnt; ++i) { - _audio_out_buf[i] = (float*) malloc (MAX_VST_BUFFERSIZE * sizeof(float)); - } - } -#endif } void @@ -593,27 +563,9 @@ VSTPlugin::connect_and_run (BufferSet& bufs, : silent_bufs.get_audio(0).data(offset); } -#ifndef VST_IN_PLACE - assert (nframes <= MAX_VST_BUFFERSIZE); - assert (_plugin->numOutputs <= _audio_out_buf_cnt); -#endif - uint32_t out_index = 0; for (i = 0; i < (int32_t) _plugin->numOutputs; ++i) { - uint32_t index; - bool valid = false; - index = out_map.get(DataType::AUDIO, out_index++, &valid); -#ifdef VST_IN_PLACE - outs[i] = (valid) - ? bufs.get_audio(index).data(offset) - : scratch_bufs.get_audio(0).data(offset); -#else - if (!valid) { - outs[i] = scratch_bufs.get_audio(0).data(offset); - } else { - outs[i] = _audio_out_buf[i]; - } -#endif + outs[i] = scratch_bufs.get_audio(i).data(offset); } if (bufs.count().n_midi() > 0) { @@ -640,7 +592,6 @@ VSTPlugin::connect_and_run (BufferSet& bufs, _plugin->processReplacing (_plugin, &ins[0], &outs[0], nframes); _midi_out_buf = 0; -#ifndef VST_IN_PLACE out_index = 0; for (i = 0; i < (int32_t) _plugin->numOutputs; ++i) { uint32_t index; @@ -651,7 +602,6 @@ VSTPlugin::connect_and_run (BufferSet& bufs, } memcpy (bufs.get_audio(index).data(offset), outs[i], nframes * sizeof(float)); } -#endif return 0; } -- cgit v1.2.3