summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGravatar Alexey Yakovenko <waker@users.sourceforge.net>2013-10-30 22:10:28 +0100
committerGravatar Alexey Yakovenko <waker@users.sourceforge.net>2013-10-30 22:10:28 +0100
commit95048c37933de195c7231467b9bd5749bccbd697 (patch)
tree9af20b4b3c946fcadf06085a79e40ff968d96df4 /plugins
parente3ffff7ae156a277c96c02efb972ee37541fa5a7 (diff)
multichannel vis data
Diffstat (limited to 'plugins')
-rw-r--r--plugins/gtkui/widgets.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/plugins/gtkui/widgets.c b/plugins/gtkui/widgets.c
index 9eee7ea8..ae9e3185 100644
--- a/plugins/gtkui/widgets.c
+++ b/plugins/gtkui/widgets.c
@@ -2305,16 +2305,21 @@ scope_wavedata_listener (void *ctx, int type, ddb_waveformat_t *fmt, const float
if (w->samples) {
// append
+ int nsamples = in_samples / fmt->channels;
float ratio = fmt->samplerate / 44100.f;
- int size = in_samples / ratio;
+ int size = nsamples / ratio;
int sz = min (w->nsamples, size);
int n = w->nsamples-sz;
memmove (w->samples, w->samples + sz, n * sizeof (float));
float pos = 0;
- for (int i = 0; i < sz && pos < in_samples; i++, pos += ratio) {
- w->samples[n + i] = data[ftoi(pos * fmt->channels)];
+ for (int i = 0; i < sz && pos < nsamples; i++, pos += ratio) {
+ w->samples[n + i] = data[ftoi(pos * fmt->channels) * fmt->channels + 0];
+ for (int j = 1; j < fmt->channels; j++) {
+ w->samples[n + i] += data[ftoi(pos * fmt->channels) * fmt->channels + j];
+ }
+ w->samples[n+i] /= fmt->channels;
}
}
}