Class: SDL2::Mixer::Music
- Inherits:
-
Object
- Object
- SDL2::Mixer::Music
- Defined in:
- mixer.c,
mixer.c
Overview
This class represents music, a kind of sound sources.
Music is playable on MusicChannel, not on Channels.
Class Method Summary (collapse)
-
+ (Array<String>) decoders
Get the names of music decoders.
-
+ (SDL2::Mixer::Music) load(path)
Load a music from file.
Instance Method Summary (collapse)
-
- (nil) destroy
Deallocate the music memory.
-
- (Boolean) destroy?
Return true if the memory is deallocated by #destroy.
-
- (String) inspect
Inspection string.
Class Method Details
+ (Array<String>) decoders
Get the names of music decoders.
906 907 908 909 910 911 912 913 914 |
# File 'mixer.c', line 906
static VALUE Music_s_decoders(VALUE self)
{
int num_decoders = Mix_GetNumMusicDecoders();
int i;
VALUE decoders = rb_ary_new2(num_decoders);
for (i=0; i<num_decoders; ++i)
rb_ary_push(decoders, utf8str_new_cstr(Mix_GetMusicDecoder(i)));
return decoders;
}
|
+ (SDL2::Mixer::Music) load(path)
925 926 927 928 929 930 931 932 933 |
# File 'mixer.c', line 925
static VALUE Music_s_load(VALUE self, VALUE fname)
{
Mix_Music* music = Mix_LoadMUS(StringValueCStr(fname));
VALUE mus;
if (!music) MIX_ERROR();
mus = Music_new(music);
rb_iv_set(mus, "@filename", fname);
return mus;
}
|
Instance Method Details
- (nil) destroy
Deallocate the music memory.
Normally, the memory is deallocated by ruby's GC, but you can surely deallocate the memory with this method at any time.
943 944 945 946 947 948 949 |
# File 'mixer.c', line 943
static VALUE Music_destroy(VALUE self)
{
Music* c = Get_Music(self);
if (c) Mix_FreeMusic(c->music);
c->music = NULL;
return Qnil;
}
|
- (Boolean) destroy?
Return true if the memory is deallocated by #destroy.
- (String) inspect
Returns inspection string
952 953 954 955 956 957 958 959 960 961 |
# File 'mixer.c', line 952
static VALUE Music_inspect(VALUE self)
{
VALUE filename = rb_iv_get(self, "@filename");
if (RTEST(Music_destroy_p(self)))
return rb_sprintf("<%s: destroyed>", rb_obj_classname(self));
return rb_sprintf("<%s: filename=\"%s\" type=%d>",
rb_obj_classname(self), StringValueCStr(filename),
Mix_GetMusicType(Get_Mix_Music(self)));
}
|