Star Ruby Ruby extension library for creating 2D games

StarRuby::Audio

This module manages sound.

BGM and Sound Effect

There are two types of sound in Star Ruby

FeatureBGMSound Effect
Maximum number of sounds playable simultaneously18
Streaming×
Play from the middle×
Loop×
Panning×

File types Star Ruby supports are as below.

Constants

MAX_SE_COUNT
The maximum number of SEs which can be played.

Module Methods

Audio.bgm_position

Get playing position of BGM as an integer

Audio.bgm_volume
Audio.bgm_volume=(volume)

Set/Get integer value(0 - 255) of volume.

Audio.play_bgm(path, options = {})

Play file of chosen path as a BGM. Extension can be omitted.

You have to pass Hash as options. Keys and values below can be selected.

KeyValueDefault
:loopLoop BGM or notfalse
:positionSeek position of playing sound. Uses the value from Audio.bgm_position.0
:volumeVolume (0 〜 255)。255
:timeFadein time (millisec)。0

Playing from the middle of BGM can cause two seconds error maximum.

Audio.play_se(path, options = {})

Play file of chosen path as a sound effect. Extension can be omitted.

You have to pass Hash as options. Keys and values below can be selected.

KeyValueDefault
:panningPanning (-255 - 255).0
:volumeVolume (0 - 255).255
:timeFadein time(millisec).0

(before Ver 0.1.0 , range of :panning isは 0 - 255.)

Audio.playing_bgm?

If the BGM is playing return true otherwise return false.

Audio.stop_all_ses(options = {})

Stop all playing sound effecs.

You have to pass Hash as options. Keys and values below can be selected.

KeyValueDefault
:timeFadeout time(millsec).0
Audio.playing_se_count

Returns a number of SEs which are played.

Audio.stop_bgm(options = {})

Stop BGM

You have to pass Hash as options. Keys and values below can be selected.

KeyValueDefault
:timefade out (millisec).0
© Copyright 2012 Hajime Hoshi