rubygame 2.2.0 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -22,41 +22,45 @@
22
22
 
23
23
  #include "rubygame_shared.h"
24
24
  #include "rubygame_mixer.h"
25
+ #include "rubygame_sound.h"
26
+ #include "rubygame_music.h"
27
+
25
28
 
26
- void Init_rubygame_mixer();
27
29
  VALUE mMixer;
30
+ VALUE cSample;
31
+ VALUE cOldMusic;
28
32
 
29
- VALUE rbgm_mixer_openaudio(int, VALUE*, VALUE);
30
- VALUE rbgm_mixer_closeaudio(VALUE);
31
- VALUE rbgm_mixer_getmixchans();
32
- VALUE rbgm_mixer_setmixchans(VALUE, VALUE);
33
- VALUE rbgm_mixer_getdrivername(VALUE);
34
33
 
35
- VALUE cSample;
36
- VALUE rbgm_sample_new(VALUE, VALUE);
37
- VALUE rbgm_mixchan_play( VALUE, VALUE, VALUE, VALUE );
38
- VALUE rbgm_mixchan_stop( VALUE, VALUE );
39
- VALUE rbgm_mixchan_pause( VALUE, VALUE );
40
- VALUE rbgm_mixchan_resume( VALUE, VALUE );
41
-
42
- VALUE cMusic;
43
- VALUE rbgm_mixmusic_setcommand(VALUE, VALUE);
44
- VALUE rbgm_mixmusic_new(VALUE, VALUE);
45
-
46
- VALUE rbgm_mixmusic_play(int, VALUE*, VALUE);
47
- VALUE rbgm_mixmusic_stop(VALUE);
48
- VALUE rbgm_mixmusic_resume(VALUE);
49
- VALUE rbgm_mixmusic_pause(VALUE);
50
- VALUE rbgm_mixmusic_rewind(VALUE);
51
- VALUE rbgm_mixmusic_jump(VALUE, VALUE);
52
- VALUE rbgm_mixmusic_paused(VALUE);
53
- VALUE rbgm_mixmusic_playing(VALUE);
54
-
55
- VALUE rbgm_mixmusic_getvolume(VALUE);
56
- VALUE rbgm_mixmusic_setvolume(VALUE, VALUE);
57
- VALUE rbgm_mixmusic_fadein(int, VALUE*, VALUE);
58
- VALUE rbgm_mixmusic_fadeout(VALUE, VALUE);
59
- VALUE rbgm_mixmusic_fading(int, VALUE*, VALUE);
34
+ /* Return 1 if SDL_mixer audio is open, or 0 if it is not. */
35
+ int audio_is_open()
36
+ {
37
+ /* We don't actually care about these, but Mix_QuerySpec wants args. */
38
+ int frequency; Uint16 format; int channels;
39
+
40
+ int result = Mix_QuerySpec(&frequency, &format, &channels);
41
+
42
+ return ( (result > 0) ? 1 : 0 );
43
+ }
44
+
45
+ /*
46
+ * If SDL_mixer audio is not open, try to open it with the default
47
+ * arguments, and return the result. If it's already open, return 0
48
+ * without doing anything.
49
+ */
50
+ int ensure_open_audio()
51
+ {
52
+ if( audio_is_open() )
53
+ {
54
+ return 0;
55
+ }
56
+ else
57
+ {
58
+ return Mix_OpenAudio( MIX_DEFAULT_FREQUENCY,
59
+ MIX_DEFAULT_FORMAT,
60
+ 2,
61
+ 1024 );
62
+ }
63
+ }
60
64
 
61
65
 
62
66
  /* --
@@ -66,7 +70,10 @@ VALUE rbgm_mixmusic_fading(int, VALUE*, VALUE);
66
70
 
67
71
  /* call-seq:
68
72
  * open_audio( frequency=nil, format=nil, channels=nil, buffer=nil)
69
- *
73
+ *
74
+ * **NOTE:** This method is DEPRECATED and will be removed in
75
+ * Rubygame 3.0. Please use the Rubygame.open_audio instead.
76
+ *
70
77
  * Initializes the audio device. You must call this before using the other
71
78
  * mixer functions. See also #close_audio().
72
79
  *
@@ -103,6 +110,10 @@ VALUE rbgm_mixmusic_fading(int, VALUE*, VALUE);
103
110
  */
