summaryrefslogtreecommitdiff
path: root/gtk2_ardour/plugin_eq_gui.cc
diff options
context:
space:
mode:
authorSampo Savolainen <v2@iki.fi>2009-03-07 11:17:06 +0000
committerSampo Savolainen <v2@iki.fi>2009-03-07 11:17:06 +0000
commitbcd217ec8e11abcb3bc829251b6dc503d606aaeb (patch)
treebdb5d54aa6c7b1b46835acee2c8697dabbf520d7 /gtk2_ardour/plugin_eq_gui.cc
parente09c51251f1742ac5c61966b5dd8c5f61c567f69 (diff)
Improvements to the plugin eq gui:
- phase correction for analysis - move gui elements to a more common location so that it's available for VSTs (needs packing in each PluginUI derived class though) git-svn-id: svn://localhost/ardour2/branches/3.0@4745 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/plugin_eq_gui.cc')
-rw-r--r--gtk2_ardour/plugin_eq_gui.cc71
1 files changed, 68 insertions, 3 deletions
diff --git a/gtk2_ardour/plugin_eq_gui.cc b/gtk2_ardour/plugin_eq_gui.cc
index 2b43927278..1e7d038b97 100644
--- a/gtk2_ardour/plugin_eq_gui.cc
+++ b/gtk2_ardour/plugin_eq_gui.cc
@@ -246,9 +246,11 @@ PluginEqGui::set_buffer_size(uint32_t size, uint32_t signal_size)
// buffers for the signal analysis are ensured inside PluginInsert
uint32_t n_chans = std::max(inputs, outputs);
_bufferset.ensure_buffers(ARDOUR::DataType::AUDIO, n_chans, _buffer_size);
+ _collect_bufferset.ensure_buffers(ARDOUR::DataType::AUDIO, n_chans, _buffer_size);
ARDOUR::ChanCount chanCount(ARDOUR::DataType::AUDIO, n_chans);
_bufferset.set_count(chanCount);
+ _collect_bufferset.set_count(chanCount);
}
void
@@ -313,15 +315,79 @@ PluginEqGui::run_impulse_analysis()
memset(d, 0, sizeof(ARDOUR::Sample)*_buffer_size);
*d = 1.0;
}
+
uint32_t x,y;
x=y=0;
+
+
_plugin->connect_and_run(_bufferset, x, y, _buffer_size, (nframes_t)0);
+ nframes_t f = _plugin->signal_latency();
+ // Adding user_latency() could be interesting
- // Analyze all output buffers
+ // Gather all output, taking latency into account.
_impulse_fft->reset();
+
+ // Silence collect buffers to copy data to, can't use silence() because consecutive calls won't work
+ for (uint32_t i = 0; i < outputs; ++i) {
+ ARDOUR::AudioBuffer &buf = _collect_bufferset.get_audio(i);
+ ARDOUR::Sample *d = buf.data(_buffer_size, 0);
+ memset(d, 0, sizeof(ARDOUR::Sample)*_buffer_size);
+ }
+
+ if (f == 0) {
+ //std::cerr << "0: no latency, copying full buffer, trivial.." << std::endl;
+ for (uint32_t i = 0; i < outputs; ++i) {
+ memcpy(_collect_bufferset.get_audio(i).data(_buffer_size, 0),
+ _bufferset.get_audio(i).data(_buffer_size, 0), _buffer_size * sizeof(float));
+ }
+ } else {
+ //int C = 0;
+ //std::cerr << (++C) << ": latency is " << f << " frames, doing split processing.." << std::endl;
+ nframes_t target_offset = 0;
+ nframes_t frames_left = _buffer_size; // refaktoroi
+ do {
+ if (f >= _buffer_size) {
+ //std::cerr << (++C) << ": f (=" << f << ") is larger than buffer_size, still trying to reach the actual output" << std::endl;
+ // there is no data in this buffer regarding to the input!
+ f -= _buffer_size;
+ } else {
+ // this buffer contains either the first, last or a whole bu the output of the impulse
+ // first part: offset is 0, so we copy to the start of _collect_bufferset
+ // we start at output offset "f"
+ // .. and copy "buffer size" - "f" - "offset" frames
+
+ nframes_t length = _buffer_size - f - target_offset;
+
+ //std::cerr << (++C) << ": copying " << length << " frames to _collect_bufferset.get_audio(i)+" << target_offset << " from bufferset at offset " << f << std::endl;
+ for (uint32_t i = 0; i < outputs; ++i) {
+ memcpy(_collect_bufferset.get_audio(i).data(_buffer_size, target_offset),
+ _bufferset.get_audio(i).data(_buffer_size, 0) + f,
+ length * sizeof(float));
+ }
+
+ target_offset += length;
+ frames_left -= length;
+ f = 0;
+ }
+ if (frames_left > 0) {
+ // Silence the buffers
+ for (uint32_t i = 0; i < inputs; ++i) {
+ ARDOUR::AudioBuffer &buf = _bufferset.get_audio(i);
+ ARDOUR::Sample *d = buf.data(_buffer_size, 0);
+ memset(d, 0, sizeof(ARDOUR::Sample)*_buffer_size);
+ }
+
+ x=y=0;
+ _plugin->connect_and_run(_bufferset, x, y, _buffer_size, (nframes_t)0);
+ }
+ } while ( frames_left > 0);
+
+ }
+
+
for (uint32_t i = 0; i < outputs; ++i) {
- _impulse_fft->analyze(_bufferset.get_audio(i).data(_buffer_size, 0));
+ _impulse_fft->analyze(_collect_bufferset.get_audio(i).data(_buffer_size, 0));
}
// normalize the output
@@ -329,7 +395,6 @@ PluginEqGui::run_impulse_analysis()
// This signals calls expose_analysis_area()
_analysis_area->queue_draw();
-
}
bool