mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-10-22 02:13:46 +00:00
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.
This commit is contained in:
parent
e9c00c083b
commit
ad062e1879
1 changed files with 5 additions and 13 deletions
|
@ -383,27 +383,19 @@ gst_audio_echo_transform_##name (GstAudioEcho * self, \
|
||||||
{ \
|
{ \
|
||||||
type *buffer = (type *) self->buffer; \
|
type *buffer = (type *) self->buffer; \
|
||||||
guint channels = GST_AUDIO_FILTER_CHANNELS (self); \
|
guint channels = GST_AUDIO_FILTER_CHANNELS (self); \
|
||||||
guint rate = GST_AUDIO_FILTER_RATE (self); \
|
|
||||||
guint i, j; \
|
guint i, j; \
|
||||||
guint echo_index = self->buffer_size_frames - self->delay_frames; \
|
guint echo_offset = 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; \
|
|
||||||
\
|
\
|
||||||
num_samples /= channels; \
|
num_samples /= channels; \
|
||||||
\
|
\
|
||||||
for (i = 0; i < num_samples; i++) { \
|
for (i = 0; i < num_samples; i++) { \
|
||||||
guint echo0_index = ((echo_index + self->buffer_pos) % self->buffer_size_frames) * channels; \
|
guint echo_index = ((echo_offset + self->buffer_pos) % self->buffer_size_frames) * channels; \
|
||||||
guint echo1_index = ((echo_index + self->buffer_pos +1) % self->buffer_size_frames) * channels; \
|
|
||||||
guint rbout_index = (self->buffer_pos % self->buffer_size_frames) * channels; \
|
guint rbout_index = (self->buffer_pos % self->buffer_size_frames) * channels; \
|
||||||
guint64 channel_mask = 1; \
|
guint64 channel_mask = 1; \
|
||||||
for (j = 0; j < channels; j++) { \
|
for (j = 0; j < channels; j++) { \
|
||||||
if (self->surdelay == FALSE) { \
|
if (self->surdelay == FALSE) { \
|
||||||
gdouble in = data[i*channels + j]; \
|
gdouble in = data[i*channels + j]; \
|
||||||
gdouble echo0 = buffer[echo0_index + j]; \
|
gdouble echo = buffer[echo_index + j]; \
|
||||||
gdouble echo1 = buffer[echo1_index + j]; \
|
|
||||||
gdouble echo = echo0 + (echo1-echo0)*echo_off; \
|
|
||||||
type out = in + self->intensity * echo; \
|
type out = in + self->intensity * echo; \
|
||||||
\
|
\
|
||||||
GST_DEBUG ( "not adding delay on Surround Channel %d", j); \
|
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; \
|
buffer[rbout_index + j] = in + self->feedback * echo; \
|
||||||
} else if (channel_mask & self->surround_mask) { \
|
} else if (channel_mask & self->surround_mask) { \
|
||||||
gdouble in = data[i*channels + j]; \
|
gdouble in = data[i*channels + j]; \
|
||||||
gdouble echo0 = buffer[echo0_index + j]; \
|
gdouble echo = buffer[echo_index + j]; \
|
||||||
type out = echo0; \
|
type out = echo; \
|
||||||
GST_DEBUG ( "Adding delay on Surround Channel %d", j); \
|
GST_DEBUG ( "Adding delay on Surround Channel %d", j); \
|
||||||
\
|
\
|
||||||
data[i*channels + j] = out; \
|
data[i*channels + j] = out; \
|
||||||
|
|
Loading…
Reference in a new issue