gst_plugins_base/gst/audiotestsrc/gstaudiotestsrc.h
changeset 0 0e761a78d257
child 8 4a7fac7dd34a
equal deleted inserted replaced
-1:000000000000 0:0e761a78d257
       
     1 /* GStreamer
       
     2  * Copyright (C) 2005 Stefan Kost <ensonic@users.sf.net>
       
     3  *
       
     4  * This library is free software; you can redistribute it and/or
       
     5  * modify it under the terms of the GNU Library General Public
       
     6  * License as published by the Free Software Foundation; either
       
     7  * version 2 of the License, or (at your option) any later version.
       
     8  *
       
     9  * This library is distributed in the hope that it will be useful,
       
    10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
       
    12  * Library General Public License for more details.
       
    13  *
       
    14  * You should have received a copy of the GNU Library General Public
       
    15  * License along with this library; if not, write to the
       
    16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
       
    17  * Boston, MA 02111-1307, USA.
       
    18  */
       
    19 
       
    20 #ifndef __GST_AUDIO_TEST_SRC_H__
       
    21 #define __GST_AUDIO_TEST_SRC_H__
       
    22 
       
    23 
       
    24 #include <gst/gst.h>
       
    25 #include <gst/base/gstbasesrc.h>
       
    26 
       
    27 G_BEGIN_DECLS
       
    28 
       
    29 
       
    30 #define GST_TYPE_AUDIO_TEST_SRC \
       
    31   (gst_audio_test_src_get_type())
       
    32 #define GST_AUDIO_TEST_SRC(obj) \
       
    33   (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_AUDIO_TEST_SRC,GstAudioTestSrc))
       
    34 #define GST_AUDIO_TEST_SRC_CLASS(klass) \
       
    35   (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_AUDIO_TEST_SRC,GstAudioTestSrcClass))
       
    36 #define GST_IS_AUDIO_TEST_SRC(obj) \
       
    37   (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_AUDIO_TEST_SRC))
       
    38 #define GST_IS_AUDIO_TEST_SRC_CLASS(klass) \
       
    39   (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AUDIO_TEST_SRC))
       
    40 
       
    41 /**
       
    42  * GstAudioTestSrcWave:
       
    43  * @GST_AUDIO_TEST_SRC_WAVE_SINE: a sine wave
       
    44  * @GST_AUDIO_TEST_SRC_WAVE_SQUARE: a square wave
       
    45  * @GST_AUDIO_TEST_SRC_WAVE_SAW: a saw wave
       
    46  * @GST_AUDIO_TEST_SRC_WAVE_TRIANGLE: a tringle wave
       
    47  * @GST_AUDIO_TEST_SRC_WAVE_SILENCE: silence
       
    48  * @GST_AUDIO_TEST_SRC_WAVE_WHITE_NOISE: white noise
       
    49  * @GST_AUDIO_TEST_SRC_WAVE_PINK_NOISE: pink noise
       
    50  * @GST_AUDIO_TEST_SRC_WAVE_SINE_TAB: sine wave using a table
       
    51  *
       
    52  * Different types of supported sound waves.
       
    53  */
       
    54 typedef enum {
       
    55   GST_AUDIO_TEST_SRC_WAVE_SINE,
       
    56   GST_AUDIO_TEST_SRC_WAVE_SQUARE,
       
    57   GST_AUDIO_TEST_SRC_WAVE_SAW,
       
    58   GST_AUDIO_TEST_SRC_WAVE_TRIANGLE,
       
    59   GST_AUDIO_TEST_SRC_WAVE_SILENCE,
       
    60   GST_AUDIO_TEST_SRC_WAVE_WHITE_NOISE,
       
    61   GST_AUDIO_TEST_SRC_WAVE_PINK_NOISE,
       
    62   GST_AUDIO_TEST_SRC_WAVE_SINE_TAB
       
    63 } GstAudioTestSrcWave; 
       
    64 
       
    65 #define PINK_MAX_RANDOM_ROWS   (30)
       
    66 #define PINK_RANDOM_BITS       (16)
       
    67 #define PINK_RANDOM_SHIFT      ((sizeof(long)*8)-PINK_RANDOM_BITS)
       
    68 
       
    69 typedef struct {
       
    70   glong      rows[PINK_MAX_RANDOM_ROWS];
       
    71   glong      running_sum;   /* Used to optimize summing of generators. */
       
    72   gint       index;         /* Incremented each sample. */
       
    73   gint       index_mask;    /* Index wrapped by ANDing with this mask. */
       
    74   gdouble    scalar;        /* Used to scale within range of -1.0 to +1.0 */
       
    75 } GstPinkNoise;
       
    76 
       
    77 typedef enum {
       
    78   GST_AUDIO_TEST_SRC_FORMAT_NONE = -1,
       
    79   GST_AUDIO_TEST_SRC_FORMAT_S16 = 0,
       
    80   GST_AUDIO_TEST_SRC_FORMAT_S32,
       
    81   GST_AUDIO_TEST_SRC_FORMAT_F32,
       
    82   GST_AUDIO_TEST_SRC_FORMAT_F64
       
    83 } GstAudioTestSrcFormat;
       
    84 
       
    85 typedef struct _GstAudioTestSrc GstAudioTestSrc;
       
    86 typedef struct _GstAudioTestSrcClass GstAudioTestSrcClass;
       
    87 
       
    88 typedef void (*ProcessFunc) (GstAudioTestSrc*, guint8 *);
       
    89 
       
    90 /**
       
    91  * GstAudioTestSrc:
       
    92  *
       
    93  * audiotestsrc object structure.
       
    94  */
       
    95 struct _GstAudioTestSrc {
       
    96   GstBaseSrc parent;
       
    97 
       
    98   ProcessFunc process;
       
    99 
       
   100   /* parameters */
       
   101   GstAudioTestSrcWave wave;
       
   102   gdouble volume;
       
   103   gdouble freq;
       
   104     
       
   105   /* audio parameters */
       
   106   gint samplerate;
       
   107   gint samples_per_buffer;
       
   108   GstAudioTestSrcFormat format;
       
   109   
       
   110   /*< private >*/
       
   111   gboolean tags_pushed;			/* send tags just once ? */
       
   112   GstClockTimeDiff timestamp_offset;    /* base offset */
       
   113   GstClockTime running_time;            /* total running time */
       
   114   gint64 n_samples;                     /* total samples sent */
       
   115   gint64 n_samples_stop;
       
   116   gboolean check_seek_stop;
       
   117   gboolean eos_reached;
       
   118   gint generate_samples_per_buffer;	/* used to generate a partial buffer */
       
   119   
       
   120   /* waveform specific context data */
       
   121   gdouble accumulator;			/* phase angle */
       
   122   GstPinkNoise pink;
       
   123   gdouble wave_table[1024];
       
   124 };
       
   125 
       
   126 struct _GstAudioTestSrcClass {
       
   127   GstBaseSrcClass parent_class;
       
   128 };
       
   129 #ifdef __SYMBIAN32__
       
   130 IMPORT_C
       
   131 #endif
       
   132 
       
   133 
       
   134 GType gst_audio_test_src_get_type (void);
       
   135 
       
   136 G_END_DECLS
       
   137 
       
   138 #endif /* __GST_AUDIO_TEST_SRC_H__ */