fiddle_fluidsynth 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. checksums.yaml +7 -0
  2. data/.standard.yml +3 -0
  3. data/CHANGELOG.md +5 -0
  4. data/LICENSE.txt +21 -0
  5. data/README.md +138 -0
  6. data/Rakefile +14 -0
  7. data/examples/enum.rb +30 -0
  8. data/examples/example.sf2 +0 -0
  9. data/examples/ffs_arpeggio.rb +252 -0
  10. data/examples/ffs_example.rb +47 -0
  11. data/examples/ffs_fx.rb +200 -0
  12. data/examples/ffs_metronome.rb +260 -0
  13. data/examples/ffs_midiplay.rb +122 -0
  14. data/examples/ffs_simple.rb +45 -0
  15. data/examples/ffs_test1.rb +41 -0
  16. data/examples/ffs_test3.rb +50 -0
  17. data/examples/fiddle-pointer.rb +18 -0
  18. data/examples/presets-each.rb +66 -0
  19. data/examples/presets-full_scan.rb +59 -0
  20. data/examples/settings-each.rb +106 -0
  21. data/exe/ffs_midiplay.rb +122 -0
  22. data/lib/fiddle_fluidsynth/audio_output/driver.rb +104 -0
  23. data/lib/fiddle_fluidsynth/audio_output/file_renderer.rb +84 -0
  24. data/lib/fiddle_fluidsynth/audio_output.rb +7 -0
  25. data/lib/fiddle_fluidsynth/command_interface/command_interface.rb +90 -0
  26. data/lib/fiddle_fluidsynth/command_interface/handler.rb +95 -0
  27. data/lib/fiddle_fluidsynth/command_interface/server.rb +79 -0
  28. data/lib/fiddle_fluidsynth/command_interface/shell.rb +76 -0
  29. data/lib/fiddle_fluidsynth/command_interface.rb +9 -0
  30. data/lib/fiddle_fluidsynth/core_ext/fiddle.rb +142 -0
  31. data/lib/fiddle_fluidsynth/core_ext/module.rb +123 -0
  32. data/lib/fiddle_fluidsynth/fiddle_fluidsynth.rb +172 -0
  33. data/lib/fiddle_fluidsynth/logging/logging.rb +82 -0
  34. data/lib/fiddle_fluidsynth/logging.rb +6 -0
  35. data/lib/fiddle_fluidsynth/midi_input/driver.rb +77 -0
  36. data/lib/fiddle_fluidsynth/midi_input/events.rb +255 -0
  37. data/lib/fiddle_fluidsynth/midi_input/midi_input.rb +70 -0
  38. data/lib/fiddle_fluidsynth/midi_input/player.rb +289 -0
  39. data/lib/fiddle_fluidsynth/midi_input/router.rb +225 -0
  40. data/lib/fiddle_fluidsynth/midi_input.rb +11 -0
  41. data/lib/fiddle_fluidsynth/misc/misc.rb +162 -0
  42. data/lib/fiddle_fluidsynth/misc.rb +6 -0
  43. data/lib/fiddle_fluidsynth/sequencer/events.rb +679 -0
  44. data/lib/fiddle_fluidsynth/sequencer/sequencer.rb +384 -0
  45. data/lib/fiddle_fluidsynth/sequencer.rb +7 -0
  46. data/lib/fiddle_fluidsynth/settings/settings.rb +465 -0
  47. data/lib/fiddle_fluidsynth/settings.rb +6 -0
  48. data/lib/fiddle_fluidsynth/soundfonts/generators.rb +128 -0
  49. data/lib/fiddle_fluidsynth/soundfonts/loader.rb +506 -0
  50. data/lib/fiddle_fluidsynth/soundfonts/modulators.rb +247 -0
  51. data/lib/fiddle_fluidsynth/soundfonts/soundfonts.rb +64 -0
  52. data/lib/fiddle_fluidsynth/soundfonts/voices.rb +178 -0
  53. data/lib/fiddle_fluidsynth/soundfonts.rb +11 -0
  54. data/lib/fiddle_fluidsynth/synth/audio_rendering.rb +100 -0
  55. data/lib/fiddle_fluidsynth/synth/effect/chorus.rb +269 -0
  56. data/lib/fiddle_fluidsynth/synth/effect/iir_filter.rb +81 -0
  57. data/lib/fiddle_fluidsynth/synth/effect/ladspa.rb +172 -0
  58. data/lib/fiddle_fluidsynth/synth/effect/reverb.rb +207 -0
  59. data/lib/fiddle_fluidsynth/synth/effect.rb +10 -0
  60. data/lib/fiddle_fluidsynth/synth/midi/messages.rb +292 -0
  61. data/lib/fiddle_fluidsynth/synth/midi/setup.rb +235 -0
  62. data/lib/fiddle_fluidsynth/synth/midi/tuning.rb +128 -0
  63. data/lib/fiddle_fluidsynth/synth/midi.rb +9 -0
  64. data/lib/fiddle_fluidsynth/synth/params/params.rb +200 -0
  65. data/lib/fiddle_fluidsynth/synth/params.rb +8 -0
  66. data/lib/fiddle_fluidsynth/synth/soundfont_management.rb +210 -0
  67. data/lib/fiddle_fluidsynth/synth/synth.rb +114 -0
  68. data/lib/fiddle_fluidsynth/synth/voice_control.rb +94 -0
  69. data/lib/fiddle_fluidsynth/synth.rb +18 -0
  70. data/lib/fiddle_fluidsynth/types/types.rb +131 -0
  71. data/lib/fiddle_fluidsynth/types.rb +10 -0
  72. data/lib/fiddle_fluidsynth/util/callback.rb +585 -0
  73. data/lib/fiddle_fluidsynth/util/interface/settings.rb +689 -0
  74. data/lib/fiddle_fluidsynth/util/interface/soundfont.rb +115 -0
  75. data/lib/fiddle_fluidsynth/util/interface/soundfont_preset.rb +69 -0
  76. data/lib/fiddle_fluidsynth/util/interface/soundfont_sample.rb +61 -0
  77. data/lib/fiddle_fluidsynth/util/interface.rb +11 -0
  78. data/lib/fiddle_fluidsynth/util/module_hier.rb +403 -0
  79. data/lib/fiddle_fluidsynth/util/util.rb +467 -0
  80. data/lib/fiddle_fluidsynth/util-after.rb +12 -0
  81. data/lib/fiddle_fluidsynth/util.rb +37 -0
  82. data/lib/fiddle_fluidsynth/version.rb +10 -0
  83. data/lib/fiddle_fluidsynth.rb +57 -0
  84. data/sig/fiddle_fluidsynth.rbs +4 -0
  85. metadata +128 -0
