summaryrefslogtreecommitdiff
path: root/gst/audiotestsrc
diff options
context:
space:
mode:
authorCarlos Rafael Giani <dv@pseudoterminal.org>2016-09-02 15:23:18 +0200
committerTim-Philipp Müller <tim@centricular.com>2016-12-23 16:51:07 +0000
commita257a177c35645191fda34fba7a0182a40041457 (patch)
treecd363dd746d53a928003ab3d6ed10a77d2be8d2e /gst/audiotestsrc
parent7c0c59ccdf340522f5371c64564771b187b271c4 (diff)
downloadgstreamer-plugins-base-a257a177c35645191fda34fba7a0182a40041457.tar.gz
audiotestsrc: Fix incorrect start of tick waveform
Make sure ticks start with an accumulator value of 0 by incrementing it after filling in samples instead of before and by resetting the accumulator every time a tick begins. This prevents it from being discontinuous at the beginning of the tick. https://bugzilla.gnome.org/show_bug.cgi?id=774050
Diffstat (limited to 'gst/audiotestsrc')
-rw-r--r--gst/audiotestsrc/gstaudiotestsrc.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/gst/audiotestsrc/gstaudiotestsrc.c b/gst/audiotestsrc/gstaudiotestsrc.c
index d00c1c698..51b25907d 100644
--- a/gst/audiotestsrc/gstaudiotestsrc.c
+++ b/gst/audiotestsrc/gstaudiotestsrc.c
@@ -735,7 +735,7 @@ static const ProcessFunc sine_table_funcs[] = {
static void \
gst_audio_test_src_create_tick_##type (GstAudioTestSrc * src, g##type * samples) \
{ \
- gint i, c, channels, samplerate; \
+ gint i, c, channels, samplerate, samplemod; \
gdouble step, scl; \
\
channels = GST_AUDIO_INFO_CHANNELS (&src->info); \
@@ -744,17 +744,20 @@ gst_audio_test_src_create_tick_##type (GstAudioTestSrc * src, g##type * samples)
scl = 1024.0 / M_PI_M2; \
\
for (i = 0; i < src->generate_samples_per_buffer; i++) { \
- src->accumulator += step; \
- if (src->accumulator >= M_PI_M2) \
- src->accumulator -= M_PI_M2; \
- \
- if ((src->next_sample + i)%samplerate < 1600) { \
+ samplemod = (src->next_sample + i) % samplerate; \
+ if (samplemod == 0) { \
+ src->accumulator = 0; \
+ } else if (samplemod < 1600) { \
for (c = 0; c < channels; ++c) \
samples[(i * channels) + c] = (g##type) scale * src->wave_table[(gint) (src->accumulator * scl)]; \
} else { \
for (c = 0; c < channels; ++c) \
samples[(i * channels) + c] = 0; \
} \
+ \
+ src->accumulator += step; \
+ if (src->accumulator >= M_PI_M2) \
+ src->accumulator -= M_PI_M2; \
} \
}