Top Description Fields Constructors Methods
org.lwjgl.examples.spaceinvaders

public Class SoundManager

extends Object
Class Inheritance
Imports
java.nio.IntBuffer, org.lwjgl.BufferUtils, .LWJGLException, org.lwjgl.openal.AL, .AL10, org.lwjgl.util.WaveData

Simple sound manager for OpenAL using n sources accessed in a round robin schedule. Source n is reserved for a single buffer and checking for whether it's playing.

Author
Brian Matzon
Version
$Revision$ $Id$

Field Summary

Modifier and TypeField and Description
private int
bufferIndex

Current index in our buffers

private int[]
buffers

We support at most 256 buffers

private IntBuffer
scratchBuffer

Our internal scratch buffer

private boolean
soundOutput

Whether we're running in no sound mode

private int
sourceIndex

Current index in our source list

private int[]
sources

Number of sources is limited tby user (and hardware)

Constructor Summary

AccessConstructor and Description
public
SoundManager()

Creates a new SoundManager

Method Summary

Modifier and TypeMethod and Description
public int

Returns:

index into SoundManagers buffer list
addSound
(String
Path to file to load
path
)

Adds a sound to the Sound Managers pool

public void
destroy()

Destroy this SoundManager

public void
initialize(int
Number of channels to create
channels
)

Initializes the SoundManager

public boolean

Returns:

true if a source is playing right now on source n
isPlayingSound
()

Whether a sound is playing on last source

public void
playEffect(int
Buffer index to play gotten from addSound
buffer
)

Plays a sound effect

public void
playSound(int
Buffer index to play gotten from addSound
buffer
)

Plays a sound on last source

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

bufferIndexback to summary
private int bufferIndex

Current index in our buffers

buffersback to summary
private int[] buffers

We support at most 256 buffers

scratchBufferback to summary
private IntBuffer scratchBuffer

Our internal scratch buffer

soundOutputback to summary
private boolean soundOutput

Whether we're running in no sound mode

sourceIndexback to summary
private int sourceIndex

Current index in our source list

sourcesback to summary
private int[] sources

Number of sources is limited tby user (and hardware)

Constructor Detail

SoundManagerback to summary
public SoundManager()

Creates a new SoundManager

Method Detail

addSoundback to summary
public int addSound(String path)

Adds a sound to the Sound Managers pool

Parameters
path:String

Path to file to load

Returns:int

index into SoundManagers buffer list

destroyback to summary
public void destroy()

Destroy this SoundManager

initializeback to summary
public void initialize(int channels)

Initializes the SoundManager

Parameters
channels:int

Number of channels to create

isPlayingSoundback to summary
public boolean isPlayingSound()

Whether a sound is playing on last source

Returns:boolean

true if a source is playing right now on source n

playEffectback to summary
public void playEffect(int buffer)

Plays a sound effect

Parameters
buffer:int

Buffer index to play gotten from addSound

playSoundback to summary
public void playSound(int buffer)

Plays a sound on last source

Parameters
buffer:int

Buffer index to play gotten from addSound