|
GTGE API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.golden.gamedev.engine.BaseAudio
public class BaseAudio
Audio manager that manages playing, stopping, looping of multiple audio
sounds (BaseAudioRenderer
s).
Audio manager takes up a single base renderer parameter. The base is used to
create new instance of BaseAudioRenderer
to play new audio
sound.
Audio manager also take care any idle renderer and looping audio renderer.
This class is using BaseIO
to get the external resources.
Field Summary | |
---|---|
static int |
MULTIPLE
Multiple audio clips can be played at the same time (simultaneous). |
static int |
SINGLE
Audio clip with a same name only can be played once at a time. |
static int |
SINGLE_REPLAY
Same as SINGLE policy except the audio clip is force to replay. |
Constructor Summary | |
---|---|
BaseAudio(BaseIO base,
BaseAudioRenderer baseRenderer)
Creates new audio manager with specified renderer as the base renderer of all audio sounds created by this audio manager. |
Method Summary | |
---|---|
protected BaseAudioRenderer |
createRenderer()
Constructs new audio renderer to play new audio sound. |
int |
getAudioPolicy()
Returns the default audio policy used by this audio manager to play audio sound when no audio policy is specified. |
BaseAudioRenderer |
getAudioRenderer(int slot)
Returns audio renderer in specified slot. |
BaseAudioRenderer |
getAudioRenderer(String audiofile)
Returns audio renderer with specified audio file or null if not found. |
BaseIO |
getBaseIO()
Returns BaseIO from where this audio manager is getting all
audio sound resources. |
BaseAudioRenderer |
getBaseRenderer()
Returns the base renderer of this audio manager. |
int |
getBuffer()
Returns total renderer allowed to create before audio manager attempt to replace idle renderer. |
int |
getCountRenderers()
Returns total audio renderer created within this audio manager. |
String |
getLastAudioFile()
Returns the last played audio file. |
int |
getMaxSimultaneous()
Returns maximum simultaneous same audio sound can be played at a time. |
BaseAudioRenderer[] |
getRenderers()
Returns all audio renderers (playing and idle renderer) associated with this audio manager. |
float |
getVolume()
Returns audio manager volume. |
boolean |
isActive()
Returns true, if this audio manager is fully functional. |
boolean |
isAvailable()
Returns whether this audio manager is available to use or not. |
boolean |
isExclusive()
Returns true, if only one clip is allowed to play at a time. |
boolean |
isLoop()
Returns true, if all the audio sounds are played continously. |
int |
play(String audiofile)
Plays audio clip with default policy . |
int |
play(String audiofile,
int policy)
Plays an audio clip based on specified policy ( SINGLE , MULTIPLE , SINGLE_REPLAY ). |
void |
run()
Thread implementation for managing audio renderers looping. |
void |
setActive(boolean b)
Turn on/off this audio manager. |
void |
setAudioPolicy(int i)
Sets the default audio policy used by this audio manager to play audio sound when no audio policy is specified. |
void |
setBaseIO(BaseIO base)
Sets BaseIO from where this audio manager is getting all
audio sound resources. |
void |
setBaseRenderer(BaseAudioRenderer renderer)
Sets specified audio renderer as this audio manager base renderer. |
void |
setBuffer(int i)
Sets total renderer allowed to create before audio manager attempt to replace idle renderer. |
void |
setExclusive(boolean exclusive)
Sets whether only one clip is allowed to play at a time or not. |
void |
setLoop(boolean loop)
Sets whether all the audio sounds should be played continously or not. |
void |
setMaxSimultaneous(int i)
Sets maximum simultaneous same audio sound can be played at a time. |
void |
setVolume(float volume)
Sets audio manager volume range in [0.0f - 1.0f]. |
void |
stop(int slot)
Stops audio playback in specified slot. |
void |
stop(String audiofile)
Stops audio playback with specified name. |
void |
stopAll()
Stops all played audio playbacks in this audio manager. |
void |
stopAll(BaseAudioRenderer except)
Stops all played audio playbacks in this audio manager except specified renderer. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int SINGLE
To force the clip to replay, set the audio policy to
SINGLE_REPLAY
instead.
setAudioPolicy(int)
,
play(String, int)
,
Constant Field Valuespublic static final int MULTIPLE
exclusive mode
(only
one audio clip can be played at a time), MULTIPLE
policy is obsolete, and automatically changed into SINGLE
.
setAudioPolicy(int)
,
play(String, int)
,
Constant Field Valuespublic static final int SINGLE_REPLAY
SINGLE
policy except the audio clip is force to replay.
setAudioPolicy(int)
,
play(String, int)
,
Constant Field ValuesConstructor Detail |
---|
public BaseAudio(BaseIO base, BaseAudioRenderer baseRenderer)
base
- the BaseIO to get audio resourcesbaseRenderer
- the base renderer of this audio managerMethod Detail |
---|
public void run()
run
in interface Runnable
public int play(String audiofile)
default policy
.
getAudioRenderer(int)
public int play(String audiofile, int policy)
SINGLE
, MULTIPLE
, SINGLE_REPLAY
).
getAudioRenderer(int)
public void stop(int slot)
public void stop(String audiofile)
public void stopAll()
public void stopAll(BaseAudioRenderer except)
getAudioRenderer(String)
,
getAudioRenderer(int)
public BaseAudioRenderer getAudioRenderer(int slot)
public BaseAudioRenderer getAudioRenderer(String audiofile)
public String getLastAudioFile()
This method is used for example when audio manager is set to active state
from inactive state, if the game wish to play the last played audio, call
play(getLastAudioFile())
.
play(String)
public BaseAudioRenderer[] getRenderers()
getCountRenderers()
public int getCountRenderers()
getRenderers()
public float getVolume()
setVolume(float)
public void setVolume(float volume)
If setting volume of base renderer is not supported, this method will return immediately.
getVolume()
public int getAudioPolicy()
play(String)
public void setAudioPolicy(int i)
i
- the default audio policy, one of SINGLE
,
MULTIPLE
, SINGLE_REPLAY
play(String)
public int getMaxSimultaneous()
public void setMaxSimultaneous(int i)
public boolean isExclusive()
setExclusive(boolean)
public void setExclusive(boolean exclusive)
exclusive
- true, only one clip is allowed to play at a timeisExclusive()
public int getBuffer()
setBuffer(int)
public void setBuffer(int i)
getBuffer()
public boolean isLoop()
setLoop(boolean)
public void setLoop(boolean loop)
isLoop()
public BaseIO getBaseIO()
BaseIO
from where this audio manager is getting all
audio sound resources.
setBaseIO(BaseIO)
public void setBaseIO(BaseIO base)
BaseIO
from where this audio manager is getting all
audio sound resources.
getBaseIO()
public boolean isActive()
setActive(boolean)
public void setActive(boolean b)
Note: unavailable audio manager can't be switch to on.
b
- true, turn on this audio managerisActive()
,
isAvailable()
public boolean isAvailable()
Unavailable audio manager is caused by
unavailable
base renderer
.
public BaseAudioRenderer getBaseRenderer()
setBaseRenderer(BaseAudioRenderer)
public void setBaseRenderer(BaseAudioRenderer renderer)
All renderers in this audio manager is created based on this base renderer.
getBaseRenderer()
protected BaseAudioRenderer createRenderer()
The new audio renderer is created using Class.forName(String)
from the base renderer class name.
getBaseRenderer()
|
GTGE API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |