1 #include <Python.h>
2 #include "mod_defs.h"
3 #include "decoders.h"
4 #ifdef HAS_MP3
5 #include <mpg123.h>
6 #endif
7
8 /********************************************************
9 Audio Tools, a module and set of tools for manipulating audio data
10 Copyright (C) 2007-2014 Brian Langenberger
11
12 This program is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 2 of the License, or
15 (at your option) any later version.
16
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
21
22 You should have received a copy of the GNU General Public License
23 along with this program; if not, write to the Free Software
24 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25 *******************************************************/
26
27 extern PyTypeObject decoders_FlacDecoderType;
28 extern PyTypeObject decoders_OggFlacDecoderType;
29 extern PyTypeObject decoders_SHNDecoderType;
30 extern PyTypeObject decoders_ALACDecoderType;
31 extern PyTypeObject decoders_WavPackDecoderType;
32 #ifdef HAS_VORBIS
33 extern PyTypeObject decoders_VorbisDecoderType;
34 #endif
35 #ifdef HAS_MP3
36 extern PyTypeObject decoders_MP3DecoderType;
37 #endif
38 #ifdef HAS_OPUS
39 extern PyTypeObject decoders_OpusDecoderType;
40 #endif
41 extern PyTypeObject decoders_TTADecoderType;
42 extern PyTypeObject decoders_Sine_Mono_Type;
43 extern PyTypeObject decoders_Sine_Stereo_Type;
44 extern PyTypeObject decoders_Sine_Simple_Type;
45 extern PyTypeObject decoders_SameSample_Type;
46
MOD_INIT(decoders)47 MOD_INIT(decoders)
48 {
49 PyObject* m;
50
51 MOD_DEF(m, "decoders", "low-level audio format decoders", module_methods)
52
53 decoders_FlacDecoderType.tp_new = PyType_GenericNew;
54 if (PyType_Ready(&decoders_FlacDecoderType) < 0)
55 return MOD_ERROR_VAL;
56
57 decoders_OggFlacDecoderType.tp_new = PyType_GenericNew;
58 if (PyType_Ready(&decoders_OggFlacDecoderType) < 0)
59 return MOD_ERROR_VAL;
60
61 decoders_SHNDecoderType.tp_new = PyType_GenericNew;
62 if (PyType_Ready(&decoders_SHNDecoderType) < 0)
63 return MOD_ERROR_VAL;
64
65 decoders_ALACDecoderType.tp_new = PyType_GenericNew;
66 if (PyType_Ready(&decoders_ALACDecoderType) < 0)
67 return MOD_ERROR_VAL;
68
69 decoders_WavPackDecoderType.tp_new = PyType_GenericNew;
70 if (PyType_Ready(&decoders_WavPackDecoderType) < 0)
71 return MOD_ERROR_VAL;
72
73 #ifdef HAS_VORBIS
74 decoders_VorbisDecoderType.tp_new = PyType_GenericNew;
75 if (PyType_Ready(&decoders_VorbisDecoderType) < 0)
76 return MOD_ERROR_VAL;
77 #endif
78
79 #ifdef HAS_MP3
80 decoders_MP3DecoderType.tp_new = PyType_GenericNew;
81 if (PyType_Ready(&decoders_MP3DecoderType) < 0)
82 return MOD_ERROR_VAL;
83 #endif
84
85 #ifdef HAS_OPUS
86 decoders_OpusDecoderType.tp_new = PyType_GenericNew;
87 if (PyType_Ready(&decoders_OpusDecoderType) < 0)
88 return MOD_ERROR_VAL;
89 #endif
90
91 decoders_TTADecoderType.tp_new = PyType_GenericNew;
92 if (PyType_Ready(&decoders_TTADecoderType) < 0)
93 return MOD_ERROR_VAL;
94
95 decoders_Sine_Mono_Type.tp_new = PyType_GenericNew;
96 if (PyType_Ready(&decoders_Sine_Mono_Type) < 0)
97 return MOD_ERROR_VAL;
98
99 decoders_Sine_Stereo_Type.tp_new = PyType_GenericNew;
100 if (PyType_Ready(&decoders_Sine_Stereo_Type) < 0)
101 return MOD_ERROR_VAL;
102
103 decoders_Sine_Simple_Type.tp_new = PyType_GenericNew;
104 if (PyType_Ready(&decoders_Sine_Simple_Type) < 0)
105 return MOD_ERROR_VAL;
106
107 decoders_SameSample_Type.tp_new = PyType_GenericNew;
108 if (PyType_Ready(&decoders_SameSample_Type) < 0)
109 return MOD_ERROR_VAL;
110
111 Py_INCREF(&decoders_FlacDecoderType);
112 PyModule_AddObject(m, "FlacDecoder",
113 (PyObject *)&decoders_FlacDecoderType);
114
115 Py_INCREF(&decoders_OggFlacDecoderType);
116 PyModule_AddObject(m, "OggFlacDecoder",
117 (PyObject *)&decoders_OggFlacDecoderType);
118
119 Py_INCREF(&decoders_SHNDecoderType);
120 PyModule_AddObject(m, "SHNDecoder",
121 (PyObject *)&decoders_SHNDecoderType);
122
123 Py_INCREF(&decoders_ALACDecoderType);
124 PyModule_AddObject(m, "ALACDecoder",
125 (PyObject *)&decoders_ALACDecoderType);
126
127 Py_INCREF(&decoders_WavPackDecoderType);
128 PyModule_AddObject(m, "WavPackDecoder",
129 (PyObject *)&decoders_WavPackDecoderType);
130
131 #ifdef HAS_VORBIS
132 Py_INCREF(&decoders_VorbisDecoderType);
133 PyModule_AddObject(m, "VorbisDecoder",
134 (PyObject *)&decoders_VorbisDecoderType);
135 #endif
136
137 #ifdef HAS_MP3
138 Py_INCREF(&decoders_MP3DecoderType);
139 PyModule_AddObject(m, "MP3Decoder",
140 (PyObject *)&decoders_MP3DecoderType);
141 #endif
142
143 #ifdef HAS_OPUS
144 Py_INCREF(&decoders_OpusDecoderType);
145 PyModule_AddObject(m, "OpusDecoder",
146 (PyObject *)&decoders_OpusDecoderType);
147 #endif
148
149 Py_INCREF(&decoders_TTADecoderType);
150 PyModule_AddObject(m, "TTADecoder",
151 (PyObject *)&decoders_TTADecoderType);
152
153 Py_INCREF(&decoders_Sine_Mono_Type);
154 PyModule_AddObject(m, "Sine_Mono",
155 (PyObject *)&decoders_Sine_Mono_Type);
156
157 Py_INCREF(&decoders_Sine_Stereo_Type);
158 PyModule_AddObject(m, "Sine_Stereo",
159 (PyObject *)&decoders_Sine_Stereo_Type);
160
161 Py_INCREF(&decoders_Sine_Simple_Type);
162 PyModule_AddObject(m, "Sine_Simple",
163 (PyObject *)&decoders_Sine_Simple_Type);
164
165 Py_INCREF(&decoders_SameSample_Type);
166 PyModule_AddObject(m, "SameSample",
167 (PyObject *)&decoders_SameSample_Type);
168
169 #ifdef HAS_MP3
170 /*this initializes the library's static decoding tables
171
172 although the library has an mpg123_exit() function
173 to be called at shutdown-time, it's currenly a noop
174 so we won't worry about it*/
175 mpg123_init();
176 #endif
177
178 return MOD_SUCCESS_VAL(m);
179 }
180