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 <swfdec/swfdec_character.h>
26 #include <swfdec/swfdec_swf_decoder.h>
27 #include <swfdec/swfdec_types.h>
31 //typedef struct _SwfdecSoundChunk SwfdecSoundChunk;
32 //typedef struct _SwfdecSound SwfdecSound;
33 typedef struct _SwfdecSoundClass SwfdecSoundClass
;
34 typedef struct _SwfdecSoundEnvelope SwfdecSoundEnvelope
;
36 #define SWFDEC_TYPE_SOUND (swfdec_sound_get_type())
37 #define SWFDEC_IS_SOUND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_SOUND))
38 #define SWFDEC_IS_SOUND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_SOUND))
39 #define SWFDEC_SOUND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_SOUND, SwfdecSound))
40 #define SWFDEC_SOUND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_SOUND, SwfdecSoundClass))
42 struct _SwfdecSoundEnvelope
{
43 guint offset
; /* offset in frames */
44 guint16 volume
[2]; /* volume to use */
47 struct _SwfdecSoundChunk
49 SwfdecSound
* sound
; /* sound to play */
51 int stop
; /* stop the sample being played */
52 int no_restart
; /* don't restart if already playing */
54 guint start_sample
; /* sample at which to start playing */
55 guint stop_sample
; /* first sample to not play anymore or 0 for playing all */
56 guint loop_count
; /* amount of times this sample should be played back */
57 guint n_envelopes
; /* amount of points in the envelope */
58 SwfdecSoundEnvelope
* envelope
; /* volume envelope or NULL if none */
63 SwfdecCharacter character
;
65 guint codec
; /* codec in use */
66 SwfdecAudioFormat format
; /* channel/rate/width information for codec */
67 guint n_samples
; /* total number of samples when decoded to 44100kHz */
68 guint skip
; /* samples to skip at start */
69 SwfdecBuffer
* encoded
; /* encoded data */
71 SwfdecBuffer
* decoded
; /* decoded data */
74 struct _SwfdecSoundClass
76 SwfdecCharacterClass character_class
;
79 GType
swfdec_sound_get_type (void);
81 int tag_func_define_sound (SwfdecSwfDecoder
* s
, guint tag
);
82 int tag_func_start_sound (SwfdecSwfDecoder
* s
, guint tag
);
83 int tag_func_define_button_sound (SwfdecSwfDecoder
* s
, guint tag
);
85 SwfdecBuffer
* swfdec_sound_get_decoded (SwfdecSound
* sound
);
86 void swfdec_sound_buffer_render (gint16
* dest
,
87 const SwfdecBuffer
* source
,
90 guint
swfdec_sound_buffer_get_n_samples (const SwfdecBuffer
* buffer
,
91 SwfdecAudioFormat format
);
93 SwfdecSoundChunk
* swfdec_sound_parse_chunk (SwfdecSwfDecoder
* s
,
96 void swfdec_sound_chunk_free (SwfdecSoundChunk
* chunk
);