2 * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
3 * Copyright (C) <2009> Sebastian Dröge <sebastian.droege@collabora.co.uk>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
22 #ifndef __GST_SPECTRUM_H__
23 #define __GST_SPECTRUM_H__
26 #include <gst/audio/gstaudiofilter.h>
27 #include <gst/fft/gstfftf32.h>
31 #define GST_TYPE_SPECTRUM (gst_spectrum_get_type())
32 #define GST_SPECTRUM(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_SPECTRUM,GstSpectrum))
33 #define GST_IS_SPECTRUM(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_SPECTRUM))
34 #define GST_SPECTRUM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_SPECTRUM,GstSpectrumClass))
35 #define GST_IS_SPECTRUM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_SPECTRUM))
36 typedef struct _GstSpectrum GstSpectrum;
37 typedef struct _GstSpectrumClass GstSpectrumClass;
38 typedef struct _GstSpectrumChannel GstSpectrumChannel;
40 typedef void (*GstSpectrumInputData)(const guint8 * in, gfloat * out,
41 guint len, guint channels, gfloat max_value, guint op, guint nfft);
43 struct _GstSpectrumChannel
47 GstFFTF32Complex *freqdata;
48 gfloat *spect_magnitude; /* accumulated mangitude and phase */
49 gfloat *spect_phase; /* will be scaled by num_fft before sending */
55 GstAudioFilter parent;
58 gboolean post_messages; /* whether or not to post messages */
59 gboolean message_magnitude;
60 gboolean message_phase;
61 guint64 interval; /* how many nanoseconds between emits */
62 guint64 frames_per_interval; /* how many frames per interval */
64 guint bands; /* number of spectrum bands */
65 gint threshold; /* energy level treshold */
66 gboolean multi_channel; /* send separate channel results */
68 guint64 num_frames; /* frame count (1 sample per channel)
70 guint64 num_fft; /* number of FFTs since last emit */
71 GstClockTime message_ts; /* starttime for next message */
74 GstSpectrumChannel *channel_data;
78 guint64 error_per_interval;
79 guint64 accumulated_error;
81 GstSpectrumInputData input_data;
84 struct _GstSpectrumClass
86 GstAudioFilterClass parent_class;
89 GType gst_spectrum_get_type (void);
93 #endif /* __GST_SPECTRUM_H__ */