sdl2-bindings 0.1.1 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/ChangeLog +140 -124
  3. data/LICENSE.txt +0 -0
  4. data/README.md +93 -77
  5. data/lib/sdl2.rb +131 -131
  6. data/lib/sdl2_audio.rb +265 -261
  7. data/lib/sdl2_blendmode.rb +72 -72
  8. data/lib/sdl2_clipboard.rb +56 -56
  9. data/lib/sdl2_cpuinfo.rb +137 -129
  10. data/lib/sdl2_error.rb +71 -71
  11. data/lib/sdl2_events.rb +575 -564
  12. data/lib/sdl2_filesystem.rb +52 -52
  13. data/lib/sdl2_framerate.rb +74 -74
  14. data/lib/sdl2_gamecontroller.rb +345 -329
  15. data/lib/sdl2_gesture.rb +61 -61
  16. data/lib/sdl2_gfxPrimitives.rb +283 -283
  17. data/lib/sdl2_guid.rb +58 -0
  18. data/lib/sdl2_haptic.rb +301 -301
  19. data/lib/sdl2_hidapi.rb +139 -139
  20. data/lib/sdl2_hints.rb +240 -221
  21. data/lib/sdl2_image.rb +296 -232
  22. data/lib/sdl2_imageFilter.rb +164 -164
  23. data/lib/sdl2_joystick.rb +332 -294
  24. data/lib/sdl2_keyboard.rb +129 -125
  25. data/lib/sdl2_keycode.rb +311 -307
  26. data/lib/sdl2_log.rb +131 -131
  27. data/lib/sdl2_main.rb +74 -74
  28. data/lib/sdl2_messagebox.rb +102 -102
  29. data/lib/sdl2_misc.rb +48 -48
  30. data/lib/sdl2_mixer.rb +464 -392
  31. data/lib/sdl2_mouse.rb +136 -136
  32. data/lib/sdl2_pixels.rb +240 -240
  33. data/lib/sdl2_platform.rb +48 -48
  34. data/lib/sdl2_power.rb +54 -54
  35. data/lib/sdl2_rect.rb +145 -145
  36. data/lib/sdl2_render.rb +408 -408
  37. data/lib/sdl2_rotozoom.rb +76 -76
  38. data/lib/sdl2_rwops.rb +242 -238
  39. data/lib/sdl2_scancode.rb +293 -289
  40. data/lib/sdl2_sensor.rb +115 -115
  41. data/lib/sdl2_shape.rb +83 -83
  42. data/lib/sdl2_sound.rb +154 -154
  43. data/lib/sdl2_stdinc.rb +564 -556
  44. data/lib/sdl2_surface.rb +229 -229
  45. data/lib/sdl2_syswm.rb +160 -160
  46. data/lib/sdl2_timer.rb +74 -74
  47. data/lib/sdl2_touch.rb +86 -86
  48. data/lib/sdl2_ttf.rb +414 -358
  49. data/lib/sdl2_version.rb +67 -67
  50. data/lib/sdl2_video.rb +549 -540
  51. data/lib/sdl2_vulkan.rb +72 -72
  52. metadata +4 -3
