Module: SDL2::Mixer::Channels
- Defined in:
- mixer.c,
mixer.c
Overview
This module plays Chunk objects in parallel.
Each virtual sound output device is called channel, and the number of channels determines the f
Defined Under Namespace
Classes: Group
Class Method Summary collapse
-
.allocate(num_channels) ⇒ Integer
Set the number of channels being mixed.
-
.expire(channel, ticks) ⇒ nil
Halt playing of a specified channel after ticks milliseconds.
-
.fade_in(channel, chunk, loops, ms, ticks = -1) ⇒ Integer
Play a Chunk on channel with fading in.
-
.fade_out(channel, ms) ⇒ nil
Halt playing of a specified channel with fade-out effect.
-
.fading(channel) ⇒ Integer
Return the fading state of a specified channel.
-
.halt(channel) ⇒ nil
Halt playing of a specified channel.
-
.pause(channel) ⇒ nil
Pause a specified channel.
-
.pause?(channel) ⇒ Boolean
Return true if a specified channel is paused.
-
.play(channel, chunk, loops, ticks = -1) ⇒ Integer
Play a Chunk on channel.
-
.play?(channel) ⇒ Boolean
Return true if a specified channel is playing.
-
.playing_chunk(channel) ⇒ SDL2::Mixer::Chunk?
Get the Chunk object most recently playing on channel.
-
.reserve(num) ⇒ Integer
Reserve channel from 0 to num-1 and reserved channels are not used by Channels.play and Channels.fade_in with channels==-1.
-
.resume(channel) ⇒ nil
Resume a specified channel that already pauses.
-
.set_volume(channel, volume) ⇒ void
Set the volume of specified channel.
-
.volume(channel) ⇒ Integer
Get the volume of specified channel.
Class Method Details
.allocate(num_channels) ⇒ Integer
230 231 232 233 |
# File 'mixer.c', line 230
static VALUE Channels_s_allocate(VALUE self, VALUE num_channels)
{
return INT2NUM(Mix_AllocateChannels(NUM2INT(num_channels)));
}
|
.expire(channel, ticks) ⇒ nil
428 429 430 431 432 433 |
# File 'mixer.c', line 428
static VALUE Channels_s_expire(VALUE self, VALUE channel, VALUE ticks)
{
check_channel(channel, 1);
Mix_ExpireChannel(NUM2INT(channel), NUM2INT(ticks));
return Qnil;
}
|
.fade_in(channel, chunk, loops, ms, ticks = -1) ⇒ Integer
348 349 350 351 352 353 354 355 356 357 358 359 360 361 |
# File 'mixer.c', line 348
static VALUE Channels_s_fade_in(int argc, VALUE* argv, VALUE self)
{
VALUE channel, chunk, loops, ms, ticks;
int ch;
rb_scan_args(argc, argv, "41", &channel, &chunk, &loops, &ms, &ticks);
if (ticks == Qnil)
ticks = INT2FIX(-1);
check_channel(channel, 1);
ch = Mix_FadeInChannelTimed(NUM2INT(channel), Get_Mix_Chunk(chunk),
NUM2INT(loops), NUM2INT(ms), NUM2INT(ticks));
HANDLE_MIX_ERROR(ch);
protect_playing_chunk_from_gc(ch, chunk);
return INT2FIX(ch);
}
|
.fade_out(channel, ms) ⇒ nil
448 449 450 451 452 453 |
# File 'mixer.c', line 448
static VALUE Channels_s_fade_out(VALUE self, VALUE channel, VALUE ms)
{
check_channel(channel, 1);
Mix_FadeOutChannel(NUM2INT(channel), NUM2INT(ms));
return Qnil;
}
|
.fading(channel) ⇒ Integer
506 507 508 509 510 |
# File 'mixer.c', line 506
static VALUE Channels_s_fading(VALUE self, VALUE which)
{
check_channel(which, 0);
return INT2FIX(Mix_FadingChannel(NUM2INT(which)));
}
|
.halt(channel) ⇒ nil
409 410 411 412 413 414 |
# File 'mixer.c', line 409
static VALUE Channels_s_halt(VALUE self, VALUE channel)
{
check_channel(channel, 1);
Mix_HaltChannel(NUM2INT(channel));
return Qnil;
}
|
.pause(channel) ⇒ nil
373 374 375 376 377 378 |
# File 'mixer.c', line 373
static VALUE Channels_s_pause(VALUE self, VALUE channel)
{
check_channel(channel, 1);
Mix_Pause(NUM2INT(channel));
return Qnil;
}
|
.pause?(channel) ⇒ Boolean
481 482 483 484 485 |
# File 'mixer.c', line 481
static VALUE Channels_s_pause_p(VALUE self, VALUE channel)
{
check_channel(channel, 0);
return INT2BOOL(Mix_Paused(NUM2INT(channel)));
}
|
.play(channel, chunk, loops, ticks = -1) ⇒ Integer
309 310 311 312 313 314 315 316 317 318 319 320 321 322 |
# File 'mixer.c', line 309
static VALUE Channels_s_play(int argc, VALUE* argv, VALUE self)
{
VALUE channel, chunk, loops, ticks;
int ch;
rb_scan_args(argc, argv, "31", &channel, &chunk, &loops, &ticks);
if (ticks == Qnil)
ticks = INT2FIX(-1);
check_channel(channel, 1);
ch = Mix_PlayChannelTimed(NUM2INT(channel), Get_Mix_Chunk(chunk),
NUM2INT(loops), NUM2INT(ticks));
HANDLE_MIX_ERROR(ch);
protect_playing_chunk_from_gc(ch, chunk);
return INT2FIX(ch);
}
|
.play?(channel) ⇒ Boolean
463 464 465 466 467 |
# File 'mixer.c', line 463
static VALUE Channels_s_play_p(VALUE self, VALUE channel)
{
check_channel(channel, 0);
return INT2BOOL(Mix_Playing(NUM2INT(channel)));
}
|
.playing_chunk(channel) ⇒ SDL2::Mixer::Chunk?
522 523 524 525 526 |
# File 'mixer.c', line 522
static VALUE Channels_s_playing_chunk(VALUE self, VALUE channel)
{
check_channel(channel, 0);
return rb_ary_entry(playing_chunks, NUM2INT(channel));
}
|
.reserve(num) ⇒ Integer
243 244 245 246 |
# File 'mixer.c', line 243
static VALUE Channels_s_reserve(VALUE self, VALUE num)
{
return INT2NUM(Mix_ReserveChannels(NUM2INT(num)));
}
|
.resume(channel) ⇒ nil
391 392 393 394 395 396 |
# File 'mixer.c', line 391
static VALUE Channels_s_resume(VALUE self, VALUE channel)
{
check_channel(channel, 1);
Mix_Resume(NUM2INT(channel));
return Qnil;
}
|
.set_volume(channel, volume) ⇒ void
277 278 279 280 |
# File 'mixer.c', line 277
static VALUE Channels_s_set_volume(VALUE self, VALUE channel, VALUE volume)
{
return INT2NUM(Mix_Volume(NUM2INT(channel), NUM2INT(volume)));
}
|
.volume(channel) ⇒ Integer
259 260 261 262 |
# File 'mixer.c', line 259
static VALUE Channels_s_volume(VALUE self, VALUE channel)
{
return INT2NUM(Mix_Volume(NUM2INT(channel), -1));
}
|