@@ -0,0 +1,585 @@
1
+ #
2
+ # filename: fiddle-fluidsynth/util/callback.rb
3
+ #
4
+
5
+
6
+ #
7
+ require 'ffi'
8
+
9
+
10
+ #
11
+ #
12
+ #
13
+ class FiddleFluidSynth
14
+
15
+ #
16
+ @@error_in_callback = nil
17
+ def self.error_in_callback=(v); @@error_in_callback = v; end
18
+ def self.error_in_callback; @@error_in_callback; end
19
+
20
+ #
21
+ def self.raise_error_in_callback( notify_f: false )
22
+ #raise @@error_in_callback unless @@error_in_callback.nil?
23
+ unless @@error_in_callback.nil?
24
+ unless notify_f
25
+ raise @@error_in_callback
26
+ else
27
+ $stderr.puts "#{@@error_in_callback.message}:" +
28
+ "#{@@error_in_callback.class}"
29
+ @@error_in_callback.backtrace.each do |_e|
30
+ $stderr.puts "#{_e}"
31
+ end
32
+ end
33
+ end
34
+ @@error_in_callback
35
+ end
36
+ def raise_error_in_callback( notify_f: false )
37
+ self.class.raise_error_in_callback(notify_f: notify_f)
38
+ end
39
+
40
+ def self.notify_error_in_callback
41
+ self.raise_error_in_callback(notify_f: true)
42
+ end
43
+ def notify_error_in_callback
44
+ self.class.notify_error_in_callback(notify_f: notify_f)
45
+ end
46
+
47
+
48
+ # コールバック関数は,FiddleではなくFFIで用意する必要がある.
49
+ # (FiddleだとRubyが止まる. Fiddle::Closure::BlockCaller と
50
+ # FFI::Function との GVLの扱いの違いに由来する)
51
+ # ==== References
52
+ # - FFI, [Types](https://github.com/ffi/ffi/wiki/Types).
53
+ #
54
+
55
+ #
56
+ def self.__create_func_obj( return_type: , argtypes_ary: [] ,
57
+ thread_f: false, &blk )
58
+ func_obj = FFI::Function.new(return_type, argtypes_ary) do |*args|
59
+ # NOTE:
60
+ # without Thread.new{...}, the callback is locked at
61
+ # fluid_sequencer_send_at(). i dont know why...
62
+ #
63
+ if thread_f
64
+ Thread.new{
65
+ # error_in_callback = nil
66
+ begin
67
+ blk.(*args)
68
+ rescue ScriptError =>ex
69
+ @@error_in_callback = ex
70
+ rescue =>ex
71
+ @@error_in_callback = ex
72
+ end
73
+ }
74
+ else
75
+ # error_in_callback = nil
76
+ begin
77
+ blk.(*args)
78
+ rescue ScriptError =>ex
79
+ @@error_in_callback = ex
80
+ rescue =>ex
81
+ @@error_in_callback = ex
82
+ end
83
+ end
84
+ end
85
+
86
+ # To avoid the GC, we have to have the reference to the object
87
+ # of FFI::Function...
88
+ #
89
+ @func_obj_storage ||= {}
90
+ @func_obj_storage[func_obj.object_id] = func_obj
91
+
92
+ ret = func_obj
93
+ ret
94
+ end
95
+
96
+ def self.create_func_obj_ab( return_type: , argtypes_ary: [] ,
97
+ thread_f: false, &blk )
98
+ # func_obj = FFI::Function.new(return_type, argtypes_ary) do |a, b|
99
+ func_obj = __create_func_obj(
100
+ return_type: return_type, argtypes_ary: argtypes_ary,
101
+ thread_f: thread_f) do |a, b|
102
+ blk.(a,b)
103
+ end
104
+
105
+ ret = func_obj
106
+ ret
107
+ end
108
+
109
+ def self.create_func_obj_a4( return_type: , argtypes_ary: [] ,
110
+ thread_f: false, &blk )
111
+ func_obj = __create_func_obj(
112
+ return_type: return_type, argtypes_ary: argtypes_ary,
113
+ thread_f: thread_f) do |a,b,c,d|
114
+ blk.(a,b,c,d)
115
+ end
116
+
117
+ ret = func_obj
118
+ ret
119
+ end
120
+
121
+ def self.create_func_obj_a3( return_type: , argtypes_ary: [] ,
122
+ thread_f: false, &blk )
123
+ func_obj = __create_func_obj(
124
+ return_type: return_type, argtypes_ary: argtypes_ary,
125
+ thread_f: thread_f) do |a,b,c|
126
+ blk.(a,b,c)
127
+ end
128
+
129
+ ret = func_obj
130
+ ret
131
+ end
132
+
133
+ def self.create_func_obj_a1( return_type: , argtypes_ary: [] ,
134
+ thread_f: false, &blk )
135
+ func_obj = __create_func_obj(
136
+ return_type: return_type, argtypes_ary: argtypes_ary,
137
+ thread_f: thread_f) do |a|
138
+ blk.(a)
139
+ end
140
+
141
+ ret = func_obj
142
+ ret
143
+ end
144
+
145
+ #
146
+ def self.create_func_obj_a6( return_type: , argtypes_ary: [] ,
147
+ thread_f: false, &blk )
148
+ func_obj = __create_func_obj(
149
+ return_type: return_type, argtypes_ary: argtypes_ary) do |a,b,c, d,e,f|
150
+ blk.(a,b,c, d,e,f)
151
+ end
152
+
153
+ ret = func_obj
154
+ ret
155
+ end
156
+
157
+ #
158
+ #
159
+ #
160
+ def self.create_func_ptr( func_obj )
161
+ #
162
+ ptr_obj = Fiddle::Pointer.new(func_obj.to_ptr.address)
163
+ ret = ptr_obj
164
+ ret
165
+ end
166
+
167
+ #
168
+ # ==== Desc.
169
+ # @func_obj に保存しておかないと,GCでFFI::Functionオブジェクトが
170
+ # 削除される
171
+ #
172
+ def self.define_callback_ab( return_type: , argtypes_ary: [],
173
+ thread_f: false, &blk)
174
+ # @func_ptr_storage ||= {}
175
+
176
+ #
177
+ func_obj = create_func_obj_ab(
178
+ return_type: return_type, argtypes_ary: argtypes_ary,
179
+ thread_f: thread_f){|a,b|
180
+ blk.call(a,b)
181
+ }
182
+
183
+ #
184
+ func_ptr = create_func_ptr(func_obj)
185
+ # @func_ptr_storage[func_ptr.object_id] = func_ptr
186
+
187
+ ret = func_ptr
188
+ ret
189
+ end
190
+ def define_callback_ab( return_type: , argtypes_ary: [],
191
+ thread_f: false, &blk )
192
+ self.class.define_callback_ab(
193
+ return_type: return_type, argtypes_ary: argtypes_ary,
194
+ thread_f: thread_f){|a,b|
195
+ blk.call(a,b)
196
+ }
197
+ end
198
+
199
+ #
200
+ def self.define_callback_a4( return_type: , argtypes_ary: [],
201
+ thread_f: false, &blk)
202
+ #
203
+ func_obj = create_func_obj_a4(
204
+ return_type: return_type, argtypes_ary: argtypes_ary,
205
+ thread_f: thread_f){|a,b,c,d|
206
+ blk.call(a,b,c,d)
207
+ }
208
+
209
+ #
210
+ func_ptr = create_func_ptr(func_obj)
211
+ ret = func_ptr
212
+ ret
213
+ end
214
+ def define_callback_a4( return_type: , argtypes_ary: [] ,
215
+ thread_f: false, &blk )
216
+ self.class.define_callback_a4(
217
+ return_type: return_type, argtypes_ary: argtypes_ary,
218
+ thread_f: thread_f){|a,b,c,d|
219
+ blk.call(a,b,c,d)
220
+ }
221
+ end
222
+
223
+ #
224
+ def self.define_callback_a3( return_type: , argtypes_ary: [],
225
+ thread_f: false, &blk)
226
+ #
227
+ func_obj = create_func_obj_a3(
228
+ return_type: return_type, argtypes_ary: argtypes_ary,
229
+ thread_f: thread_f){|a,b,c|
230
+ blk.call(a,b,c)
231
+ }
232
+
233
+ #
234
+ func_ptr = create_func_ptr(func_obj)
235
+ # @func_ptr_storage[func_ptr.object_id] = func_ptr
236
+
237
+ ret = func_ptr
238
+ ret
239
+ end
240
+ def define_callback_a3( return_type: , argtypes_ary: [],
241
+ thread_f: false, &blk )
242
+ self.class.define_callback_a3(
243
+ return_type: return_type, argtypes_ary: argtypes_ary,
244
+ thread_f: thread_f){|a,b,c|
245
+ blk.call(a,b,c)
246
+ }
247
+ end
248
+
249
+ #
250
+ def self.define_callback_a1( return_type: , argtypes_ary: [],
251
+ thread_f: false, &blk)
252
+ #
253
+ func_obj = create_func_obj_a1(
254
+ return_type: return_type, argtypes_ary: argtypes_ary,
255
+ thread_f: thread_f){|a|
256
+ blk.call(a)
257
+ }
258
+
259
+ #
260
+ func_ptr = create_func_ptr(func_obj)
261
+
262
+ ret = func_ptr
263
+ ret
264
+ end
265
+ def define_callback_a1( return_type: , argtypes_ary: [] ,
266
+ thread_f: false, &blk )
267
+ self.class.define_callback_a1(
268
+ return_type: return_type, argtypes_ary: argtypes_ary,
269
+ thread_f: thread_f){|a|
270
+ blk.call(a)
271
+ }
272
+ end
273
+
274
+ #
275
+ def self.define_callback_a6( return_type: , argtypes_ary: [],
276
+ thread_f: false, &blk)
277
+ #
278
+ func_obj = create_func_obj_a6(
279
+ return_type: return_type, argtypes_ary: argtypes_ary,
280
+ thread_f: thread_f){|a,b,c,d,e,f|
281
+ blk.call(a,b,c, d,e,f)
282
+ }
283
+
284
+ #
285
+ func_ptr = create_func_ptr(func_obj)
286
+
287
+ ret = func_ptr
288
+ ret
289
+ end
290
+ def define_callback_a6( return_type: , argtypes_ary: [],
291
+ thread_f: false, &blk )
292
+ self.class.define_callback_a6(
293
+ return_type: return_type, argtypes_ary: argtypes_ary,
294
+ thread_f: thread_f){|a,b,c,d,e,f|
295
+ blk.(a,b,c,d,e,f)
296
+ }
297
+ end
298
+
299
+ end
300
+
301
+
302
+ #
303
+ #
304
+ #
305
+ class FiddleFluidSynth
306
+
307
+ # define callback function for fluid_settings_foreach().
308
+ # ====
309
+ #
310
+ # ==== See Also
311
+ # - fluid_settings_foreach_option()
312
+ # - .#define_tick_callback()
313
+ #
314
+ #
315
+ def self.define_settings_foreach_callback( &blk )
316
+ self.define_callback_a3(
317
+ return_type: :void,
318
+ argtypes_ary: [:pointer, :string, :int]){|data, name, type|
319
+ begin
320
+ blk.call(data, name, type)
321
+ #blk.call(data, cur_tick)
322
+ rescue =>ex
323
+ raise ex
324
+ end
325
+ }
326
+ end
327
+
328
+ def define_settings_foreach_callback( &blk )
329
+ self.class.define_settings_foreach_callback(){|a,b,c|
330
+ blk.call(a,b,c)
331
+ }
332
+ end
333
+
334
+ # define callback function for fluid_settings_foreach_option().
335
+ # ====
336
+ #
337
+ # ==== See Also
338
+ # - fluid_settings_foreach()
339
+ #
340
+ def self.define_settings_foreach_option_callback( &blk )
341
+ self.define_callback_a3(
342
+ return_type: :void,
343
+ argtypes_ary: [:pointer, :string, :string]){|data, name, option|
344
+ blk.call(data, name, option)
345
+ }
346
+ end
347
+
348
+ def define_settings_foreach_option_callback( &blk )
349
+ self.class.define_settings_foreach_option_callback(){|a,b,c|
350
+ blk.call(a,b,c)
351
+ }
352
+ end
353
+
354
+ end
355
+
356
+
357
+ #
358
+ #
359
+ #
360
+ class FiddleFluidSynth
361
+
362
+ # define tick callback function for fluid_player_set_tick_callback().
363
+ # ====
364
+ #
365
+ # ==== See Also
366
+ # - fluid_player_set_tick_callback()
367
+ # - fluid_player_set_playback_callback()
368
+ #
369
+ # - mid_input/: fluid_synth_handle_midi_event()
370
+ # - soundfont/loader: fluid_sfloader_set_callbacks()
371
+ #
372
+ # - logging/logging: fluid_set_log_function()
373
+ #
374
+ def self.define_tick_callback( &blk )
375
+ self.define_callback_ab(
376
+ return_type: :int, argtypes_ary: [:pointer, :int]){|data, cur_tick|
377
+ blk.call(data, cur_tick)
378
+ }
379
+ end
380
+
381
+ def define_tick_callback( &blk )
382
+ self.class.define_tick_callback(){|a,b|
383
+ blk.call(a,b)
384
+ }
385
+ end
386
+
387
+ # define playback callback function.
388
+ # ==== See Also
389
+ # - fluid_player_set_tick_callback()
390
+ # - fluid_synth_handle_midi_event()
391
+ #
392
+ def self.define_playback_callback( &blk )
393
+ self.define_callback_ab(
394
+ return_type: :int, argtypes_ary: [:pointer, :pointer]){|data, event|
395
+ blk.call(data, event)
396
+ }
397
+ end
398
+ def define_playback_callback( &blk )
399
+ self.class.define_playback_callback(){|a,b|
400
+ blk.(a,b)
401
+ }
402
+ end
403
+
404
+
405
+ # fluid_audio_func_t.
406
+ # ==== Desc
407
+ # passed to audio_driver_new2().
408
+ #
409
+ def self.define_audio_func( &blk )
410
+ self.define_callback_a6(
411
+ return_type: :int,
412
+ argtypes_ary: [:pointer, :int,
413
+ :int, :pointer, :int, :pointer, ]
414
+ ){|data, len, nfx, fx, nout, out|
415
+ blk.(data, len, nfx, fx, nout, out)
416
+ }
417
+ end
418
+ def define_audio_func( &blk )
419
+ self.class.define_audio_func(){|a,b,c,d,e,f|
420
+ blk.(a,b,c,d,e,f)
421
+ }
422
+ end
423
+
424
+
425
+ # this is meaningless for cmd_handler.
426
+ # please use cmd_handler_new(), cmd_handler_new2() before
427
+ # fluid_command(). and that's it.
428
+ # ==== See Also
429
+ # - Command Interface/Command Handler
430
+ #
431
+
432
+
433
+ # define sequencer client (sequencer event callback).
434
+ # ==== See Also
435
+ # - fluid_sequencer_register_client()
436
+ # - API Reference: MIDI sequencer.
437
+ #
438
+ def self.define_event_callback( &blk )
439
+ self.define_callback_a4(
440
+ return_type: :void,
441
+ argtypes_ary: [:uint, :pointer, :pointer, :pointer],
442
+ thread_f: true
443
+ ){|time, event, seq, data|
444
+ blk.(time,event,seq,data)
445
+ }
446
+ end
447
+ def define_event_callback( &blk )
448
+ self.class.define_event_callback(){|a,b,c,d|
449
+ blk.(a,b,c,d)
450
+ #Thread.new{ blk.(a,b,c,d) }
451
+ }
452
+ end
453
+
454
+ # define midi_event_func (handle_midi_event_func_t).
455
+ # ==== See ALso
456
+ # - midi_input/driver.rb
457
+ # - midi_input/router.rb
458
+ #
459
+ def self.define_midi_event_func( &blk )
460
+ self.define_callback_ab(
461
+ return_type: :int, argtypes_ary: [:pointer, :pointer,]){|data, ev|
462
+ blk.call(data,ev)
463
+ }
464
+ end
465
+ def define_midi_event_func( &blk )
466
+ self.class.define_midi_event_func(){|data, ev|
467
+ blk.call(data,ev)
468
+ }
469
+ end
470
+ Midi_router_handle_midi_event_default = define_midi_event_func{|data, ev|
471
+ midi_router_handle_midi_event(data, ev)
472
+ }
473
+ Synth_handle_midi_event_default = define_midi_event_func{|data, ev|
474
+ synth_handle_midi_event(data, ev)
475
+ }
476
+
477
+
478
+ # define midi_tick_func.
479
+ #
480
+ #
481
+ def self.define_midi_tick_func( &blk )
482
+ self.define_callback_ab(
483
+ return_type: :int, argtypes_ary: [:pointer, :int,]){|data, tick|
484
+ blk.call(data,tick)
485
+ }
486
+ end
487
+ def define_midi_tick_func( &blk )
488
+ self.class.define_midi_tick_func(){|data, tick|
489
+ blk.call(data,tick)
490
+ }
491
+ end
492
+
493
+
494
+ # define sfloader callbacks.
495
+ #
496
+ #
497
+ def self.define_sfloader_callback_close( &blk )
498
+ self.define_callback_a1(
499
+ return_type: :int, argtypes_ary: [:pointer,]){|handle|
500
+ blk.call(handle)
501
+ }
502
+ end
503
+ def define_sfloader_callback_close( &blk )
504
+ self.class.define_sfloader_callback_close(){|handle|
505
+ blk.call(handle)
506
+ }
507
+ end
508
+
509
+ def self.define_sfloader_callback_open( &blk )
510
+ self.define_callback_a1(
511
+ return_type: :void,
512
+ argtypes_ary: [:pointer,]){|filename|
513
+ blk.call(filename)
514
+ }
515
+ end
516
+ def define_sfloader_callback_open( &blk )
517
+ self.class.define_sfloader_callback_open(){|filename|
518
+ blk.call(filename)
519
+ }
520
+ end
521
+
522
+ def self.define_sfloader_callback_read( &blk )
523
+ self.define_callback_a3(
524
+ return_type: :int,
525
+ argtypes_ary: [:pointer,:long_long,:pointer,]){|buf,count,handle|
526
+ blk.call(buf,count,handle)
527
+ }
528
+ end
529
+ def define_sfloader_callback_read( &blk )
530
+ self.class.define_sfloader_callback_read(){|buf,count,handle|
531
+ blk.call(buf,count,handle)
532
+ }
533
+ end
534
+
535
+ def self.define_sfloader_callback_seek( &blk )
536
+ self.define_callback_a3(
537
+ return_type: :void,
538
+ argtypes_ary: [:pointer,:long_long,:pointer,]){|handle,offset,origin|
539
+ blk.call(handle,offset,origin)
540
+ }
541
+ end
542
+ def define_sfloader_callback_seek( &blk )
543
+ self.class.define_sfloader_callback_seek(){|handle,offset,origin|
544
+ blk.call(handle,offset,origin)
545
+ }
546
+ end
547
+
548
+ def self.define_sfloader_callback_tell( &blk )
549
+ self.define_callback_a1(
550
+ return_type: :long_long,
551
+ argtypes_ary: [:pointer,]){|handle|
552
+ blk.call(handle)
553
+ }
554
+ end
555
+ def define_sfloader_callback_tell( &blk )
556
+ self.class.define_sfloader_callback_tell(){|handle|
557
+ blk.call(handle)
558
+ }
559
+ end
560
+
561
+
562
+ # log function.
563
+ #
564
+ #
565
+ def self.define_log_function( &blk )
566
+ self.define_callback_a3(
567
+ return_type: :void,
568
+ argtypes_ary: [:int, :pointer, :pointer]
569
+ ){|level, message, data|
570
+ blk.call(level,message,data)
571
+ }
572
+ end
573
+ def define_log_function( &blk )
574
+ self.class.define_log_function(){|level, message, data|
575
+ blk.call(level,message,data)
576
+ }
577
+ end
578
+
579
+
580
+ end
581
+
582
+
583
+
584
+
585
+ #### endof filename: fiddle-fluidsynth/util/callback.rb