data/lib/sdl2_mixer.rb CHANGED
@@ -1,392 +1,464 @@
1
- # Ruby-SDL2 : Yet another SDL2 wrapper for Ruby
2
- #
3
- # * https://github.com/vaiorabbit/sdl2-bindings
4
- #
5
- # [NOTICE] This is an automatically generated file.
6
-
7
- require 'ffi'
8
-
9
- module SDL
10
- extend FFI::Library
11
- # Define/Macro
12
-
13
- MIXER_MAJOR_VERSION = 2
14
- MIXER_MINOR_VERSION = 0
15
- MIXER_PATCHLEVEL = 4
16
- MIX_CHANNELS = 8
17
- MIX_DEFAULT_FREQUENCY = 22050
18
- MIX_DEFAULT_FORMAT = AUDIO_S16LSB
19
- MIX_DEFAULT_CHANNELS = 2
20
- MIX_MAX_VOLUME = MIX_MAXVOLUME
21
- MIX_CHANNEL_POST = -2
22
- MIX_EFFECTSMAXSPEED = "MIX_EFFECTSMAXSPEED"
23
-
24
- # Enum
25
-
26
- MIX_INIT_FLAC = 1
27
- MIX_INIT_MOD = 2
28
- MIX_INIT_MP3 = 8
29
- MIX_INIT_OGG = 16
30
- MIX_INIT_MID = 32
31
- MIX_INIT_OPUS = 64
32
- MIX_NO_FADING = 0
33
- MIX_FADING_OUT = 1
34
- MIX_FADING_IN = 2
35
- MUS_NONE = 0
36
- MUS_CMD = 1
37
- MUS_WAV = 2
38
- MUS_MOD = 3
39
- MUS_MID = 4
40
- MUS_OGG = 5
41
- MUS_MP3 = 6
42
- MUS_MP3_MAD_UNUSED = 7
43
- MUS_FLAC = 8
44
- MUS_MODPLUG_UNUSED = 9
45
- MUS_OPUS = 10
46
-
47
- # Typedef
48
-
49
- typedef :int, :MIX_InitFlags
50
- typedef :int, :Mix_Fading
51
- typedef :int, :Mix_MusicType
52
- callback :Mix_EffectFunc_t, [:int, :pointer, :int, :pointer], :void
53
- callback :Mix_EffectDone_t, [:int, :pointer], :void
54
-
55
- # Struct
56
-
57
- class Mix_Chunk < FFI::Struct
58
- layout(
59
- :allocated, :int,
60
- :abuf, :pointer,
61
- :alen, :uint,
62
- :volume, :uchar,
63
- )
64
- end
65
-
66
-
67
- # Function
68
-
69
- def self.setup_mixer_symbols(output_error = false)
70
- symbols = [
71
- :Mix_Linked_Version,
72
- :Mix_Init,
73
- :Mix_Quit,
74
- :Mix_OpenAudio,
75
- :Mix_OpenAudioDevice,
76
- :Mix_AllocateChannels,
77
- :Mix_QuerySpec,
78
- :Mix_LoadWAV_RW,
79
- :Mix_LoadMUS,
80
- :Mix_LoadMUS_RW,
81
- :Mix_LoadMUSType_RW,
82
- :Mix_QuickLoad_WAV,
83
- :Mix_QuickLoad_RAW,
84
- :Mix_FreeChunk,
85
- :Mix_FreeMusic,
86
- :Mix_GetNumChunkDecoders,
87
- :Mix_GetChunkDecoder,
88
- :Mix_HasChunkDecoder,
89
- :Mix_GetNumMusicDecoders,
90
- :Mix_GetMusicDecoder,
91
- :Mix_HasMusicDecoder,
92
- :Mix_GetMusicType,
93
- :Mix_SetPostMix,
94
- :Mix_HookMusic,
95
- :Mix_HookMusicFinished,
96
- :Mix_GetMusicHookData,
97
- :Mix_ChannelFinished,
98
- :Mix_RegisterEffect,
99
- :Mix_UnregisterEffect,
100
- :Mix_UnregisterAllEffects,
101
- :Mix_SetPanning,
102
- :Mix_SetPosition,
103
- :Mix_SetDistance,
104
- :Mix_SetReverseStereo,
105
- :Mix_ReserveChannels,
106
- :Mix_GroupChannel,
107
- :Mix_GroupChannels,
108
- :Mix_GroupAvailable,
109
- :Mix_GroupCount,
110
- :Mix_GroupOldest,
111
- :Mix_GroupNewer,
112
- :Mix_PlayChannelTimed,
113
- :Mix_PlayMusic,
114
- :Mix_FadeInMusic,
115
- :Mix_FadeInMusicPos,
116
- :Mix_FadeInChannelTimed,
117
- :Mix_Volume,
118
- :Mix_VolumeChunk,
119
- :Mix_VolumeMusic,
120
- :Mix_HaltChannel,
121
- :Mix_HaltGroup,
122
- :Mix_HaltMusic,
123
- :Mix_ExpireChannel,
124
- :Mix_FadeOutChannel,
125
- :Mix_FadeOutGroup,
126
- :Mix_FadeOutMusic,
127
- :Mix_FadingMusic,
128
- :Mix_FadingChannel,
129
- :Mix_Pause,
130
- :Mix_Resume,
131
- :Mix_Paused,
132
- :Mix_PauseMusic,
133
- :Mix_ResumeMusic,
134
- :Mix_RewindMusic,
135
- :Mix_PausedMusic,
136
- :Mix_SetMusicPosition,
137
- :Mix_Playing,
138
- :Mix_PlayingMusic,
139
- :Mix_SetMusicCMD,
140
- :Mix_SetSynchroValue,
141
- :Mix_GetSynchroValue,
142
- :Mix_SetSoundFonts,
143
- :Mix_GetSoundFonts,
144
- :Mix_EachSoundFont,
145
- :Mix_GetChunk,
146
- :Mix_CloseAudio,
147
- ]
148
- apis = {
149
- :Mix_Linked_Version => :Mix_Linked_Version,
150
- :Mix_Init => :Mix_Init,
151
- :Mix_Quit => :Mix_Quit,
152
- :Mix_OpenAudio => :Mix_OpenAudio,
153
- :Mix_OpenAudioDevice => :Mix_OpenAudioDevice,
154
- :Mix_AllocateChannels => :Mix_AllocateChannels,
155
- :Mix_QuerySpec => :Mix_QuerySpec,
156
- :Mix_LoadWAV_RW => :Mix_LoadWAV_RW,
157
- :Mix_LoadMUS => :Mix_LoadMUS,
158
- :Mix_LoadMUS_RW => :Mix_LoadMUS_RW,
159
- :Mix_LoadMUSType_RW => :Mix_LoadMUSType_RW,
160
- :Mix_QuickLoad_WAV => :Mix_QuickLoad_WAV,
161
- :Mix_QuickLoad_RAW => :Mix_QuickLoad_RAW,
162
- :Mix_FreeChunk => :Mix_FreeChunk,
163
- :Mix_FreeMusic => :Mix_FreeMusic,
164
- :Mix_GetNumChunkDecoders => :Mix_GetNumChunkDecoders,
165
- :Mix_GetChunkDecoder => :Mix_GetChunkDecoder,
166
- :Mix_HasChunkDecoder => :Mix_HasChunkDecoder,
167
- :Mix_GetNumMusicDecoders => :Mix_GetNumMusicDecoders,
168
- :Mix_GetMusicDecoder => :Mix_GetMusicDecoder,
169
- :Mix_HasMusicDecoder => :Mix_HasMusicDecoder,
170
- :Mix_GetMusicType => :Mix_GetMusicType,
171
- :Mix_SetPostMix => :Mix_SetPostMix,
172
- :Mix_HookMusic => :Mix_HookMusic,
173
- :Mix_HookMusicFinished => :Mix_HookMusicFinished,
174
- :Mix_GetMusicHookData => :Mix_GetMusicHookData,
175
- :Mix_ChannelFinished => :Mix_ChannelFinished,
176
- :Mix_RegisterEffect => :Mix_RegisterEffect,
177
- :Mix_UnregisterEffect => :Mix_UnregisterEffect,
178
- :Mix_UnregisterAllEffects => :Mix_UnregisterAllEffects,
179
- :Mix_SetPanning => :Mix_SetPanning,
180
- :Mix_SetPosition => :Mix_SetPosition,
181
- :Mix_SetDistance => :Mix_SetDistance,
182
- :Mix_SetReverseStereo => :Mix_SetReverseStereo,
183
- :Mix_ReserveChannels => :Mix_ReserveChannels,
184
- :Mix_GroupChannel => :Mix_GroupChannel,
185
- :Mix_GroupChannels => :Mix_GroupChannels,
186
- :Mix_GroupAvailable => :Mix_GroupAvailable,
187
- :Mix_GroupCount => :Mix_GroupCount,
188
- :Mix_GroupOldest => :Mix_GroupOldest,
189
- :Mix_GroupNewer => :Mix_GroupNewer,
190
- :Mix_PlayChannelTimed => :Mix_PlayChannelTimed,
191
- :Mix_PlayMusic => :Mix_PlayMusic,
192
- :Mix_FadeInMusic => :Mix_FadeInMusic,
193
- :Mix_FadeInMusicPos => :Mix_FadeInMusicPos,
194
- :Mix_FadeInChannelTimed => :Mix_FadeInChannelTimed,
195
- :Mix_Volume => :Mix_Volume,
196
- :Mix_VolumeChunk => :Mix_VolumeChunk,
197
- :Mix_VolumeMusic => :Mix_VolumeMusic,
198
- :Mix_HaltChannel => :Mix_HaltChannel,
199
- :Mix_HaltGroup => :Mix_HaltGroup,
200
- :Mix_HaltMusic => :Mix_HaltMusic,
201
- :Mix_ExpireChannel => :Mix_ExpireChannel,
202
- :Mix_FadeOutChannel => :Mix_FadeOutChannel,
203
- :Mix_FadeOutGroup => :Mix_FadeOutGroup,
204
- :Mix_FadeOutMusic => :Mix_FadeOutMusic,
205
- :Mix_FadingMusic => :Mix_FadingMusic,
206
- :Mix_FadingChannel => :Mix_FadingChannel,
207
- :Mix_Pause => :Mix_Pause,
208
- :Mix_Resume => :Mix_Resume,
209
- :Mix_Paused => :Mix_Paused,
210
- :Mix_PauseMusic => :Mix_PauseMusic,
211
- :Mix_ResumeMusic => :Mix_ResumeMusic,
212
- :Mix_RewindMusic => :Mix_RewindMusic,
213
- :Mix_PausedMusic => :Mix_PausedMusic,
214
- :Mix_SetMusicPosition => :Mix_SetMusicPosition,
215
- :Mix_Playing => :Mix_Playing,
216
- :Mix_PlayingMusic => :Mix_PlayingMusic,
217
- :Mix_SetMusicCMD => :Mix_SetMusicCMD,
218
- :Mix_SetSynchroValue => :Mix_SetSynchroValue,
219
- :Mix_GetSynchroValue => :Mix_GetSynchroValue,
220
- :Mix_SetSoundFonts => :Mix_SetSoundFonts,
221
- :Mix_GetSoundFonts => :Mix_GetSoundFonts,
222
- :Mix_EachSoundFont => :Mix_EachSoundFont,
223
- :Mix_GetChunk => :Mix_GetChunk,
224
- :Mix_CloseAudio => :Mix_CloseAudio,
225
- }
226
- args = {
227
- :Mix_Linked_Version => [],
228
- :Mix_Init => [:int],
229
- :Mix_Quit => [],
230
- :Mix_OpenAudio => [:int, :ushort, :int, :int],
231
- :Mix_OpenAudioDevice => [:int, :ushort, :int, :int, :pointer, :int],
232
- :Mix_AllocateChannels => [:int],
233
- :Mix_QuerySpec => [:pointer, :pointer, :pointer],
234
- :Mix_LoadWAV_RW => [:pointer, :int],
235
- :Mix_LoadMUS => [:pointer],
236
- :Mix_LoadMUS_RW => [:pointer, :int],
237
- :Mix_LoadMUSType_RW => [:pointer, :int, :int],
238
- :Mix_QuickLoad_WAV => [:pointer],
239
- :Mix_QuickLoad_RAW => [:pointer, :uint],
240
- :Mix_FreeChunk => [:pointer],
241
- :Mix_FreeMusic => [:pointer],
242
- :Mix_GetNumChunkDecoders => [],
243
- :Mix_GetChunkDecoder => [:int],
244
- :Mix_HasChunkDecoder => [:pointer],
245
- :Mix_GetNumMusicDecoders => [],
246
- :Mix_GetMusicDecoder => [:int],
247
- :Mix_HasMusicDecoder => [:pointer],
248
- :Mix_GetMusicType => [:pointer],
249
- :Mix_SetPostMix => [:pointer, :pointer],
250
- :Mix_HookMusic => [:pointer, :pointer],
251
- :Mix_HookMusicFinished => [:pointer],
252
- :Mix_GetMusicHookData => [],
253
- :Mix_ChannelFinished => [:pointer],
254
- :Mix_RegisterEffect => [:int, :Mix_EffectFunc_t, :Mix_EffectDone_t, :pointer],
255
- :Mix_UnregisterEffect => [:int, :Mix_EffectFunc_t],
256
- :Mix_UnregisterAllEffects => [:int],
257
- :Mix_SetPanning => [:int, :uchar, :uchar],
258
- :Mix_SetPosition => [:int, :short, :uchar],
259
- :Mix_SetDistance => [:int, :uchar],
260
- :Mix_SetReverseStereo => [:int, :int],
261
- :Mix_ReserveChannels => [:int],
262
- :Mix_GroupChannel => [:int, :int],
263
- :Mix_GroupChannels => [:int, :int, :int],
264
- :Mix_GroupAvailable => [:int],
265
- :Mix_GroupCount => [:int],
266
- :Mix_GroupOldest => [:int],
267
- :Mix_GroupNewer => [:int],
268
- :Mix_PlayChannelTimed => [:int, :pointer, :int, :int],
269
- :Mix_PlayMusic => [:pointer, :int],
270
- :Mix_FadeInMusic => [:pointer, :int, :int],
271
- :Mix_FadeInMusicPos => [:pointer, :int, :int, :double],
272
- :Mix_FadeInChannelTimed => [:int, :pointer, :int, :int, :int],
273
- :Mix_Volume => [:int, :int],
274
- :Mix_VolumeChunk => [:pointer, :int],
275
- :Mix_VolumeMusic => [:int],
276
- :Mix_HaltChannel => [:int],
277
- :Mix_HaltGroup => [:int],
278
- :Mix_HaltMusic => [],
279
- :Mix_ExpireChannel => [:int, :int],
280
- :Mix_FadeOutChannel => [:int, :int],
281
- :Mix_FadeOutGroup => [:int, :int],
282
- :Mix_FadeOutMusic => [:int],
283
- :Mix_FadingMusic => [],
284
- :Mix_FadingChannel => [:int],
285
- :Mix_Pause => [:int],
286
- :Mix_Resume => [:int],
287
- :Mix_Paused => [:int],
288
- :Mix_PauseMusic => [],
289
- :Mix_ResumeMusic => [],
290
- :Mix_RewindMusic => [],
291
- :Mix_PausedMusic => [],
292
- :Mix_SetMusicPosition => [:double],
293
- :Mix_Playing => [:int],
294
- :Mix_PlayingMusic => [],
295
- :Mix_SetMusicCMD => [:pointer],
296
- :Mix_SetSynchroValue => [:int],
297
- :Mix_GetSynchroValue => [],
298
- :Mix_SetSoundFonts => [:pointer],
299
- :Mix_GetSoundFonts => [],
300
- :Mix_EachSoundFont => [:pointer, :pointer],
301
- :Mix_GetChunk => [:int],
302
- :Mix_CloseAudio => [],
303
- }
304
- retvals = {
305
- :Mix_Linked_Version => :pointer,
306
- :Mix_Init => :int,
307
- :Mix_Quit => :void,
308
- :Mix_OpenAudio => :int,
309
- :Mix_OpenAudioDevice => :int,
310
- :Mix_AllocateChannels => :int,
311
- :Mix_QuerySpec => :int,
312
- :Mix_LoadWAV_RW => :pointer,
313
- :Mix_LoadMUS => :pointer,
314
- :Mix_LoadMUS_RW => :pointer,
315
- :Mix_LoadMUSType_RW => :pointer,
316
- :Mix_QuickLoad_WAV => :pointer,
317
- :Mix_QuickLoad_RAW => :pointer,
318
- :Mix_FreeChunk => :void,
319
- :Mix_FreeMusic => :void,
320
- :Mix_GetNumChunkDecoders => :int,
321
- :Mix_GetChunkDecoder => :pointer,
322
- :Mix_HasChunkDecoder => :int,
323
- :Mix_GetNumMusicDecoders => :int,
324
- :Mix_GetMusicDecoder => :pointer,
325
- :Mix_HasMusicDecoder => :int,
326
- :Mix_GetMusicType => :int,
327
- :Mix_SetPostMix => :void,
328
- :Mix_HookMusic => :void,
329
- :Mix_HookMusicFinished => :void,
330
- :Mix_GetMusicHookData => :pointer,
331
- :Mix_ChannelFinished => :void,
332
- :Mix_RegisterEffect => :int,
333
- :Mix_UnregisterEffect => :int,
334
- :Mix_UnregisterAllEffects => :int,
335
- :Mix_SetPanning => :int,
336
- :Mix_SetPosition => :int,
337
- :Mix_SetDistance => :int,
338
- :Mix_SetReverseStereo => :int,
339
- :Mix_ReserveChannels => :int,
340
- :Mix_GroupChannel => :int,
341
- :Mix_GroupChannels => :int,
342
- :Mix_GroupAvailable => :int,
343
- :Mix_GroupCount => :int,
344
- :Mix_GroupOldest => :int,
345
- :Mix_GroupNewer => :int,
346
- :Mix_PlayChannelTimed => :int,
347
- :Mix_PlayMusic => :int,
348
- :Mix_FadeInMusic => :int,
349
- :Mix_FadeInMusicPos => :int,
350
- :Mix_FadeInChannelTimed => :int,
351
- :Mix_Volume => :int,
352
- :Mix_VolumeChunk => :int,
353
- :Mix_VolumeMusic => :int,
354
- :Mix_HaltChannel => :int,
355
- :Mix_HaltGroup => :int,
356
- :Mix_HaltMusic => :int,
357
- :Mix_ExpireChannel => :int,
358
- :Mix_FadeOutChannel => :int,
359
- :Mix_FadeOutGroup => :int,
360
- :Mix_FadeOutMusic => :int,
361
- :Mix_FadingMusic => :int,
362
- :Mix_FadingChannel => :int,
363
- :Mix_Pause => :void,
364
- :Mix_Resume => :void,
365
- :Mix_Paused => :int,
366
- :Mix_PauseMusic => :void,
367
- :Mix_ResumeMusic => :void,
368
- :Mix_RewindMusic => :void,
369
- :Mix_PausedMusic => :int,
370
- :Mix_SetMusicPosition => :int,
371
- :Mix_Playing => :int,
372
- :Mix_PlayingMusic => :int,
373
- :Mix_SetMusicCMD => :int,
374
- :Mix_SetSynchroValue => :int,
375
- :Mix_GetSynchroValue => :int,
376
- :Mix_SetSoundFonts => :int,
377
- :Mix_GetSoundFonts => :pointer,
378
- :Mix_EachSoundFont => :int,
379
- :Mix_GetChunk => :pointer,
380
- :Mix_CloseAudio => :void,
381
- }
382
- symbols.each do |sym|
383
- begin
384
- attach_function apis[sym], sym, args[sym], retvals[sym]
385
- rescue FFI::NotFoundError => error
386
- $stderr.puts("[Warning] Failed to import #{sym} (#{error}).") if output_error
387
- end
388
- end
389
- end
390
-
391
- end
392
-
1
+ # Ruby-SDL2 : Yet another SDL2 wrapper for Ruby
2
+ #
3
+ # * https://github.com/vaiorabbit/sdl2-bindings
4
+ #
5
+ # [NOTICE] This is an automatically generated file.
6
+
7
+ require 'ffi'
8
+
9
+ module SDL
10
+ extend FFI::Library
11
+ # Define/Macro
12
+
13
+ MIXER_MAJOR_VERSION = 2
14
+ MIXER_MINOR_VERSION = 6
15
+ MIXER_PATCHLEVEL = 2
16
+ MIX_CHANNELS = 8
17
+ MIX_DEFAULT_FREQUENCY = 44100
18
+ MIX_DEFAULT_FORMAT = AUDIO_S16LSB
19
+ MIX_DEFAULT_CHANNELS = 2
20
+ MIX_MAX_VOLUME = MIX_MAXVOLUME
21
+ MIX_CHANNEL_POST = -2
22
+ MIX_EFFECTSMAXSPEED = "MIX_EFFECTSMAXSPEED"
23
+
24
+ # Enum
25
+
26
+ MIX_INIT_FLAC = 1
27
+ MIX_INIT_MOD = 2
28
+ MIX_INIT_MP3 = 8
29
+ MIX_INIT_OGG = 16
30
+ MIX_INIT_MID = 32
31
+ MIX_INIT_OPUS = 64
32
+ MIX_NO_FADING = 0
33
+ MIX_FADING_OUT = 1
34
+ MIX_FADING_IN = 2
35
+ MUS_NONE = 0
36
+ MUS_CMD = 1
37
+ MUS_WAV = 2
38
+ MUS_MOD = 3
39
+ MUS_MID = 4
40
+ MUS_OGG = 5
41
+ MUS_MP3 = 6
42
+ MUS_MP3_MAD_UNUSED = 7
43
+ MUS_FLAC = 8
44
+ MUS_MODPLUG_UNUSED = 9
45
+ MUS_OPUS = 10
46
+
47
+ # Typedef
48
+
49
+ typedef :int, :MIX_InitFlags
50
+ typedef :int, :Mix_Fading
51
+ typedef :int, :Mix_MusicType
52
+ callback :Mix_EffectFunc_t, [:int, :pointer, :int, :pointer], :void
53
+ callback :Mix_EffectDone_t, [:int, :pointer], :void
54
+
55
+ # Struct
56
+
57
+ class Mix_Chunk < FFI::Struct
58
+ layout(
59
+ :allocated, :int,
60
+ :abuf, :pointer,
61
+ :alen, :uint,
62
+ :volume, :uchar,
63
+ )
64
+ end
65
+
66
+
67
+ # Function
68
+
69
+ def self.setup_mixer_symbols(output_error = false)
70
+ symbols = [
71
+ :Mix_Linked_Version,
72
+ :Mix_Init,
73
+ :Mix_Quit,
74
+ :Mix_OpenAudio,
75
+ :Mix_OpenAudioDevice,
76
+ :Mix_QuerySpec,
77
+ :Mix_AllocateChannels,
78
+ :Mix_LoadWAV_RW,
79
+ :Mix_LoadWAV,
80
+ :Mix_LoadMUS,
81
+ :Mix_LoadMUS_RW,
82
+ :Mix_LoadMUSType_RW,
83
+ :Mix_QuickLoad_WAV,
84
+ :Mix_QuickLoad_RAW,
85
+ :Mix_FreeChunk,
86
+ :Mix_FreeMusic,
87
+ :Mix_GetNumChunkDecoders,
88
+ :Mix_GetChunkDecoder,
89
+ :Mix_HasChunkDecoder,
90
+ :Mix_GetNumMusicDecoders,
91
+ :Mix_GetMusicDecoder,
92
+ :Mix_HasMusicDecoder,
93
+ :Mix_GetMusicType,
94
+ :Mix_GetMusicTitle,
95
+ :Mix_GetMusicTitleTag,
96
+ :Mix_GetMusicArtistTag,
97
+ :Mix_GetMusicAlbumTag,
98
+ :Mix_GetMusicCopyrightTag,
99
+ :Mix_SetPostMix,
100
+ :Mix_HookMusic,
101
+ :Mix_HookMusicFinished,
102
+ :Mix_GetMusicHookData,
103
+ :Mix_ChannelFinished,
104
+ :Mix_RegisterEffect,
105
+ :Mix_UnregisterEffect,
106
+ :Mix_UnregisterAllEffects,
107
+ :Mix_SetPanning,
108
+ :Mix_SetPosition,
109
+ :Mix_SetDistance,
110
+ :Mix_SetReverseStereo,
111
+ :Mix_ReserveChannels,
112
+ :Mix_GroupChannel,
113
+ :Mix_GroupChannels,
114
+ :Mix_GroupAvailable,
115
+ :Mix_GroupCount,
116
+ :Mix_GroupOldest,
117
+ :Mix_GroupNewer,
118
+ :Mix_PlayChannel,
119
+ :Mix_PlayChannelTimed,
120
+ :Mix_PlayMusic,
121
+ :Mix_FadeInMusic,
122
+ :Mix_FadeInMusicPos,
123
+ :Mix_FadeInChannel,
124
+ :Mix_FadeInChannelTimed,
125
+ :Mix_Volume,
126
+ :Mix_VolumeChunk,
127
+ :Mix_VolumeMusic,
128
+ :Mix_GetMusicVolume,
129
+ :Mix_MasterVolume,
130
+ :Mix_HaltChannel,
131
+ :Mix_HaltGroup,
132
+ :Mix_HaltMusic,
133
+ :Mix_ExpireChannel,
134
+ :Mix_FadeOutChannel,
135
+ :Mix_FadeOutGroup,
136
+ :Mix_FadeOutMusic,
137
+ :Mix_FadingMusic,
138
+ :Mix_FadingChannel,
139
+ :Mix_Pause,
140
+ :Mix_Resume,
141
+ :Mix_Paused,
142
+ :Mix_PauseMusic,
143
+ :Mix_ResumeMusic,
144
+ :Mix_RewindMusic,
145
+ :Mix_PausedMusic,
146
+ :Mix_ModMusicJumpToOrder,
147
+ :Mix_SetMusicPosition,
148
+ :Mix_GetMusicPosition,
149
+ :Mix_MusicDuration,
150
+ :Mix_GetMusicLoopStartTime,
151
+ :Mix_GetMusicLoopEndTime,
152
+ :Mix_GetMusicLoopLengthTime,
153
+ :Mix_Playing,
154
+ :Mix_PlayingMusic,
155
+ :Mix_SetMusicCMD,
156
+ :Mix_SetSynchroValue,
157
+ :Mix_GetSynchroValue,
158
+ :Mix_SetSoundFonts,
159
+ :Mix_GetSoundFonts,
160
+ :Mix_EachSoundFont,
161
+ :Mix_SetTimidityCfg,
162
+ :Mix_GetTimidityCfg,
163
+ :Mix_GetChunk,
164
+ :Mix_CloseAudio,
165
+ ]
166
+ apis = {
167
+ :Mix_Linked_Version => :Mix_Linked_Version,
168
+ :Mix_Init => :Mix_Init,
169
+ :Mix_Quit => :Mix_Quit,
170
+ :Mix_OpenAudio => :Mix_OpenAudio,
171
+ :Mix_OpenAudioDevice => :Mix_OpenAudioDevice,
172
+ :Mix_QuerySpec => :Mix_QuerySpec,
173
+ :Mix_AllocateChannels => :Mix_AllocateChannels,
174
+ :Mix_LoadWAV_RW => :Mix_LoadWAV_RW,
175
+ :Mix_LoadWAV => :Mix_LoadWAV,
176
+ :Mix_LoadMUS => :Mix_LoadMUS,
177
+ :Mix_LoadMUS_RW => :Mix_LoadMUS_RW,
178
+ :Mix_LoadMUSType_RW => :Mix_LoadMUSType_RW,
179
+ :Mix_QuickLoad_WAV => :Mix_QuickLoad_WAV,
180
+ :Mix_QuickLoad_RAW => :Mix_QuickLoad_RAW,
181
+ :Mix_FreeChunk => :Mix_FreeChunk,
182
+ :Mix_FreeMusic => :Mix_FreeMusic,
183
+ :Mix_GetNumChunkDecoders => :Mix_GetNumChunkDecoders,
184
+ :Mix_GetChunkDecoder => :Mix_GetChunkDecoder,
185
+ :Mix_HasChunkDecoder => :Mix_HasChunkDecoder,
186
+ :Mix_GetNumMusicDecoders => :Mix_GetNumMusicDecoders,
187
+ :Mix_GetMusicDecoder => :Mix_GetMusicDecoder,
188
+ :Mix_HasMusicDecoder => :Mix_HasMusicDecoder,
189
+ :Mix_GetMusicType => :Mix_GetMusicType,
190
+ :Mix_GetMusicTitle => :Mix_GetMusicTitle,
191
+ :Mix_GetMusicTitleTag => :Mix_GetMusicTitleTag,
192
+ :Mix_GetMusicArtistTag => :Mix_GetMusicArtistTag,
193
+ :Mix_GetMusicAlbumTag => :Mix_GetMusicAlbumTag,
194
+ :Mix_GetMusicCopyrightTag => :Mix_GetMusicCopyrightTag,
195
+ :Mix_SetPostMix => :Mix_SetPostMix,
196
+ :Mix_HookMusic => :Mix_HookMusic,
197
+ :Mix_HookMusicFinished => :Mix_HookMusicFinished,
198
+ :Mix_GetMusicHookData => :Mix_GetMusicHookData,
199
+ :Mix_ChannelFinished => :Mix_ChannelFinished,
200
+ :Mix_RegisterEffect => :Mix_RegisterEffect,
201
+ :Mix_UnregisterEffect => :Mix_UnregisterEffect,
202
+ :Mix_UnregisterAllEffects => :Mix_UnregisterAllEffects,
203
+ :Mix_SetPanning => :Mix_SetPanning,
204
+ :Mix_SetPosition => :Mix_SetPosition,
205
+ :Mix_SetDistance => :Mix_SetDistance,
206
+ :Mix_SetReverseStereo => :Mix_SetReverseStereo,
207
+ :Mix_ReserveChannels => :Mix_ReserveChannels,
208
+ :Mix_GroupChannel => :Mix_GroupChannel,
209
+ :Mix_GroupChannels => :Mix_GroupChannels,
210
+ :Mix_GroupAvailable => :Mix_GroupAvailable,
211
+ :Mix_GroupCount => :Mix_GroupCount,
212
+ :Mix_GroupOldest => :Mix_GroupOldest,
213
+ :Mix_GroupNewer => :Mix_GroupNewer,
214
+ :Mix_PlayChannel => :Mix_PlayChannel,
215
+ :Mix_PlayChannelTimed => :Mix_PlayChannelTimed,
216
+ :Mix_PlayMusic => :Mix_PlayMusic,
217
+ :Mix_FadeInMusic => :Mix_FadeInMusic,
218
+ :Mix_FadeInMusicPos => :Mix_FadeInMusicPos,
219
+ :Mix_FadeInChannel => :Mix_FadeInChannel,
220
+ :Mix_FadeInChannelTimed => :Mix_FadeInChannelTimed,
221
+ :Mix_Volume => :Mix_Volume,
222
+ :Mix_VolumeChunk => :Mix_VolumeChunk,
223
+ :Mix_VolumeMusic => :Mix_VolumeMusic,
224
+ :Mix_GetMusicVolume => :Mix_GetMusicVolume,
225
+ :Mix_MasterVolume => :Mix_MasterVolume,
226
+ :Mix_HaltChannel => :Mix_HaltChannel,
227
+ :Mix_HaltGroup => :Mix_HaltGroup,
228
+ :Mix_HaltMusic => :Mix_HaltMusic,
229
+ :Mix_ExpireChannel => :Mix_ExpireChannel,
230
+ :Mix_FadeOutChannel => :Mix_FadeOutChannel,
231
+ :Mix_FadeOutGroup => :Mix_FadeOutGroup,
232
+ :Mix_FadeOutMusic => :Mix_FadeOutMusic,
233
+ :Mix_FadingMusic => :Mix_FadingMusic,
234
+ :Mix_FadingChannel => :Mix_FadingChannel,
235
+ :Mix_Pause => :Mix_Pause,
236
+ :Mix_Resume => :Mix_Resume,
237
+ :Mix_Paused => :Mix_Paused,
238
+ :Mix_PauseMusic => :Mix_PauseMusic,
239
+ :Mix_ResumeMusic => :Mix_ResumeMusic,
240
+ :Mix_RewindMusic => :Mix_RewindMusic,
241
+ :Mix_PausedMusic => :Mix_PausedMusic,
242
+ :Mix_ModMusicJumpToOrder => :Mix_ModMusicJumpToOrder,
243
+ :Mix_SetMusicPosition => :Mix_SetMusicPosition,
244
+ :Mix_GetMusicPosition => :Mix_GetMusicPosition,
245
+ :Mix_MusicDuration => :Mix_MusicDuration,
246
+ :Mix_GetMusicLoopStartTime => :Mix_GetMusicLoopStartTime,
247
+ :Mix_GetMusicLoopEndTime => :Mix_GetMusicLoopEndTime,
248
+ :Mix_GetMusicLoopLengthTime => :Mix_GetMusicLoopLengthTime,
249
+ :Mix_Playing => :Mix_Playing,
250
+ :Mix_PlayingMusic => :Mix_PlayingMusic,
251
+ :Mix_SetMusicCMD => :Mix_SetMusicCMD,
252
+ :Mix_SetSynchroValue => :Mix_SetSynchroValue,
253
+ :Mix_GetSynchroValue => :Mix_GetSynchroValue,
254
+ :Mix_SetSoundFonts => :Mix_SetSoundFonts,
255
+ :Mix_GetSoundFonts => :Mix_GetSoundFonts,
256
+ :Mix_EachSoundFont => :Mix_EachSoundFont,
257
+ :Mix_SetTimidityCfg => :Mix_SetTimidityCfg,
258
+ :Mix_GetTimidityCfg => :Mix_GetTimidityCfg,
259
+ :Mix_GetChunk => :Mix_GetChunk,
260
+ :Mix_CloseAudio => :Mix_CloseAudio,
261
+ }
262
+ args = {
263
+ :Mix_Linked_Version => [],
264
+ :Mix_Init => [:int],
265
+ :Mix_Quit => [],
266
+ :Mix_OpenAudio => [:int, :ushort, :int, :int],
267
+ :Mix_OpenAudioDevice => [:int, :ushort, :int, :int, :pointer, :int],
268
+ :Mix_QuerySpec => [:pointer, :pointer, :pointer],
269
+ :Mix_AllocateChannels => [:int],
270
+ :Mix_LoadWAV_RW => [:pointer, :int],
271
+ :Mix_LoadWAV => [:pointer],
272
+ :Mix_LoadMUS => [:pointer],
273
+ :Mix_LoadMUS_RW => [:pointer, :int],
274
+ :Mix_LoadMUSType_RW => [:pointer, :int, :int],
275
+ :Mix_QuickLoad_WAV => [:pointer],
276
+ :Mix_QuickLoad_RAW => [:pointer, :uint],
277
+ :Mix_FreeChunk => [:pointer],
278
+ :Mix_FreeMusic => [:pointer],
279
+ :Mix_GetNumChunkDecoders => [],
280
+ :Mix_GetChunkDecoder => [:int],
281
+ :Mix_HasChunkDecoder => [:pointer],
282
+ :Mix_GetNumMusicDecoders => [],
283
+ :Mix_GetMusicDecoder => [:int],
284
+ :Mix_HasMusicDecoder => [:pointer],
285
+ :Mix_GetMusicType => [:pointer],
286
+ :Mix_GetMusicTitle => [:pointer],
287
+ :Mix_GetMusicTitleTag => [:pointer],
288
+ :Mix_GetMusicArtistTag => [:pointer],
289
+ :Mix_GetMusicAlbumTag => [:pointer],
290
+ :Mix_GetMusicCopyrightTag => [:pointer],
291
+ :Mix_SetPostMix => [:pointer, :pointer],
292
+ :Mix_HookMusic => [:pointer, :pointer],
293
+ :Mix_HookMusicFinished => [:pointer],
294
+ :Mix_GetMusicHookData => [],
295
+ :Mix_ChannelFinished => [:pointer],
296
+ :Mix_RegisterEffect => [:int, :Mix_EffectFunc_t, :Mix_EffectDone_t, :pointer],
297
+ :Mix_UnregisterEffect => [:int, :Mix_EffectFunc_t],
298
+ :Mix_UnregisterAllEffects => [:int],
299
+ :Mix_SetPanning => [:int, :uchar, :uchar],
300
+ :Mix_SetPosition => [:int, :short, :uchar],
301
+ :Mix_SetDistance => [:int, :uchar],
302
+ :Mix_SetReverseStereo => [:int, :int],
303
+ :Mix_ReserveChannels => [:int],
304
+ :Mix_GroupChannel => [:int, :int],
305
+ :Mix_GroupChannels => [:int, :int, :int],
306
+ :Mix_GroupAvailable => [:int],
307
+ :Mix_GroupCount => [:int],
308
+ :Mix_GroupOldest => [:int],
309
+ :Mix_GroupNewer => [:int],
310
+ :Mix_PlayChannel => [:int, :pointer, :int],
311
+ :Mix_PlayChannelTimed => [:int, :pointer, :int, :int],
312
+ :Mix_PlayMusic => [:pointer, :int],
313
+ :Mix_FadeInMusic => [:pointer, :int, :int],
314
+ :Mix_FadeInMusicPos => [:pointer, :int, :int, :double],
315
+ :Mix_FadeInChannel => [:int, :pointer, :int, :int],
316
+ :Mix_FadeInChannelTimed => [:int, :pointer, :int, :int, :int],
317
+ :Mix_Volume => [:int, :int],
318
+ :Mix_VolumeChunk => [:pointer, :int],
319
+ :Mix_VolumeMusic => [:int],
320
+ :Mix_GetMusicVolume => [:pointer],
321
+ :Mix_MasterVolume => [:int],
322
+ :Mix_HaltChannel => [:int],
323
+ :Mix_HaltGroup => [:int],
324
+ :Mix_HaltMusic => [],
325
+ :Mix_ExpireChannel => [:int, :int],
326
+ :Mix_FadeOutChannel => [:int, :int],
327
+ :Mix_FadeOutGroup => [:int, :int],
328
+ :Mix_FadeOutMusic => [:int],
329
+ :Mix_FadingMusic => [],
330
+ :Mix_FadingChannel => [:int],
331
+ :Mix_Pause => [:int],
332
+ :Mix_Resume => [:int],
333
+ :Mix_Paused => [:int],
334
+ :Mix_PauseMusic => [],
335
+ :Mix_ResumeMusic => [],
336
+ :Mix_RewindMusic => [],
337
+ :Mix_PausedMusic => [],
338
+ :Mix_ModMusicJumpToOrder => [:int],
339
+ :Mix_SetMusicPosition => [:double],
340
+ :Mix_GetMusicPosition => [:pointer],
341
+ :Mix_MusicDuration => [:pointer],
342
+ :Mix_GetMusicLoopStartTime => [:pointer],
343
+ :Mix_GetMusicLoopEndTime => [:pointer],
344
+ :Mix_GetMusicLoopLengthTime => [:pointer],
345
+ :Mix_Playing => [:int],
346
+ :Mix_PlayingMusic => [],
347
+ :Mix_SetMusicCMD => [:pointer],
348
+ :Mix_SetSynchroValue => [:int],
349
+ :Mix_GetSynchroValue => [],
350
+ :Mix_SetSoundFonts => [:pointer],
351
+ :Mix_GetSoundFonts => [],
352
+ :Mix_EachSoundFont => [:pointer, :pointer],
353
+ :Mix_SetTimidityCfg => [:pointer],
354
+ :Mix_GetTimidityCfg => [],
355
+ :Mix_GetChunk => [:int],
356
+ :Mix_CloseAudio => [],
357
+ }
358
+ retvals = {
359
+ :Mix_Linked_Version => :pointer,
360
+ :Mix_Init => :int,
361
+ :Mix_Quit => :void,
362
+ :Mix_OpenAudio => :int,
363
+ :Mix_OpenAudioDevice => :int,
364
+ :Mix_QuerySpec => :int,
365
+ :Mix_AllocateChannels => :int,
366
+ :Mix_LoadWAV_RW => :pointer,
367
+ :Mix_LoadWAV => :pointer,
368
+ :Mix_LoadMUS => :pointer,
369
+ :Mix_LoadMUS_RW => :pointer,
370
+ :Mix_LoadMUSType_RW => :pointer,
371
+ :Mix_QuickLoad_WAV => :pointer,
372
+ :Mix_QuickLoad_RAW => :pointer,
373
+ :Mix_FreeChunk => :void,
374
+ :Mix_FreeMusic => :void,
375
+ :Mix_GetNumChunkDecoders => :int,
376
+ :Mix_GetChunkDecoder => :pointer,
377
+ :Mix_HasChunkDecoder => :int,
378
+ :Mix_GetNumMusicDecoders => :int,
379
+ :Mix_GetMusicDecoder => :pointer,
380
+ :Mix_HasMusicDecoder => :int,
381
+ :Mix_GetMusicType => :int,
382
+ :Mix_GetMusicTitle => :pointer,
383
+ :Mix_GetMusicTitleTag => :pointer,
384
+ :Mix_GetMusicArtistTag => :pointer,
385
+ :Mix_GetMusicAlbumTag => :pointer,
386
+ :Mix_GetMusicCopyrightTag => :pointer,
387
+ :Mix_SetPostMix => :void,
388
+ :Mix_HookMusic => :void,
389
+ :Mix_HookMusicFinished => :void,
390
+ :Mix_GetMusicHookData => :pointer,
391
+ :Mix_ChannelFinished => :void,
392
+ :Mix_RegisterEffect => :int,
393
+ :Mix_UnregisterEffect => :int,
394
+ :Mix_UnregisterAllEffects => :int,
395
+ :Mix_SetPanning => :int,
396
+ :Mix_SetPosition => :int,
397
+ :Mix_SetDistance => :int,
398
+ :Mix_SetReverseStereo => :int,
399
+ :Mix_ReserveChannels => :int,
400
+ :Mix_GroupChannel => :int,
401
+ :Mix_GroupChannels => :int,
402
+ :Mix_GroupAvailable => :int,
403
+ :Mix_GroupCount => :int,
404
+ :Mix_GroupOldest => :int,
405
+ :Mix_GroupNewer => :int,
406
+ :Mix_PlayChannel => :int,
407
+ :Mix_PlayChannelTimed => :int,
408
+ :Mix_PlayMusic => :int,
409
+ :Mix_FadeInMusic => :int,
410
+ :Mix_FadeInMusicPos => :int,
411
+ :Mix_FadeInChannel => :int,
412
+ :Mix_FadeInChannelTimed => :int,
413
+ :Mix_Volume => :int,
414
+ :Mix_VolumeChunk => :int,
415
+ :Mix_VolumeMusic => :int,
416
+ :Mix_GetMusicVolume => :int,
417
+ :Mix_MasterVolume => :int,
418
+ :Mix_HaltChannel => :int,
419
+ :Mix_HaltGroup => :int,
420
+ :Mix_HaltMusic => :int,
421
+ :Mix_ExpireChannel => :int,
422
+ :Mix_FadeOutChannel => :int,
423
+ :Mix_FadeOutGroup => :int,
424
+ :Mix_FadeOutMusic => :int,
425
+ :Mix_FadingMusic => :int,
426
+ :Mix_FadingChannel => :int,
427
+ :Mix_Pause => :void,
428
+ :Mix_Resume => :void,
429
+ :Mix_Paused => :int,
430
+ :Mix_PauseMusic => :void,
431
+ :Mix_ResumeMusic => :void,
432
+ :Mix_RewindMusic => :void,
433
+ :Mix_PausedMusic => :int,
434
+ :Mix_ModMusicJumpToOrder => :int,
435
+ :Mix_SetMusicPosition => :int,
436
+ :Mix_GetMusicPosition => :double,
437
+ :Mix_MusicDuration => :double,
438
+ :Mix_GetMusicLoopStartTime => :double,
439
+ :Mix_GetMusicLoopEndTime => :double,
440
+ :Mix_GetMusicLoopLengthTime => :double,
441
+ :Mix_Playing => :int,
442
+ :Mix_PlayingMusic => :int,
443
+ :Mix_SetMusicCMD => :int,
444
+ :Mix_SetSynchroValue => :int,
445
+ :Mix_GetSynchroValue => :int,
446
+ :Mix_SetSoundFonts => :int,
447
+ :Mix_GetSoundFonts => :pointer,
448
+ :Mix_EachSoundFont => :int,
449
+ :Mix_SetTimidityCfg => :int,
450
+ :Mix_GetTimidityCfg => :pointer,
451
+ :Mix_GetChunk => :pointer,
452
+ :Mix_CloseAudio => :void,
453
+ }
454
+ symbols.each do |sym|
455
+ begin
456
+ attach_function apis[sym], sym, args[sym], retvals[sym]
457
+ rescue FFI::NotFoundError => error
458
+ $stderr.puts("[Warning] Failed to import #{sym} (#{error}).") if output_error
459
+ end
460
+ end
461
+ end
462
+
463
+ end
464
+