gst/audiotestsrc/gstaudiotestsrc.*: Add 'ticks', a 1/30 second sine wave pulse every...
authorDavid Schleef <ds@schleef.org>
Thu, 17 Jul 2008 02:30:24 +0000 (02:30 +0000)
committerDavid Schleef <ds@schleef.org>
Thu, 17 Jul 2008 02:30:24 +0000 (02:30 +0000)
Original commit message from CVS:
* gst/audiotestsrc/gstaudiotestsrc.c:
* gst/audiotestsrc/gstaudiotestsrc.h:
Add 'ticks', a 1/30 second sine wave pulse every second.

ChangeLog
gst/audiotestsrc/gstaudiotestsrc.c
gst/audiotestsrc/gstaudiotestsrc.h

index 91bcffa..ae1986c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2008-07-16  David Schleef  <ds@schleef.org>
+
+       * gst/audiotestsrc/gstaudiotestsrc.c:
+       * gst/audiotestsrc/gstaudiotestsrc.h:
+         Add 'ticks', a 1/30 second sine wave pulse every second.
+
 2008-07-15  David Schleef  <ds@schleef.org>
 
        * gst-libs/gst/video/video.c: Revert ABI change.
index 4a2298a..3386a55 100644 (file)
@@ -121,6 +121,7 @@ gst_audiostestsrc_wave_get_type (void)
     {GST_AUDIO_TEST_SRC_WAVE_WHITE_NOISE, "White noise", "white-noise"},
     {GST_AUDIO_TEST_SRC_WAVE_PINK_NOISE, "Pink noise", "pink-noise"},
     {GST_AUDIO_TEST_SRC_WAVE_SINE_TAB, "Sine table", "sine table"},
+    {GST_AUDIO_TEST_SRC_WAVE_TICKS, "Periodic Ticks", "ticks"},
     {0, NULL, NULL},
   };
 
@@ -659,6 +660,41 @@ static ProcessFunc sine_table_funcs[] = {
   (ProcessFunc) gst_audio_test_src_create_sine_table_double
 };
 
+#define DEFINE_TICKS(type,scale) \
+static void \
+gst_audio_test_src_create_tick_##type (GstAudioTestSrc * src, g##type * samples) \
+{ \
+  gint i; \
+  gdouble step, scl; \
+  \
+  step = M_PI_M2 * src->freq / src->samplerate; \
+  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->n_samples + i)%src->samplerate < 1600) { \
+      samples[i] = (g##type) scale * src->wave_table[(gint) (src->accumulator * scl)]; \
+    } else { \
+      samples[i] = 0; \
+    } \
+  } \
+}
+
+DEFINE_TICKS (int16, 32767.0);
+DEFINE_TICKS (int32, 2147483647.0);
+DEFINE_TICKS (float, 1.0);
+DEFINE_TICKS (double, 1.0);
+
+static ProcessFunc tick_funcs[] = {
+  (ProcessFunc) gst_audio_test_src_create_tick_int16,
+  (ProcessFunc) gst_audio_test_src_create_tick_int32,
+  (ProcessFunc) gst_audio_test_src_create_tick_float,
+  (ProcessFunc) gst_audio_test_src_create_tick_double
+};
+
 /*
  * gst_audio_test_src_change_wave:
  * Assign function pointer of wave genrator.
@@ -698,6 +734,10 @@ gst_audio_test_src_change_wave (GstAudioTestSrc * src)
       gst_audio_test_src_init_sine_table (src);
       src->process = sine_table_funcs[src->format];
       break;
+    case GST_AUDIO_TEST_SRC_WAVE_TICKS:
+      gst_audio_test_src_init_sine_table (src);
+      src->process = tick_funcs[src->format];
+      break;
     default:
       GST_ERROR ("invalid wave-form");
       break;
index cbb9893..51d138f 100644 (file)
@@ -48,6 +48,7 @@ G_BEGIN_DECLS
  * @GST_AUDIO_TEST_SRC_WAVE_WHITE_NOISE: white noise
  * @GST_AUDIO_TEST_SRC_WAVE_PINK_NOISE: pink noise
  * @GST_AUDIO_TEST_SRC_WAVE_SINE_TAB: sine wave using a table
+ * @GST_AUDIO_TEST_SRC_WAVE_TICKS: periodic ticks
  *
  * Different types of supported sound waves.
  */
@@ -59,7 +60,8 @@ typedef enum {
   GST_AUDIO_TEST_SRC_WAVE_SILENCE,
   GST_AUDIO_TEST_SRC_WAVE_WHITE_NOISE,
   GST_AUDIO_TEST_SRC_WAVE_PINK_NOISE,
-  GST_AUDIO_TEST_SRC_WAVE_SINE_TAB
+  GST_AUDIO_TEST_SRC_WAVE_SINE_TAB,
+  GST_AUDIO_TEST_SRC_WAVE_TICKS
 } GstAudioTestSrcWave; 
 
 #define PINK_MAX_RANDOM_ROWS   (30)