1
2
3
4 from ctypes import *
5
6 import sys, os
7
9 """
10 searches for a library with given names and returns a ctypes
11 .so/.dll library object if successful. if the library can not
12 be loaded, an assertion error will be thrown.
13
14 @type names: list of strings
15 @param names: one or more aliases for required libraries, e.g.
16 'SDL','SDL-1.2'.
17 @rtype: ctypes CDLL handle
18 """
19 import ctypes, os, sys
20 searchpaths = []
21 if os.name in ('posix', 'mac'):
22 if os.environ.has_key('LD_LIBRARY_PATH'):
23 searchpaths += os.environ['LD_LIBRARY_PATH'].split(os.pathsep)
24 searchpaths += [
25 '/usr/local/lib64',
26 '/usr/local/lib',
27 '/usr/lib64',
28 '/usr/lib',
29 ]
30 elif os.name == 'nt':
31 searchpaths += ['.']
32 if 'PATH' in os.environ:
33 searchpaths += os.environ['PATH'].split(os.pathsep)
34 else:
35 assert 0, "Unknown OS: %s" % os.name
36 if 'paths' in kw:
37 searchpaths += kw['paths']
38 for name in names:
39 if os.name == 'nt':
40 libname = name + '.dll'
41 elif sys.platform == 'darwin':
42 libname = 'lib' + name + '.dylib'
43 if 'version' in kw:
44 libname += '.' + kw['version']
45 else:
46 libname = 'lib' + name + '.so'
47 if 'version' in kw:
48 libname += '.' + kw['version']
49 m = None
50 for path in searchpaths:
51 if os.path.isdir(path):
52 libpath = os.path.join(path,libname)
53 if os.path.isfile(libpath):
54 m = ctypes.CDLL(libpath)
55 break
56 for filename in reversed(sorted(os.listdir(path))):
57 if filename.startswith(libname):
58 m = ctypes.CDLL(os.path.join(path,filename))
59 break
60 if m:
61 break
62 if m:
63 break
64 assert m, "libraries %s not found in %s" % (','.join(["'%s'" % a for a in names]),','.join(searchpaths))
65 return m
66
68 """
69 Opens a library by name and returns a handle object. See
70 {library.load} for more information.
71 """
72 return load_library(*args,**kwds)
73
74 -def dlsym(lib, name, restype, *args):
75 """
76 Retrieves a symbol from a library loaded by dlopen and
77 assigns correct result and argument types.
78
79 @param lib: Library object.
80 @type lib: ctypes.CDLL
81 @param name: Name of symbol.
82 @type name: str
83 @param restype: Type of function return value.
84 @param args: Types of function arguments.
85 """
86 if not lib:
87 return None
88 proc = getattr(lib,name)
89 proc.restype = restype
90 proc.argtypes = [argtype for argname,argtype in args]
91 proc.o_restype = restype
92 proc.o_args = args
93 return proc
94
95 libzzub = dlopen("zzub", "0.3")
96
97
98 zzub_version = 15
99 zzub_buffer_size = 256
100
101
102 zzub_event_type_pre_flag = 16384
103 zzub_event_type_double_click = 0
104 zzub_event_type_new_plugin = 1
105 zzub_event_type_delete_plugin = 2
106 zzub_event_type_pre_delete_plugin = 9
107 zzub_event_type_disconnect = 3
108 zzub_event_type_connect = 4
109 zzub_event_type_plugin_changed = 30
110 zzub_event_type_parameter_changed = 7
111 zzub_event_type_set_tracks = 13
112 zzub_event_type_set_sequence_tracks = 23
113 zzub_event_type_set_sequence_event = 24
114 zzub_event_type_new_pattern = 25
115 zzub_event_type_delete_pattern = 26
116 zzub_event_type_pre_delete_pattern = 47
117 zzub_event_type_edit_pattern = 27
118 zzub_event_type_pattern_changed = 31
119 zzub_event_type_pattern_insert_rows = 42
120 zzub_event_type_pattern_remove_rows = 43
121 zzub_event_type_sequencer_add_track = 32
122 zzub_event_type_sequencer_remove_track = 33
123 zzub_event_type_sequencer_changed = 41
124 zzub_event_type_pre_disconnect = 34
125 zzub_event_type_pre_connect = 35
126 zzub_event_type_post_connect = 46
127 zzub_event_type_pre_set_tracks = 36
128 zzub_event_type_post_set_tracks = 45
129 zzub_event_type_envelope_changed = 37
130 zzub_event_type_slices_changed = 38
131 zzub_event_type_wave_changed = 39
132 zzub_event_type_delete_wave = 40
133 zzub_event_type_load_progress = 8
134 zzub_event_type_midi_control = 11
135 zzub_event_type_wave_allocated = 12
136 zzub_event_type_player_state_changed = 20
137 zzub_event_type_osc_message = 21
138 zzub_event_type_vu = 22
139 zzub_event_type_custom = 44
140 zzub_event_type_all = 255
141
142
143 zzub_player_state_playing = 0
144 zzub_player_state_stopped = 1
145 zzub_player_state_muted = 2
146 zzub_player_state_released = 3
147
148
149 zzub_parameter_type_note = 0
150 zzub_parameter_type_switch = 1
151 zzub_parameter_type_byte = 2
152 zzub_parameter_type_word = 3
153
154
155 zzub_wave_buffer_type_si16 = 0
156 zzub_wave_buffer_type_f32 = 1
157 zzub_wave_buffer_type_si32 = 2
158 zzub_wave_buffer_type_si24 = 3
159
160
161 zzub_oscillator_type_sine = 0
162 zzub_oscillator_type_sawtooth = 1
163 zzub_oscillator_type_pulse = 2
164 zzub_oscillator_type_triangle = 3
165 zzub_oscillator_type_noise = 4
166 zzub_oscillator_type_sawtooth_303 = 5
167
168
169 zzub_note_value_none = 0
170 zzub_note_value_off = 255
171 zzub_note_value_min = 1
172 zzub_note_value_max = 156
173 zzub_note_value_c4 = 65
174
175
176 zzub_switch_value_none = 255
177 zzub_switch_value_off = 0
178 zzub_switch_value_on = 1
179
180
181 zzub_wavetable_index_value_none = 0
182 zzub_wavetable_index_value_min = 1
183 zzub_wavetable_index_value_max = 200
184
185
186 zzub_parameter_flag_wavetable_index = (1 << 0)
187 zzub_parameter_flag_state = (1 << 1)
188 zzub_parameter_flag_event_on_edit = (1 << 2)
189
190
191 zzub_plugin_flag_mono_to_stereo = (1 << 0)
192 zzub_plugin_flag_plays_waves = (1 << 1)
193 zzub_plugin_flag_uses_lib_interface = (1 << 2)
194 zzub_plugin_flag_uses_instruments = (1 << 3)
195 zzub_plugin_flag_does_input_mixing = (1 << 4)
196 zzub_plugin_flag_no_output = (1 << 5)
197 zzub_plugin_flag_control_plugin = (1 << 6)
198 zzub_plugin_flag_auxiliary = (1 << 7)
199 zzub_plugin_flag_is_root = (1 << 16)
200 zzub_plugin_flag_has_audio_input = (1 << 17)
201 zzub_plugin_flag_has_audio_output = (1 << 18)
202 zzub_plugin_flag_has_event_input = (1 << 19)
203 zzub_plugin_flag_has_event_output = (1 << 20)
204 zzub_plugin_flag_offline = (1 << 21)
205 zzub_plugin_flag_stream = (1 << 22)
206 zzub_plugin_flag_import = (1 << 25)
207 zzub_plugin_flag_has_midi_input = (1 << 23)
208 zzub_plugin_flag_has_midi_output = (1 << 24)
209 zzub_plugin_flag_no_undo = (1 << 25)
210 zzub_plugin_flag_no_save = (1 << 26)
211
212
213 zzub_state_flag_playing = 1
214 zzub_state_flag_recording = 2
215
216
217 zzub_wave_flag_loop = (1 << 0)
218 zzub_wave_flag_extended = (1 << 2)
219 zzub_wave_flag_stereo = (1 << 3)
220 zzub_wave_flag_pingpong = (1 << 4)
221 zzub_wave_flag_envelope = (1 << 7)
222
223
224 zzub_envelope_flag_sustain = (1 << 0)
225 zzub_envelope_flag_loop = (1 << 1)
226
227
228 zzub_process_mode_no_io = 0
229 zzub_process_mode_read = (1 << 0)
230 zzub_process_mode_write = (1 << 1)
231 zzub_process_mode_read_write = (1 << 0)|(1 << 1)
232
233
234 zzub_connection_type_audio = 0
235 zzub_connection_type_event = 1
236 zzub_connection_type_midi = 2
237
238
239 zzub_parameter_group_connection = 0
240 zzub_parameter_group_global = 1
241 zzub_parameter_group_track = 2
243 """Plugin methods
244 Retreive more details about plugins."""
245 _fields_ = [
246 ]
247 _anonymous_ = [
248 ]
262 _fields_ = [
263 ("status", c_ubyte),
264 ("data1", c_ubyte),
265 ("data2", c_ubyte),
266 ]
267 _anonymous_ = [
268 ]