104
111
  VALUE rbgm_mixer_openaudio(int argc, VALUE *argv, VALUE module)
105
112
  {
113
+
114
+ /* This feature will be removed in Rubygame 3.0. */
115
+ rg_deprecated("Rubygame::Mixer", "3.0");
116
+
106
117
  VALUE vfreq, vformat, vchannels, vbuffer;
107
118
  int freq = MIX_DEFAULT_FREQUENCY;
108
119
  Uint16 format = MIX_DEFAULT_FORMAT;
@@ -141,7 +152,10 @@ VALUE rbgm_mixer_openaudio(int argc, VALUE *argv, VALUE module)
141
152
 
142
153
  /* call-seq:
143
154
  * close_audio()
144
- *
155
+ *
156
+ * **NOTE:** This method is DEPRECATED and will be removed in
157
+ * Rubygame 3.0. Please use the Rubygame.close_audio instead.
158
+ *
145
159
  * Close the audio device being used by the mixer. You should not use any
146
160
  * mixer functions after this function, unless you use #open_audio() to
147
161
  * re-open the audio device. See also #open_audio().
@@ -150,18 +164,185 @@ VALUE rbgm_mixer_openaudio(int argc, VALUE *argv, VALUE module)
150
164
  */
151
165
  VALUE rbgm_mixer_closeaudio(VALUE module)
152
166
  {
167
+ /* This feature will be removed in Rubygame 3.0. */
168
+ rg_deprecated("Rubygame::Mixer", "3.0");
169
+
153
170
  Mix_CloseAudio();
154
171
  return Qnil;
155
172
  }
156
173
 
174
+
175
+
176
+ /* call-seq:
177
+ * open_audio( options={ :buffer => 1024, :channels => 2, :frequency => 22050 } ) -> true or false
178
+ *
179
+ * Initializes the audio device using the given settings.
180
+ *
181
+ * NOTE: Audio will be automatically opened when Rubygame::Sound or
182
+ * Rubygame::Music are first used. You only need to open audio
183
+ * manually if you want settings different from the default, or if
184
+ * you are using the older, deprecated Music and Sample classes from
185
+ * the Rubygame::Mixer module.
186
+ *
187
+ * If audio is already open, this method has no effect, and returns false.
188
+ * If you want to change audio settings, you must #close_audio() and
189
+ * then open it again.
190
+ *
191
+ * options:: A Hash of any of the following options. (Hash, optional)
192
+ *
193
+ * :frequency:: output sample rate in audio samples per second
194
+ * (Hz). Affects the quality of the sound output, at
195
+ * the expense of CPU usage. If omitted, the default
196
+ * (22050) is used. The default is recommended for
197
+ * most games.
198
+ *
199
+ * :channels:: output sound channels. Use 2 for stereo, 1 for mono.
200
+ * If omitted, the default (2) is used.
201
+ *
202
+ * :buffer:: size of the sound buffer, in bytes. Must be a
203
+ * power of 2 (e.g. 512, 1024, 2048). If omitted,
204
+ * the default (1024) is used. If your game is
205
+ * fast-paced, you may want to use a smaller value
206
+ * to reduce audio delay, the time between when you
207
+ * play a sound and when it is heard.
208
+ *
209
+ * Returns:: true if the audio was newly opened by this action, or
210
+ * false if it was already open before this action.
211
+ *
212
+ * May raise:: SDLError, if initialization fails.
213
+ * ArgumentError, if an invalid value is given for any option.
214
+ *
215
+ *
216
+ */
217
+ VALUE rbgm_mixer_openaudio2(int argc, VALUE *argv, VALUE module)
218
+ {
219
+ VALUE options;
220
+
221
+ int buffer = 1024;
222
+ int channels = 2;
223
+ int frequency = MIX_DEFAULT_FREQUENCY;
224
+
225
+ /* In general, format should always be the default. */
226
+ Uint16 format = MIX_DEFAULT_FORMAT;
227
+
228
+
229
+ /* Does nothing if audio is already open. */
230
+ if( audio_is_open() )
231
+ {
232
+ return Qfalse;
233
+ }
234
+
235
+
236
+ rb_scan_args(argc, argv, "01", &options);
237
+
238
+
239
+ if( RTEST(options) )
240
+ {
241
+ /* Make sure options is a Hash table */
242
+ if( TYPE(options) != T_HASH )
243
+ {
244
+ rb_raise(rb_eTypeError, "wrong argument type %s (expected Hash)",
245
+ rb_obj_classname(options));
246
+ }
247
+
248
+ VALUE temp;
249
+
250
+ /* Buffer size */
251
+ temp = rb_hash_aref(options, make_symbol("buffer"));
252
+ if( RTEST(temp) )
253
+ {
254
+ buffer = NUM2INT(temp);
255
+
256
+ if( buffer <= 0 )
257
+ {
258
+ rb_raise(rb_eArgError, "buffer size must be positive (got %d)", buffer);
259
+ }
260
+
261
+ /* Check to see if it's not a power of two */
262
+ if( buffer & (buffer - 1) != 0 )
263
+ {
264
+ rb_raise(rb_eArgError, "buffer size must be a power of 2 (e.g. 512, 1024) (got %d)", buffer);
265
+ }
266
+ }
267
+
268
+ /* Channels */
269
+ temp = rb_hash_aref(options, make_symbol("channels"));
270
+ if( RTEST(temp) )
271
+ {
272
+ channels = NUM2INT(temp);
273
+
274
+ if( channels != 1 && channels != 2 )
275
+ {
276
+ rb_raise(rb_eArgError, "channels must be 1 (mono) or 2 (stereo) (got %d)", channels);
277
+ }
278
+ }
279
+
280
+ /* Frequency */
281
+ temp = rb_hash_aref(options, make_symbol("frequency"));
282
+ if( RTEST(temp) )
283
+ {
284
+ frequency = NUM2INT(temp);
285
+
286
+ if( frequency <= 0 )
287
+ {
288
+ rb_raise(rb_eArgError, "frequency must be positive (got %d)", frequency);
289
+ }
290
+ }
291
+ }
292
+
293
+ int result = Mix_OpenAudio(frequency, format, channels, buffer);
294
+
295
+ if( result < 0 )
296
+ {
297
+ rb_raise(eSDLError, "Could not open audio: %s", Mix_GetError());
298
+ }
299
+
300
+ return Qtrue;
301
+ }
302
+
303
+
304
+ /* call-seq:
305
+ * close_audio() -> true or false
306
+ *
307
+ * Deinitializes and closes the audio device. If audio was not open,
308
+ * this method does nothing, and returns false. See also #open_audio().
309
+ *
310
+ * NOTE: The audio will be automatically closed when the program
311
+ * exits. You only need to close audio manually if you want to
312
+ * call #open_audio with different settings.
313
+ *
314
+ * Returns:: true if the audio changed from open to closed, or
315
+ * false if the audio was not open before this action.
316
+ */
317
+ VALUE rbgm_mixer_closeaudio2(VALUE module)
318
+ {
319
+ if( audio_is_open() )
320
+ {
321
+ Mix_CloseAudio();
322
+ return Qtrue;
323
+ }
324
+ else
325
+ {
326
+ return Qfalse;
327
+ }
328
+ }
329
+
330
+
331
+
157
332
  /* call-seq:
158
333
  * #mix_channels() -> integer
159
334
  *
335
+ * **NOTE:** This method is DEPRECATED and will be removed in
336
+ * Rubygame 3.0. Please use the Rubygame::Sound class instead.
337
+ *
160
338
  * Returns the number of mixing channels currently allocated.
161
339
  * See also #mix_channels=().
162
340
  */
163
341
  VALUE rbgm_mixer_getmixchans(VALUE module)
164
342
  {
343
+ /* This feature will be removed in Rubygame 3.0. */
344
+ rg_deprecated("Rubygame::Mixer", "3.0");
345
+
165
346
  int result;
166
347
  result = Mix_AllocateChannels(-1);
167
348
 
@@ -171,6 +352,9 @@ VALUE rbgm_mixer_getmixchans(VALUE module)
171
352
  /* call-seq:
172
353
  * #mix_channels = num_channels
173
354
  *
355
+ * **NOTE:** This method is DEPRECATED and will be removed in
356
+ * Rubygame 3.0. Please use the Rubygame::Sound class instead.
357
+ *
174
358
  * Set the number of mixer channels, allocating or deallocating channels as
175
359
  * needed. This can be called many times, even during audio playback. If this
176
360
  * call reduces the number of channels allocated, the excess channels will
@@ -190,6 +374,9 @@ VALUE rbgm_mixer_getmixchans(VALUE module)
190
374
  */
191
375
  VALUE rbgm_mixer_setmixchans(VALUE module, VALUE channelsv)
192
376
  {
377
+ /* This feature will be removed in Rubygame 3.0. */
378
+ rg_deprecated("Rubygame::Mixer", "3.0");
379
+
193
380
  int desired;
194
381
  int allocated;
195
382
 
@@ -202,6 +389,9 @@ VALUE rbgm_mixer_setmixchans(VALUE module, VALUE channelsv)
202
389
  /* call-seq:
203
390
  * driver_name -> string
204
391
  *
392
+ * **NOTE:** This method is DEPRECATED and will be removed in
393
+ * Rubygame 3.0. Please use the Rubygame.audio_driver instead.
394
+ *
205
395
  * Returns the name of the audio driver that SDL is using.
206
396
  *
207
397
  * May raise an SDLError if initialization fails.
@@ -209,10 +399,36 @@ VALUE rbgm_mixer_setmixchans(VALUE module, VALUE channelsv)
209
399
 
210
400
  VALUE rbgm_mixer_getdrivername(VALUE module)
211
401
  {
402
+ /* This feature will be removed in Rubygame 3.0. */
403
+ rg_deprecated("Rubygame::Mixer", "3.0");
404
+
405
+ char driver_name[1024];
406
+ if(SDL_AudioDriverName(driver_name, sizeof(driver_name)) == NULL)
407
+ {
408
+ rb_raise(eSDLError, "Error fetching audio driver name: %s", SDL_GetError());
409
+ }
410
+ return rb_str_new2(driver_name);
411
+ }
412
+
413
+ /* call-seq:
414
+ * audio_driver -> string
415
+ *
416
+ * Returns the name of the audio driver that SDL is using.
417
+ *
418
+ * May raise an SDLError if initialization fails.
419
+ */
420
+
421
+ VALUE rbgm_mixer_audiodriver(VALUE module)
422
+ {
423
+ if( ensure_open_audio() != 0 )
424
+ {
425
+ rb_raise(eSDLError, "Could not initialize audio: %s", Mix_GetError());
426
+ }
427
+
212
428
  char driver_name[1024];
213
429
  if(SDL_AudioDriverName(driver_name, sizeof(driver_name)) == NULL)
214
430
  {
215
- rb_raise(eSDLError, "Error fetrching audio driver name: %s", SDL_GetError());
431
+ rb_raise(eSDLError, "Could not get audio driver name: %s", Mix_GetError());
216
432
  }
217
433
  return rb_str_new2(driver_name);
218
434
  }
@@ -227,6 +443,9 @@ VALUE rbgm_mixer_getdrivername(VALUE module)
227
443
  /* call-seq:
228
444
  * load_audio( filename ) -> Sample
229
445
  *
446
+ * **NOTE:** Rubygame::Mixer::Sample is DEPRECATED and will be removed in
447
+ * Rubygame 3.0. Please use the Rubygame::Sound class instead.
448
+ *
230
449
  * Load an audio sample (a "chunk", to use SDL_mixer's term) from a file.
231
450
  * Only WAV files are supported at this time.
232
451
  *
@@ -234,6 +453,9 @@ VALUE rbgm_mixer_getdrivername(VALUE module)
234
453
  */
235
454
  VALUE rbgm_sample_new(VALUE class, VALUE filev)
236
455
  {
456
+ /* This feature will be removed in Rubygame 3.0. */
457
+ rg_deprecated("Rubygame::Mixer::Sample", "3.0");
458
+
237
459
  VALUE self;
238
460
  Mix_Chunk* sample;
239
461
 
@@ -254,6 +476,9 @@ VALUE rbgm_sample_new(VALUE class, VALUE filev)
254
476
  /* call-seq:
255
477
  * play(sample, channel_num, repeats ) -> integer
256
478
  *
479
+ * **NOTE:** This method is DEPRECATED and will be removed in
480
+ * Rubygame 3.0. Please use the Rubygame::Sound class instead.
481
+ *
257
482
  * Play an audio Sample on a mixing channel, repeating a certain number
258
483
  * of extra times. Returns the number of the channel that the sample
259
484
  * is being played on.
@@ -269,6 +494,10 @@ VALUE rbgm_sample_new(VALUE class, VALUE filev)
269
494
  */
270
495
  VALUE rbgm_mixchan_play( VALUE self, VALUE samplev, VALUE chanv, VALUE loopsv )
271
496
  {
497
+
498
+ /* This feature will be removed in Rubygame 3.0. */
499
+ rg_deprecated("Rubygame::Mixer", "3.0");
500
+
272
501
  Mix_Chunk* sample;
273
502
  int loops, channel, result;
274
503
 
@@ -359,12 +588,19 @@ VALUE rbgm_mixmusic_setcommand(VALUE class, VALUE commandv)
359
588
  /* call-seq:
360
589
  * load_audio( filename ) -> Music
361
590
  *
591
+ * **NOTE:** Rubygame::Mixer::Music is DEPRECATED and will be removed
592
+ * in Rubygame 3.0. Please use the Rubygame::Music class instead.
593
+ *
362
594
  * Load music from a file. Supports WAVE, MOD, MIDI, OGG, and MP3 formats.
363
595
  *
364
596
  * Raises SDLError if the music could not be loaded.
365
597
  */
366
598
  VALUE rbgm_mixmusic_new(VALUE class, VALUE filev)
367
599
  {
600
+
601
+ /* This feature will be removed in Rubygame 3.0. */
602
+ rg_deprecated("Rubygame::Mixer::Music", "3.0");
603
+
368
604
  VALUE self;
369
605
  Mix_Music* music;
370
606
 
@@ -375,7 +611,7 @@ VALUE rbgm_mixmusic_new(VALUE class, VALUE filev)
375
611
  rb_raise(eSDLError, "Error loading audio music from file `%s': %s",
376
612
  StringValuePtr(filev), Mix_GetError());
377
613
  }
378
- self = Data_Wrap_Struct( cMusic, 0, Mix_FreeMusic, music );
614
+ self = Data_Wrap_Struct( cOldMusic, 0, Mix_FreeMusic, music );
379
615
 
380
616
  //rb_obj_call_init(self,argc,argv);
381
617
 
@@ -689,6 +925,9 @@ void Init_rubygame_mixer()
689
925
 
690
926
  Init_rubygame_shared();
691
927
 
928
+ Rubygame_Init_Sound();
929
+ Rubygame_Init_Music();
930
+
692
931
  rb_hash_aset(rb_ivar_get(mRubygame,rb_intern("VERSIONS")),
693
932
  ID2SYM(rb_intern("sdl_mixer")),
694
933
  rb_ary_new3(3,
@@ -696,14 +935,27 @@ void Init_rubygame_mixer()
696
935
  INT2NUM(SDL_MIXER_MINOR_VERSION),
697
936
  INT2NUM(SDL_MIXER_PATCHLEVEL)));
698
937
 
699
- /*
700
- * The Mixer module provides access to the SDL_mixer library for audio
701
- * playback and mixing. This module is still very basic, but it is
702
- * good enough to load and play WAV files on multiple mix channels.
703
- *
704
- * See the Sample class for loading audio files.
705
- * See the Music class for streaming music from a file.
706
- */
938
+ /*
939
+ * Moving these to be under Rubygame module instead of Mixer.
940
+ */
941
+ rb_define_module_function(mRubygame,"open_audio", rbgm_mixer_openaudio2, -1);
942
+ rb_define_module_function(mRubygame,"close_audio", rbgm_mixer_closeaudio2, 0);
943
+ rb_define_module_function(mRubygame,"audio_driver",rbgm_mixer_audiodriver, 0);
944
+
945
+
946
+
947
+ /*
948
+ * **NOTE:** This module is DEPRECATED and will be removed in Rubygame 3.0.
949
+ * Please use Rubygame.open_audio, Rubygame.close_audio, Rubygame::Sound,
950
+ * and Rubygame::Music instead.
951
+ *
952
+ * The Mixer module provides access to the SDL_mixer library for audio
953
+ * playback and mixing. This module is still very basic, but it is
954
+ * good enough to load and play WAV files on multiple mix channels.
955
+ *
956
+ * See the Sample class for loading audio files.
957
+ * See the Music class for streaming music from a file.
958
+ */
707
959
  mMixer = rb_define_module_under(mRubygame, "Mixer");
708
960
 
709
961
  rb_define_const(mMixer,"AUDIO_U8", INT2NUM(AUDIO_U8));
@@ -718,8 +970,12 @@ void Init_rubygame_mixer()
718
970
  rb_define_module_function(mMixer,"driver_name", rbgm_mixer_getdrivername, 0);
719
971
 
720
972
 
721
-
722
- /* Stores audio data to play with Mixer.play() */
973
+ /*
974
+ * **NOTE:** This class is DEPRECATED and will be removed in Rubygame 3.0.
975
+ * Please use the Rubygame::Sound class instead.
976
+ *
977
+ * Stores audio data to play with Mixer.play()
978
+ */
723
979
  cSample = rb_define_class_under(mMixer, "Sample", rb_cObject);
724
980
  rb_define_singleton_method(cSample, "load_audio", rbgm_sample_new, 1);
725
981
  rb_define_module_function(mMixer,"play", rbgm_mixchan_play, 3);
@@ -728,7 +984,11 @@ void Init_rubygame_mixer()
728
984
  rb_define_module_function(mMixer,"resume", rbgm_mixchan_resume, 1);
729
985
 
730
986
 
731
- /* The Music class is used for playing music from a file. It supports
987
+ /*
988
+ * **NOTE:** This class is DEPRECATED and will be removed in Rubygame 3.0.
989
+ * Please use the Rubygame::Music class instead.
990
+ *
991
+ * The Music class is used for playing music from a file. It supports
732
992
  * WAVE, MOD, MIDI, OGG, and MP3 files. There are two important differences
733
993
  * between Music and Sample:
734
994
  *
@@ -740,25 +1000,25 @@ void Init_rubygame_mixer()
740
1000
  * be many Samples playing at once. If you play a second Music while one
741
1001
  * is already playing, the first one will be stopped. See #play.
742
1002
  */
743
- cMusic = rb_define_class_under(mMixer, "Music", rb_cObject);
744
- rb_define_singleton_method(cMusic, "load_audio", rbgm_mixmusic_new, 1);
1003
+ cOldMusic = rb_define_class_under(mMixer, "Music", rb_cObject);
1004
+ rb_define_singleton_method(cOldMusic, "load_audio", rbgm_mixmusic_new, 1);
745
1005
 
746
- //rb_define_singleton_method(cMusic, "set_command", rbgm_mixmusic_setcommand, 1);
1006
+ //rb_define_singleton_method(cOldMusic, "set_command", rbgm_mixmusic_setcommand, 1);
747
1007
 
748
- rb_define_method(cMusic, "play", rbgm_mixmusic_play, -1);
749
- rb_define_method(cMusic, "stop", rbgm_mixmusic_stop, 0);
750
- rb_define_method(cMusic, "pause", rbgm_mixmusic_pause, 0);
751
- rb_define_method(cMusic, "resume", rbgm_mixmusic_resume, 0);
752
- rb_define_method(cMusic, "rewind", rbgm_mixmusic_rewind, 0);
753
- rb_define_method(cMusic, "jump", rbgm_mixmusic_jump, 1);
754
- rb_define_method(cMusic, "paused?", rbgm_mixmusic_paused, 0);
755
- rb_define_method(cMusic, "playing?", rbgm_mixmusic_playing, 0);
756
-
757
- rb_define_method(cMusic, "volume", rbgm_mixmusic_getvolume, 0);
758
- rb_define_method(cMusic, "volume=", rbgm_mixmusic_setvolume, 1);
759
- rb_define_method(cMusic, "fade_in", rbgm_mixmusic_fadein, -1);
760
- rb_define_method(cMusic, "fade_out", rbgm_mixmusic_fadeout, 1);
761
- rb_define_method(cMusic, "fading?", rbgm_mixmusic_fading, -1);
1008
+ rb_define_method(cOldMusic, "play", rbgm_mixmusic_play, -1);
1009
+ rb_define_method(cOldMusic, "stop", rbgm_mixmusic_stop, 0);
1010
+ rb_define_method(cOldMusic, "pause", rbgm_mixmusic_pause, 0);
1011
+ rb_define_method(cOldMusic, "resume", rbgm_mixmusic_resume, 0);
1012
+ rb_define_method(cOldMusic, "rewind", rbgm_mixmusic_rewind, 0);
1013
+ rb_define_method(cOldMusic, "jump", rbgm_mixmusic_jump, 1);
1014
+ rb_define_method(cOldMusic, "paused?", rbgm_mixmusic_paused, 0);
1015
+ rb_define_method(cOldMusic, "playing?", rbgm_mixmusic_playing, 0);
1016
+
1017
+ rb_define_method(cOldMusic, "volume", rbgm_mixmusic_getvolume, 0);
1018
+ rb_define_method(cOldMusic, "volume=", rbgm_mixmusic_setvolume, 1);
1019
+ rb_define_method(cOldMusic, "fade_in", rbgm_mixmusic_fadein, -1);
1020
+ rb_define_method(cOldMusic, "fade_out", rbgm_mixmusic_fadeout, 1);
1021
+ rb_define_method(cOldMusic, "fading?", rbgm_mixmusic_fading, -1);
762
1022
  }
763
1023
 
764
1024
 
@@ -24,39 +24,13 @@
24
24
  #include "SDL_audio.h"
25
25
  #include "SDL_mixer.h"
26
26
 
27
- extern void Init_rubygame_mixer();
28
- extern VALUE mMixer;
27
+ extern int audio_is_open();
28
+ extern int ensure_open_audio();
29
29
 
30
- extern VALUE rbgm_mixer_openaudio(int, VALUE*, VALUE);
31
- extern VALUE rbgm_mixer_closeaudio(VALUE);
32
- extern VALUE rbgm_mixer_getmixchans();
33
- extern VALUE rbgm_mixer_setmixchans(VALUE, VALUE);
34
- extern VALUE rbgm_mixer_getdrivername(VALUE);
30
+ extern void Init_rubygame_mixer();
35
31
 
32
+ extern VALUE mMixer;
36
33
  extern VALUE cSample;
37
- extern VALUE rbgm_sample_new(VALUE, VALUE);
38
- extern VALUE rbgm_mixchan_play( VALUE, VALUE, VALUE, VALUE );
39
- extern VALUE rbgm_mixchan_stop( VALUE, VALUE );
40
- extern VALUE rbgm_mixchan_pause( VALUE, VALUE );
41
- extern VALUE rbgm_mixchan_resume( VALUE, VALUE );
42
-
43
- extern VALUE cMusic;
44
- extern VALUE rbgm_mixmusic_setcommand(VALUE, VALUE);
45
- extern VALUE rbgm_mixmusic_new(VALUE, VALUE);
46
-
47
- extern VALUE rbgm_mixmusic_play(int, VALUE*, VALUE);
48
- extern VALUE rbgm_mixmusic_stop(VALUE);
49
- extern VALUE rbgm_mixmusic_resume(VALUE);
50
- extern VALUE rbgm_mixmusic_pause(VALUE);
51
- extern VALUE rbgm_mixmusic_rewind(VALUE);
52
- extern VALUE rbgm_mixmusic_jump(VALUE, VALUE);
53
- extern VALUE rbgm_mixmusic_paused(VALUE);
54
- extern VALUE rbgm_mixmusic_playing(VALUE);
55
-
56
- extern VALUE rbgm_mixmusic_getvolume(VALUE);
57
- extern VALUE rbgm_mixmusic_setvolume(VALUE, VALUE);
58
- extern VALUE rbgm_mixmusic_fadein(int, VALUE*, VALUE);
59
- extern VALUE rbgm_mixmusic_fadeout(VALUE, VALUE);
60
- extern VALUE rbgm_mixmusic_fading(int, VALUE*, VALUE);
34
+ extern VALUE cOldMusic;
61
35
 
62
36
  #endif