From ad062e18794cf7e940de0250a155dd1c302cac8c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Fri, 6 Oct 2017 23:59:43 +0300 Subject: [PATCH] audioecho: Don't do linear interpolation between samples Linear interpolation adds quite some noise, and it's unlikely that anybody will ever need sub-sample accurate delays. Proper resampling before that will lead to better results. --- gst/audiofx/audioecho.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/gst/audiofx/audioecho.c b/gst/audiofx/audioecho.c index 01fd476..437a0e7 100644 --- a/gst/audiofx/audioecho.c +++ b/gst/audiofx/audioecho.c @@ -383,27 +383,19 @@ gst_audio_echo_transform_##name (GstAudioEcho * self, \ { \ type *buffer = (type *) self->buffer; \ guint channels = GST_AUDIO_FILTER_CHANNELS (self); \ - guint rate = GST_AUDIO_FILTER_RATE (self); \ guint i, j; \ - guint echo_index = self->buffer_size_frames - self->delay_frames; \ - gdouble echo_off = ((((gdouble) self->delay) * rate) / GST_SECOND) - self->delay_frames; \ - \ - if (echo_off < 0.0) \ - echo_off = 0.0; \ + guint echo_offset = self->buffer_size_frames - self->delay_frames; \ \ num_samples /= channels; \ \ for (i = 0; i < num_samples; i++) { \ - guint echo0_index = ((echo_index + self->buffer_pos) % self->buffer_size_frames) * channels; \ - guint echo1_index = ((echo_index + self->buffer_pos +1) % self->buffer_size_frames) * channels; \ + guint echo_index = ((echo_offset + self->buffer_pos) % self->buffer_size_frames) * channels; \ guint rbout_index = (self->buffer_pos % self->buffer_size_frames) * channels; \ guint64 channel_mask = 1; \ for (j = 0; j < channels; j++) { \ if (self->surdelay == FALSE) { \ gdouble in = data[i*channels + j]; \ - gdouble echo0 = buffer[echo0_index + j]; \ - gdouble echo1 = buffer[echo1_index + j]; \ - gdouble echo = echo0 + (echo1-echo0)*echo_off; \ + gdouble echo = buffer[echo_index + j]; \ type out = in + self->intensity * echo; \ \ GST_DEBUG ( "not adding delay on Surround Channel %d", j); \ @@ -412,8 +404,8 @@ gst_audio_echo_transform_##name (GstAudioEcho * self, \ buffer[rbout_index + j] = in + self->feedback * echo; \ } else if (channel_mask & self->surround_mask) { \ gdouble in = data[i*channels + j]; \ - gdouble echo0 = buffer[echo0_index + j]; \ - type out = echo0; \ + gdouble echo = buffer[echo_index + j]; \ + type out = echo; \ GST_DEBUG ( "Adding delay on Surround Channel %d", j); \ \ data[i*channels + j] = out; \ -- 2.7.4