]> gitweb.factorcode.org Git - factor.git/blob - extra/ogg/vorbis/vorbis.factor
Initial import
[factor.git] / extra / ogg / vorbis / vorbis.factor
1 ! Copyright (C) 2007 Chris Double.
2 ! See http://factorcode.org/license.txt for BSD license.
3 !
4 USING: kernel system combinators alien alien.syntax ;
5 IN: ogg.vorbis
6
7 : load-vorbis-library ( -- )
8     "vorbis" {
9         { [ win32? ]  [ "vorbis.dll" ] }
10         { [ macosx? ] [ "libvorbis.0.dylib" ] }
11         { [ unix? ]   [ "libvorbis.so" ] }
12     } cond "cdecl" add-library ; parsing
13
14 load-vorbis-library
15
16 LIBRARY: vorbis
17
18 C-STRUCT: vorbis_info 
19     { "int" "version" }
20     { "int" "channels" }
21     { "long" "rate" }
22     { "long" "bitrate_upper" }
23     { "long" "bitrate_nominal" }
24     { "long" "bitrate_lower" }
25     { "long" "bitrate_window" }
26     { "void*" "codec_setup"} 
27     ;
28
29 C-STRUCT: vorbis_dsp_state
30     { "int" "analysisp" }
31     { "vorbis_info*" "vi" }
32     { "float**" "pcm" }
33     { "float**" "pcmret" }
34     { "int" "pcm_storage" }
35     { "int" "pcm_current" }
36     { "int" "pcm_returned" }
37     { "int" "preextrapolate" }
38     { "int" "eofflag" }
39     { "long" "lW" }
40     { "long" "W" }
41     { "long" "nW" }
42     { "long" "centerW" }
43     { "longlong" "granulepos" }
44     { "longlong" "sequence" }
45     { "longlong" "glue_bits" }
46     { "longlong" "time_bits" }
47     { "longlong" "floor_bits" }
48     { "longlong" "res_bits" }
49     { "void*" "backend_state" }
50     ;
51
52 C-STRUCT: alloc_chain
53     { "void*" "ptr" }
54     { "void*" "next" }
55     ;
56
57 C-STRUCT: vorbis_block
58     { "float**" "pcm" }
59     { "oggpack_buffer" "opb" }
60     { "long" "lW" }
61     { "long" "W" }
62     { "long" "nW" }
63     { "int" "pcmend" }
64     { "int" "mode" }
65     { "int" "eofflag" }
66     { "longlong" "granulepos" }
67     { "longlong" "sequence" }
68     { "vorbis_dsp_state*" "vd" }
69     { "void*" "localstore" }
70     { "long" "localtop" }
71     { "long" "localalloc" }
72     { "long" "totaluse" }
73     { "alloc_chain*" "reap" }
74     { "long" "glue_bits" }
75     { "long" "time_bits" }
76     { "long" "floor_bits" }
77     { "long" "res_bits" }
78     { "void*" "internal" }
79     ;
80
81 C-STRUCT: vorbis_comment
82     { "char**" "usercomments" }
83     { "int*" "comment_lengths" }
84     { "int" "comments" }
85     { "char*" "vendor" }
86     ;
87
88 FUNCTION: void     vorbis_info_init ( vorbis_info* vi ) ;
89 FUNCTION: void     vorbis_info_clear ( vorbis_info* vi ) ;
90 FUNCTION: int      vorbis_info_blocksize ( vorbis_info* vi, int zo ) ;
91 FUNCTION: void     vorbis_comment_init ( vorbis_comment* vc ) ;
92 FUNCTION: void     vorbis_comment_add ( vorbis_comment* vc, char* comment ) ;
93 FUNCTION: void     vorbis_comment_add_tag ( vorbis_comment* vc, char* tag, char* contents ) ;
94 FUNCTION: char*    vorbis_comment_query ( vorbis_comment* vc, char* tag, int count ) ;
95 FUNCTION: int      vorbis_comment_query_count ( vorbis_comment* vc, char* tag ) ;
96 FUNCTION: void     vorbis_comment_clear ( vorbis_comment* vc ) ;
97 FUNCTION: int      vorbis_block_init ( vorbis_dsp_state* v, vorbis_block* vb ) ;
98 FUNCTION: int      vorbis_block_clear ( vorbis_block* vb ) ;
99 FUNCTION: void     vorbis_dsp_clear ( vorbis_dsp_state* v ) ;
100 FUNCTION: double   vorbis_granule_time ( vorbis_dsp_state* v, longlong granulepos ) ;
101 FUNCTION: int      vorbis_analysis_init ( vorbis_dsp_state* v, vorbis_info* vi ) ;
102 FUNCTION: int      vorbis_commentheader_out ( vorbis_comment* vc, ogg_packet* op ) ;
103 FUNCTION: int      vorbis_analysis_headerout ( vorbis_dsp_state* v,
104                                           vorbis_comment* vc,
105                                           ogg_packet* op,
106                                           ogg_packet* op_comm,
107                                           ogg_packet* op_code ) ;
108 FUNCTION: float**  vorbis_analysis_buffer ( vorbis_dsp_state* v, int vals ) ;
109 FUNCTION: int      vorbis_analysis_wrote ( vorbis_dsp_state* v, int vals ) ;
110 FUNCTION: int      vorbis_analysis_blockout ( vorbis_dsp_state* v, vorbis_block* vb ) ;
111 FUNCTION: int      vorbis_analysis ( vorbis_block* vb, ogg_packet* op ) ;
112 FUNCTION: int      vorbis_bitrate_addblock ( vorbis_block* vb ) ;
113 FUNCTION: int      vorbis_bitrate_flushpacket ( vorbis_dsp_state* vd,
114                                            ogg_packet* op ) ;
115 FUNCTION: int      vorbis_synthesis_headerin ( vorbis_info* vi, vorbis_comment* vc,
116                                           ogg_packet* op ) ;
117 FUNCTION: int      vorbis_synthesis_init ( vorbis_dsp_state* v, vorbis_info* vi ) ;
118 FUNCTION: int      vorbis_synthesis_restart ( vorbis_dsp_state* v ) ;
119 FUNCTION: int      vorbis_synthesis ( vorbis_block* vb, ogg_packet* op ) ;
120 FUNCTION: int      vorbis_synthesis_trackonly ( vorbis_block* vb, ogg_packet* op ) ;
121 FUNCTION: int      vorbis_synthesis_blockin ( vorbis_dsp_state* v, vorbis_block* vb ) ;
122 FUNCTION: int      vorbis_synthesis_pcmout ( vorbis_dsp_state* v, float*** pcm ) ;
123 FUNCTION: int      vorbis_synthesis_lapout ( vorbis_dsp_state* v, float*** pcm ) ;
124 FUNCTION: int      vorbis_synthesis_read ( vorbis_dsp_state* v, int samples ) ;
125 FUNCTION: long     vorbis_packet_blocksize ( vorbis_info* vi, ogg_packet* op ) ;
126 FUNCTION: int      vorbis_synthesis_halfrate ( vorbis_info* v, int flag ) ;
127 FUNCTION: int      vorbis_synthesis_halfrate_p ( vorbis_info* v ) ;
128
129 : OV_FALSE ( -- number ) -1 ; inline
130 : OV_EOF ( -- number ) -2 ; inline
131 : OV_HOLE ( -- number ) -3 ; inline
132 : OV_EREAD ( -- number ) -128 ; inline
133 : OV_EFAULT ( -- number ) -129 ; inline
134 : OV_EIMPL ( -- number ) -130 ; inline
135 : OV_EINVAL ( -- number ) -131 ; inline
136 : OV_ENOTVORBIS ( -- number ) -132 ; inline
137 : OV_EBADHEADER ( -- number ) -133 ; inline
138 : OV_EVERSION ( -- number ) -134 ; inline
139 : OV_ENOTAUDIO ( -- number ) -135 ; inline
140 : OV_EBADPACKET ( -- number ) -136 ; inline
141 : OV_EBADLINK ( -- number ) -137 ; inline
142 : OV_ENOSEEK ( -- number ) -138 ; inline