Class: SDL::Audio
- Inherits:
-
Object
- Object
- SDL::Audio
- Defined in:
- ext/sdl/sdl.c
Class Method Summary collapse
- .load(path) ⇒ Object
-
.open(n_channels) ⇒ Object
// SDL::Audio methods:.
Instance Method Summary collapse
Class Method Details
.load(path) ⇒ Object
204 205 206 207 208 209 210 211 212 213 214 |
# File 'ext/sdl/sdl.c', line 204
static VALUE Audio_s_load(VALUE self, VALUE path) {
UNUSED(self);
ExportStringValue(path);
Mix_Chunk *chunk = Mix_LoadWAV(RSTRING_PTR(path));
if (!chunk)
AUDIO_FAILURE("Audio.load");
return TypedData_Wrap_Struct(cAudio, &_Audio_type, chunk);
}
|
.open(n_channels) ⇒ Object
// SDL::Audio methods:
189 190 191 192 193 194 195 196 197 198 199 200 201 202 |
# File 'ext/sdl/sdl.c', line 189
static VALUE Audio_s_open(VALUE self, VALUE n_channels) {
UNUSED(self);
int n = NUM2INT(n_channels);
// TODO: int Mix_Init(MIX_INIT_MP3) ?
if (Mix_QuerySpec(NULL, NULL, NULL))
return Qnil; // TODO: raise?
if (Mix_OpenAudio(22050, MIX_DEFAULT_FORMAT, 2, 4096))
AUDIO_FAILURE("SDL::Audio.open");
return INT2FIX(Mix_AllocateChannels(n));
}
|
Instance Method Details
#play ⇒ Object
216 217 218 219 220 221 222 223 |
# File 'ext/sdl/sdl.c', line 216
static VALUE Audio_play(VALUE self) {
DEFINE_SELF(Audio, audio, self);
if (Mix_PlayChannel(-1, audio, 0) < 0)
AUDIO_FAILURE("Audio#play");
return Qnil;
}
|