Class: SDL2::Mixer::Channels::Group
- Inherits:
-
Object
- Object
- SDL2::Mixer::Channels::Group
- Defined in:
- ext/sdl2_ext/mixer.c,
ext/sdl2_ext/mixer.c
Overview
This class represents a channel group. A channel group is a set of channels and you can stop playing and fade out playing channels of an group at the same time.
Each channel group is identified by an integer called tag.
Instance Attribute Summary collapse
-
#tag ⇒ Integer
readonly
Tag id.
Class Method Summary collapse
-
.default ⇒ SDL2::Mixer::Channels::Group
Get the default channel group.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
Return true if *self* and *other* are same.
-
#add(which) ⇒ nil
Add a channel to the group.
-
#available ⇒ Integer
Return the first available channel in the group.
-
#count ⇒ Integer
Get the number of channels belong to the group.
-
#fade_out(ms) ⇒ Integer
Halt playing of all channels in the group with fade-out effect.
-
#halt ⇒ nil
Halt playing of all channels in the group.
-
#initialize(tag) ⇒ Object
constructor
Initialize the channel with given *tag*.
-
#newer ⇒ Integer
Return the newer cahnnel in the group.
-
#oldest ⇒ Integer
Return the oldest cahnnel in the group.
Constructor Details
#initialize(tag) ⇒ Object
Initialize the channel with given *tag*.
Groups with a common tag are identified.
542 543 544 545 546 |
# File 'ext/sdl2_ext/mixer.c', line 542
static VALUE Group_initialize(VALUE self, VALUE tag)
{
rb_iv_set(self, "@tag", tag);
return Qnil;
}
|
Instance Attribute Details
#tag ⇒ Integer (readonly)
Returns tag id.
Class Method Details
.default ⇒ SDL2::Mixer::Channels::Group
Get the default channel group.
The default channel group refers all channels in the mixer system.
555 556 557 558 559 |
# File 'ext/sdl2_ext/mixer.c', line 555
static VALUE Group_s_default(VALUE self)
{
VALUE tag = INT2FIX(-1);
return rb_class_new_instance(1, &tag, self);
}
|
Instance Method Details
#==(other) ⇒ Boolean
581 582 583 584 585 |
# File 'ext/sdl2_ext/mixer.c', line 581
static VALUE Group_eq(VALUE self, VALUE other)
{
return INT2BOOL(rb_obj_is_instance_of(other, cGroup) &&
Group_tag(self) == Group_tag(other));
}
|
#add(which) ⇒ nil
594 595 596 597 598 599 600 601 |
# File 'ext/sdl2_ext/mixer.c', line 594
static VALUE Group_add(VALUE self, VALUE which)
{
if (!Mix_GroupChannel(NUM2INT(which), Group_tag(self))) {
SDL_SetError("Cannot add channel %d", NUM2INT(which));
SDL_ERROR();
}
return Qnil;
}
|
#available ⇒ Integer
Return the first available channel in the group.
Return -1 if no channel is available.
620 621 622 623 |
# File 'ext/sdl2_ext/mixer.c', line 620
static VALUE Group_available(VALUE self)
{
return INT2NUM(Mix_GroupAvailable(Group_tag(self)));
}
|
#count ⇒ Integer
Get the number of channels belong to the group.
608 609 610 611 |
# File 'ext/sdl2_ext/mixer.c', line 608
static VALUE Group_count(VALUE self)
{
return INT2NUM(Mix_GroupCount(Group_tag(self)));
}
|
#fade_out(ms) ⇒ Integer
658 659 660 661 |
# File 'ext/sdl2_ext/mixer.c', line 658
static VALUE Group_fade_out(VALUE self, VALUE ms)
{
return INT2NUM(Mix_FadeOutGroup(Group_tag(self), NUM2INT(ms)));
}
|
#halt ⇒ nil
Halt playing of all channels in the group.
670 671 672 673 674 |
# File 'ext/sdl2_ext/mixer.c', line 670
static VALUE Group_halt(VALUE self)
{
Mix_HaltGroup(Group_tag(self));
return Qnil;
}
|
#newer ⇒ Integer
Return the newer cahnnel in the group.
Return -1 if no channel is available.
644 645 646 647 |
# File 'ext/sdl2_ext/mixer.c', line 644
static VALUE Group_newer(VALUE self)
{
return INT2NUM(Mix_GroupNewer(Group_tag(self)));
}
|
#oldest ⇒ Integer
Return the oldest cahnnel in the group.
Return -1 if no channel is available.
632 633 634 635 |
# File 'ext/sdl2_ext/mixer.c', line 632
static VALUE Group_oldest(VALUE self)
{
return INT2NUM(Mix_GroupOldest(Group_tag(self)));
}
|