Class: SDL2::Mixer::Channels::Group

Inherits:
Object
  • Object
show all
Defined in:
mixer.c,
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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tag) ⇒ Object

Initialize the channel with given tag.

Groups with a common tag are identified.



543
544
545
546
547
# File 'mixer.c', line 543

static VALUE Group_initialize(VALUE self, VALUE tag)
{
    rb_iv_set(self, "@tag", tag);
    return Qnil;
}

Instance Attribute Details

#tagInteger (readonly)

Returns tag id

Returns:

  • (Integer)

    tag id

Class Method Details

.defaultSDL2::Mixer::Channels::Group

Get the default channel group.

The default channel group refers all channels in the mixer system.



556
557
558
559
560
# File 'mixer.c', line 556

static VALUE Group_s_default(VALUE self)
{
    VALUE tag = INT2FIX(-1);
    return rb_class_new_instance(1, &tag, self);
}

Instance Method Details

#==(other) ⇒ Boolean

Return true if self and other are same.

self and other are considered to be same if they have the same tag.

Parameters:

  • other (SDL2::Mixer::Channel::Group)

    a compared object

Returns:

  • (Boolean)


582
583
584
585
586
# File 'mixer.c', line 582

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

Add a channel to the group.

Parameters:

  • which (Integer)

    a channel id

Returns:

  • (nil)


595
596
597
598
599
600
601
602
# File 'mixer.c', line 595

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;
}

#availableInteger

Return the first available channel in the group.

Return -1 if no channel is available.

Returns:

  • (Integer)


621
622
623
624
# File 'mixer.c', line 621

static VALUE Group_available(VALUE self)
{
    return INT2NUM(Mix_GroupAvailable(Group_tag(self)));
}

#countInteger

Get the number of channels belong to the group.

Returns:

  • (Integer)


609
610
611
612
# File 'mixer.c', line 609

static VALUE Group_count(VALUE self)
{
    return INT2NUM(Mix_GroupCount(Group_tag(self)));
}

#fade_out(ms) ⇒ Integer

Halt playing of all channels in the group with fade-out effect.

Parameters:

  • ms (Integer)

    milliseconds of fade-out effect

Returns:

  • (Integer)

    the number of channels affected by this method

See Also:



659
660
661
662
# File 'mixer.c', line 659

static VALUE Group_fade_out(VALUE self, VALUE ms)
{
    return INT2NUM(Mix_FadeOutGroup(Group_tag(self), NUM2INT(ms)));
}

#haltnil

Halt playing of all channels in the group.



671
672
673
674
675
# File 'mixer.c', line 671

static VALUE Group_halt(VALUE self)
{
    Mix_HaltGroup(Group_tag(self));
    return Qnil;
}

#newerInteger

Return the newer cahnnel in the group.

Return -1 if no channel is available.

Returns:

  • (Integer)


645
646
647
648
# File 'mixer.c', line 645

static VALUE Group_newer(VALUE self)
{
    return INT2NUM(Mix_GroupNewer(Group_tag(self)));
}

#oldestInteger

Return the oldest cahnnel in the group.

Return -1 if no channel is available.

Returns:

  • (Integer)


633
634
635
636
# File 'mixer.c', line 633

static VALUE Group_oldest(VALUE self)
{
    return INT2NUM(Mix_GroupOldest(Group_tag(self)));
}