Module: Ray::Audio
- Defined in:
- ext/audio.c
Constant Summary collapse
- FORMAT_U8 =
INT2FIX(AUDIO_U8)
- FORMAT_S8 =
INT2FIX(AUDIO_S8)
- FORMAT_U16LSB =
INT2FIX(AUDIO_U16LSB)
- FORMAT_S16LSB =
INT2FIX(AUDIO_S16LSB)
- FORMAT_U16MSB =
INT2FIX(AUDIO_U16MSB)
- FORMAT_S16MSB =
INT2FIX(AUDIO_S16MSB)
- FORMAT_U16 =
INT2FIX(AUDIO_U16)
- FORMAT_S16 =
INT2FIX(AUDIO_S16)
- FORMAT_U16SYS =
INT2FIX(AUDIO_U16SYS)
- FORMAT_S16SYS =
INT2FIX(AUDIO_S16SYS)
Class Method Summary collapse
-
.format ⇒ Integer
The audio format.
-
.frequency ⇒ Integer
The audio frequency.
-
.mono? ⇒ true, false
True if mono is used.
-
.music_pos=(val) ⇒ Object
Sets the position in the current music.
-
.pause(channel = nil) ⇒ Object
If channel is set, pauses a channel.
- .paused?(channel = nil) ⇒ true, false
- .playing?(channel = nil) ⇒ true, false
-
.resume(channel = nil) ⇒ Object
If channel is set, resumes a paused channel from pause.
-
.stereo? ⇒ true, false
True if stereo is used.
-
.stop(channel = nil) ⇒ Object
If channel is set, stops playback on a channel.
-
.volume ⇒ Float
The volume for the song which is currently being played.
-
.volume=(value) ⇒ Object
Sets the volume of the song which is currently being played.
Class Method Details
.format ⇒ Integer
Returns The audio format.
19 20 21 22 23 24 25 |
# File 'ext/audio.c', line 19
VALUE ray_audio_format() {
int freq = 0, channels = 0;
uint16_t format = 0;
Mix_QuerySpec(&freq, &format, &channels);
return INT2FIX(format);
}
|
.frequency ⇒ Integer
Returns The audio frequency.
10 11 12 13 14 15 16 |
# File 'ext/audio.c', line 10
VALUE ray_audio_frequency() {
int freq = 0, channels = 0;
uint16_t format = 0;
Mix_QuerySpec(&freq, &format, &channels);
return INT2FIX(freq);
}
|
.mono? ⇒ true, false
Returns true if mono is used.
28 29 30 31 32 33 34 |
# File 'ext/audio.c', line 28
VALUE ray_audio_mono() {
int freq = 0, channels = 0;
uint16_t format = 0;
Mix_QuerySpec(&freq, &format, &channels);
return channels == 1 ? Qtrue : Qfalse;
}
|
.music_pos=(val) ⇒ Object
148 149 150 151 |
# File 'ext/audio.c', line 148
VALUE ray_audio_set_music_pos(VALUE self, VALUE val) {
Mix_SetMusicPosition(NUM2DBL(val));
return val;
}
|
.pause(channel = nil) ⇒ Object
98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'ext/audio.c', line 98
VALUE ray_audio_pause(int argc, VALUE *argv, VALUE self) {
VALUE channel;
rb_scan_args(argc, argv, "01", &channel);
if (!NIL_P(channel)) {
Mix_Pause(NUM2INT(channel));
return channel;
}
Mix_PauseMusic();
return Qnil;
}
|
.paused?(channel = nil) ⇒ true, false
134 135 136 137 138 139 140 141 |
# File 'ext/audio.c', line 134
VALUE ray_audio_paused(int argc, VALUE *argv, VALUE self) {
VALUE channel;
rb_scan_args(argc, argv, "01", &channel);
if (!NIL_P(channel))
return Mix_Paused(NUM2INT(channel)) ? Qtrue : Qfalse;
return Mix_PausedMusic() ? Qtrue : Qfalse;
}
|
.playing?(channel = nil) ⇒ true, false
67 68 69 70 71 72 73 74 |
# File 'ext/audio.c', line 67
VALUE ray_audio_playing(int argc, VALUE *argv, VALUE self) {
VALUE channel = Qnil;
rb_scan_args(argc, argv, "01", &channel);
if (NIL_P(channel))
return Mix_PlayingMusic() ? Qtrue : Qfalse;
return Mix_Playing(NUM2INT(channel)) ? Qtrue: Qfalse;
}
|
.resume(channel = nil) ⇒ Object
116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'ext/audio.c', line 116
VALUE ray_audio_resume(int argc, VALUE *argv, VALUE self) {
VALUE channel;
rb_scan_args(argc, argv, "01", &channel);
if (!NIL_P(channel)) {
Mix_Resume(NUM2INT(channel));
return channel;
}
Mix_ResumeMusic();
return Qnil;
}
|
.stereo? ⇒ true, false
Returns true if stereo is used.
37 38 39 40 41 42 43 |
# File 'ext/audio.c', line 37
VALUE ray_audio_stereo() {
int freq = 0, channels = 0;
uint16_t format = 0;
Mix_QuerySpec(&freq, &format, &channels);
return channels == 1 ? Qfalse : Qtrue;
}
|
.stop(channel = nil) ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'ext/audio.c', line 81
VALUE ray_audio_stop(int argc, VALUE *argv, VALUE self) {
VALUE channel;
rb_scan_args(argc, argv, "01", &channel);
if (!NIL_P(channel)) {
Mix_HaltChannel(NUM2INT(channel));
return channel;
}
Mix_HaltMusic();
return Qnil;
}
|
.volume ⇒ Float
Returns The volume for the song which is currently being played. 0 is the minimum volume, whereas 100 is the maximum.
49 50 51 52 |
# File 'ext/audio.c', line 49
VALUE ray_audio_volume(VALUE self) {
int volume = Mix_VolumeMusic(-1);
return rb_float_new((volume / 128.0f) * 100.0f);
}
|
.volume=(value) ⇒ Object
Sets the volume of the song which is currently being played
55 56 57 58 59 60 |
# File 'ext/audio.c', line 55
VALUE ray_audio_set_volume(VALUE self, VALUE value) {
float volume = (float)NUM2DBL(value);
Mix_VolumeMusic((int)((volume / 100.0f) * 128.0f));
return value;
}
|