1507
|
1 /* Paranormal - A highly customizable audio visualization library
|
|
2 * Copyright (C) 2001 Jamie Gennis <jgennis@mindspring.com>
|
|
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 Free
|
|
16 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
17 */
|
|
18
|
|
19 #ifndef __PN_AUDIO_DATA_H__
|
|
20 #define __PN_AUDIO_DATA_H__
|
|
21
|
|
22 #include "pnobject.h"
|
|
23
|
|
24
|
|
25 G_BEGIN_DECLS
|
|
26
|
|
27 typedef enum
|
|
28 {
|
|
29 PN_CHANNEL_LEFT,
|
|
30 PN_CHANNEL_CENTER,
|
|
31 PN_CHANNEL_RIGHT
|
|
32 } PnAudioDataChannels;
|
|
33
|
|
34 #define PN_TYPE_AUDIO_DATA (pn_audio_data_get_type ())
|
|
35 #define PN_AUDIO_DATA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PN_TYPE_AUDIO_DATA, PnAudioData))
|
|
36 #define PN_AUDIO_DATA_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), PN_TYPE_AUDIO_DATA, PnAudioDataClass))
|
|
37 #define PN_IS_AUDIO_DATA(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PN_TYPE_AUDIO_DATA))
|
|
38 #define PN_IS_AUDIO_DATA_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), PN_TYPE_AUDIO_DATA))
|
|
39 #define PN_AUDIO_DATA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PN_TYPE_AUDIO_DATA, PnAudioDataClass))
|
|
40 #define PN_AUDIO_DATA_CLASS_TYPE(class) (G_TYPE_FROM_CLASS (class))
|
|
41 #define PN_AUDIO_DATA_CLASS_NAME(class) (g_type_name (PN_AUDIO_DATA_CLASS_TYPE (class)))
|
|
42
|
|
43 #define PN_AUDIO_DATA_PCM_SAMPLES(obj) (PN_AUDIO_DATA (obj)->pcm_samples)
|
|
44 #define PN_AUDIO_DATA_PCM_DATA(obj,ch) (PN_AUDIO_DATA (obj)->pcm_data[ch])
|
|
45 #define PN_AUDIO_DATA_FREQ_BANDS(obj) (PN_AUDIO_DATA (obj)->freq_bands)
|
|
46 #define PN_AUDIO_DATA_FREQ_DATA(obj,ch) (PN_AUDIO_DATA (obj)->freq_data[ch])
|
|
47
|
|
48 typedef struct _PnAudioData PnAudioData;
|
|
49 typedef struct _PnAudioDataClass PnAudioDataClass;
|
|
50
|
|
51 struct _PnAudioData
|
|
52 {
|
|
53 PnObject parent;
|
|
54
|
|
55 /*< public >*/
|
|
56
|
|
57 /* PCM and frequency data are floats in the range of 0 to 1 */
|
|
58
|
|
59 /* PCM Data */
|
|
60 guint pcm_samples; /* read-only */
|
|
61 gfloat *pcm_data[3]; /* read-write */
|
|
62
|
|
63 /* Frequency Data */
|
|
64 guint freq_bands; /* read-only */
|
|
65 gfloat *freq_data[3]; /* read-write */
|
|
66
|
|
67 /*< private >*/
|
|
68 /* If this is TRUE, each channel is separate, otherwise they all point
|
|
69 * to the same buffer. Default is TRUE.
|
|
70 */
|
|
71 gboolean stereo;
|
|
72
|
|
73 /* Overall volume of the audio frame */
|
|
74 gfloat volume;
|
|
75 };
|
|
76
|
|
77 struct _PnAudioDataClass
|
|
78 {
|
|
79 PnObjectClass parent_class;
|
|
80 };
|
|
81
|
|
82 /* Creators */
|
|
83 GType pn_audio_data_get_type (void);
|
|
84 PnAudioData *pn_audio_data_new (void);
|
|
85
|
|
86 /* Accessors */
|
|
87 void pn_audio_data_set_stereo (PnAudioData *audio_data,
|
|
88 gboolean stereo);
|
|
89 gboolean pn_audio_data_get_stereo (PnAudioData *audio_data);
|
|
90 void pn_audio_data_set_pcm_samples (PnAudioData *audio_data,
|
|
91 guint samples);
|
|
92 guint pn_audio_data_get_pcm_samples (PnAudioData *audio_data);
|
|
93 void pn_audio_data_set_freq_bands (PnAudioData *audio_data,
|
|
94 guint bands);
|
|
95 guint pn_audio_data_get_freq_bands (PnAudioData *audio_data);
|
|
96 gfloat pn_audio_data_get_volume (PnAudioData *audio_data);
|
|
97
|
|
98 /* Actions */
|
|
99 void pn_audio_data_update (PnAudioData *audio_data);
|
|
100
|
|
101 #endif /* __PN_AUDIO_DATA_H__ */
|