audiotestsrc: Max audio frequency is half the rate, not 1/4
authorVivia Nikolaidou <vivia@ahiru.eu>
Fri, 17 May 2019 13:35:40 +0000 (16:35 +0300)
committerVivia Nikolaidou <vivia@ahiru.eu>
Fri, 17 May 2019 13:35:40 +0000 (16:35 +0300)
https://en.wikipedia.org/wiki/Nyquist%E2%80%93Shannon_sampling_theorem

gst/audiotestsrc/gstaudiotestsrc.c

index 0a3a937..f447196 100644 (file)
@@ -245,8 +245,8 @@ gst_audio_test_src_class_init (GstAudioTestSrcClass * klass)
           G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));
   g_object_class_install_property (gobject_class, PROP_FREQ,
       g_param_spec_double ("freq", "Frequency", "Frequency of test signal. "
-          "The sample rate needs to be at least 4 times higher.",
-          0.0, (gdouble) G_MAXINT / 4, DEFAULT_FREQ,
+          "The sample rate needs to be at least 2 times higher.",
+          0.0, (gdouble) G_MAXINT / 2, DEFAULT_FREQ,
           G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));
   g_object_class_install_property (gobject_class, PROP_VOLUME,
       g_param_spec_double ("volume", "Volume", "Volume of test signal", 0.0,
@@ -372,7 +372,7 @@ gst_audio_test_src_fixate (GstBaseSrc * bsrc, GstCaps * caps)
 
   GST_DEBUG_OBJECT (src, "fixating samplerate to %d", GST_AUDIO_DEF_RATE);
 
-  rate = MAX (GST_AUDIO_DEF_RATE, src->freq * 4);
+  rate = MAX (GST_AUDIO_DEF_RATE, src->freq * 2);
   gst_structure_fixate_field_nearest_int (structure, "rate", rate);
 
   gst_structure_fixate_field_string (structure, "format", DEFAULT_FORMAT_STR);