rewrite SwfdecAudioFormat handling
[swfdec.git] / libswfdec / swfdec_sound.h
blob81e8ccaf35fce8ad7a9b089381efb438d6ef0ec0
1 /* Swfdec
2 * Copyright (C) 2003-2006 David Schleef <ds@schleef.org>
3 * 2005-2006 Eric Anholt <eric@anholt.net>
4 * 2006-2007 Benjamin Otte <otte@gnome.org>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301 USA
22 #ifndef _SWFDEC_SOUND_H_
23 #define _SWFDEC_SOUND_H_
25 #include <libswfdec/swfdec_cached.h>
26 #include <libswfdec/swfdec_codec_audio.h>
27 #include <libswfdec/swfdec_swf_decoder.h>
28 #include <libswfdec/swfdec_types.h>
30 G_BEGIN_DECLS
32 //typedef struct _SwfdecSoundChunk SwfdecSoundChunk;
33 //typedef struct _SwfdecSound SwfdecSound;
34 typedef struct _SwfdecSoundClass SwfdecSoundClass;
35 typedef struct _SwfdecSoundEnvelope SwfdecSoundEnvelope;
37 #define SWFDEC_TYPE_SOUND (swfdec_sound_get_type())
38 #define SWFDEC_IS_SOUND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_SOUND))
39 #define SWFDEC_IS_SOUND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_SOUND))
40 #define SWFDEC_SOUND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_SOUND, SwfdecSound))
41 #define SWFDEC_SOUND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_SOUND, SwfdecSoundClass))
43 struct _SwfdecSoundEnvelope {
44 guint offset; /* offset in frames */
45 guint16 volume[2]; /* volume to use */
48 struct _SwfdecSoundChunk
50 SwfdecSound * sound; /* sound to play */
52 int stop; /* stop the sample being played */
53 int no_restart; /* don't restart if already playing */
55 guint start_sample; /* sample at which to start playing */
56 guint stop_sample; /* first sample to not play anymore */
57 guint loop_count; /* amount of times this sample should be played back */
58 guint n_envelopes; /* amount of points in the envelope */
59 SwfdecSoundEnvelope * envelope; /* volume envelope or NULL if none */
62 struct _SwfdecSound
64 SwfdecCached cached;
66 SwfdecAudioCodec format; /* format in use */
67 SwfdecAudioFormat original_format; /* channel/rate information */
68 guint n_samples; /* total number of samples when decoded to 44100kHz */
69 guint skip; /* samples to skip at start */
70 SwfdecBuffer * encoded; /* encoded data */
72 SwfdecAudioFormat decoded_format; /* format of decoded data */
73 SwfdecBuffer * decoded; /* decoded data */
76 struct _SwfdecSoundClass
78 SwfdecCachedClass cached_class;
81 GType swfdec_sound_get_type (void);
83 int tag_func_define_sound (SwfdecSwfDecoder * s, guint tag);
84 int tag_func_sound_stream_block (SwfdecSwfDecoder * s, guint tag);
85 int tag_func_sound_stream_head (SwfdecSwfDecoder * s, guint tag);
86 int tag_func_start_sound (SwfdecSwfDecoder * s, guint tag);
87 int tag_func_define_button_sound (SwfdecSwfDecoder * s, guint tag);
89 void swfdec_sound_render (SwfdecSound * sound,
90 gint16 * dest,
91 guint offset,
92 guint len);
93 void swfdec_sound_buffer_render (gint16 * dest,
94 const SwfdecBuffer * source,
95 SwfdecAudioFormat format,
96 const SwfdecBuffer * previous,
97 guint offset,
98 guint n_samples);
99 guint swfdec_sound_buffer_get_n_samples (const SwfdecBuffer * buffer,
100 SwfdecAudioFormat format);
102 SwfdecSoundChunk * swfdec_sound_parse_chunk (SwfdecSwfDecoder * s,
103 int id);
104 void swfdec_sound_chunk_free (SwfdecSoundChunk * chunk);
107 G_END_DECLS
108 #endif