1/* GStreamer StreamVolume
2 * Copyright (C) 2009 Sebastian Dröge <sebastian.droege@collabora.co.uk>
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., 51 Franklin St, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20#ifndef __GST_STREAM_VOLUME_H__
21#define __GST_STREAM_VOLUME_H__
22
23#include <gst/gst.h>
24#include <gst/audio/audio-prelude.h>
25
26G_BEGIN_DECLS
27
28#define GST_TYPE_STREAM_VOLUME \
29 (gst_stream_volume_get_type ())
30#define GST_STREAM_VOLUME(obj) \
31 (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_STREAM_VOLUME, GstStreamVolume))
32#define GST_IS_STREAM_VOLUME(obj) \
33 (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_STREAM_VOLUME))
34#define GST_STREAM_VOLUME_GET_INTERFACE(inst) \
35 (G_TYPE_INSTANCE_GET_INTERFACE ((inst), GST_TYPE_STREAM_VOLUME, GstStreamVolumeInterface))
36
37typedef struct _GstStreamVolume GstStreamVolume;
38typedef struct _GstStreamVolumeInterface GstStreamVolumeInterface;
39
40struct _GstStreamVolumeInterface {
41 GTypeInterface iface;
42};
43
44/**
45 * GstStreamVolumeFormat:
46 * @GST_STREAM_VOLUME_FORMAT_LINEAR: Linear scale factor, 1.0 = 100%
47 * @GST_STREAM_VOLUME_FORMAT_CUBIC: Cubic volume scale
48 * @GST_STREAM_VOLUME_FORMAT_DB: Logarithmic volume scale (dB, amplitude not power)
49 *
50 * Different representations of a stream volume. gst_stream_volume_convert_volume()
51 * allows to convert between the different representations.
52 *
53 * Formulas to convert from a linear to a cubic or dB volume are
54 * cbrt(val) and 20 * log10 (val).
55 */
56typedef enum {
57 GST_STREAM_VOLUME_FORMAT_LINEAR = 0,
58 GST_STREAM_VOLUME_FORMAT_CUBIC,
59 GST_STREAM_VOLUME_FORMAT_DB
60} GstStreamVolumeFormat;
61
62GST_AUDIO_API
63GType gst_stream_volume_get_type (void);
64
65GST_AUDIO_API
66void gst_stream_volume_set_volume (GstStreamVolume *volume,
67 GstStreamVolumeFormat format,
68 gdouble val);
69
70GST_AUDIO_API
71gdouble gst_stream_volume_get_volume (GstStreamVolume *volume,
72 GstStreamVolumeFormat format);
73
74GST_AUDIO_API
75void gst_stream_volume_set_mute (GstStreamVolume *volume,
76 gboolean mute);
77
78GST_AUDIO_API
79gboolean gst_stream_volume_get_mute (GstStreamVolume *volume);
80
81GST_AUDIO_API
82gdouble gst_stream_volume_convert_volume (GstStreamVolumeFormat from,
83 GstStreamVolumeFormat to,
84 gdouble val) G_GNUC_CONST;
85
86G_END_DECLS
87
88#endif /* __GST_STREAM_VOLUME_H__ */
89