2 * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
3 * 2000 Wim Taymans <wtay@chello.be>
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
24 #ifndef __GST_AUDIO_TEST_SRC_H__
25 #define __GST_AUDIO_TEST_SRC_H__
29 #include <gst/base/gstbasesrc.h>
34 #define GST_TYPE_AUDIO_TEST_SRC \
35 (gst_audio_test_src_get_type())
36 #define GST_AUDIO_TEST_SRC(obj) \
37 (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_AUDIO_TEST_SRC,GstAudioTestSrc))
38 #define GST_AUDIO_TEST_SRC_CLASS(klass) \
39 (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_AUDIO_TEST_SRC,GstAudioTestSrcClass))
40 #define GST_IS_AUDIO_TEST_SRC(obj) \
41 (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_AUDIO_TEST_SRC))
42 #define GST_IS_AUDIO_TEST_SRC_CLASS(obj) \
43 (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AUDIO_TEST_SRC))
46 GST_AUDIO_TEST_SRC_WAVE_SINE,
47 GST_AUDIO_TEST_SRC_WAVE_SQUARE,
48 GST_AUDIO_TEST_SRC_WAVE_SAW,
49 GST_AUDIO_TEST_SRC_WAVE_TRIANGLE,
50 GST_AUDIO_TEST_SRC_WAVE_SILENCE,
51 GST_AUDIO_TEST_SRC_WAVE_WHITE_NOISE,
52 GST_AUDIO_TEST_SRC_WAVE_PINK_NOISE,
53 GST_AUDIO_TEST_SRC_WAVE_SINE_TAB
54 } GstAudioTestSrcWaves;
56 #define PINK_MAX_RANDOM_ROWS (30)
57 #define PINK_RANDOM_BITS (16)
58 #define PINK_RANDOM_SHIFT ((sizeof(long)*8)-PINK_RANDOM_BITS)
61 glong rows[PINK_MAX_RANDOM_ROWS];
62 glong running_sum; /* Used to optimize summing of generators. */
63 gint index; /* Incremented each sample. */
64 gint index_mask; /* Index wrapped by ANDing with this mask. */
65 gfloat scalar; /* Used to scale within range of -1.0 to +1.0 */
68 typedef struct _GstAudioTestSrc GstAudioTestSrc;
69 typedef struct _GstAudioTestSrcClass GstAudioTestSrcClass;
71 struct _GstAudioTestSrc {
74 void (*process)(GstAudioTestSrc*, gint16 *);
77 GstAudioTestSrcWaves wave;
81 /* audio parameters */
83 gint samples_per_buffer;
86 gboolean tags_pushed; /* send tags just once ? */
87 GstClockTimeDiff timestamp_offset; /* base offset */
88 GstClockTime running_time; /* total running time */
89 gint64 n_samples; /* total samples sent */
90 gint64 n_samples_stop;
91 gboolean check_seek_stop;
93 gint generate_samples_per_buffer; /* used to generate a partial buffer */
95 /* waveform specific context data */
96 gdouble accumulator; /* phase angle */
98 gint16 wave_table[1024];
101 struct _GstAudioTestSrcClass {
102 GstBaseSrcClass parent_class;
105 GType gst_audio_test_src_get_type(void);
106 gboolean gst_audio_test_src_factory_init (GstElementFactory *factory);
110 #endif /* __GST_AUDIO_TEST_SRC_H__ */