|
PulpCore | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectpulpcore.sound.Sound
public abstract class Sound
The Sound class is a base class for sampled sound.
SoundSequence| Constructor Summary | |
|---|---|
Sound(int sampleRate)
Creates a new Sound with the specified sample rate. |
|
| Method Summary | |
|---|---|
long |
getDuration()
Gets the duration of this clip in milliseconds. |
abstract int |
getNumFrames()
Gets the length of this sound, expressed in the number of frames. |
int |
getSampleRate()
Returns the sample rate - the number of samples played per second, per channel. |
abstract void |
getSamples(byte[] dest,
int destOffset,
int destChannels,
int srcFrame,
int numFrames)
Copies a sequence of samples from this Sound to a byte array as signed, little endian, 16-bit PCM format. |
int |
getSampleSize()
Returns the sample size - the number of bytes in each sample. |
static Sound |
load(byte[] data,
int sampleRate,
boolean stereo)
Creates an sound clip with the specified samples (signed, little endian, 16-bit PCM format). |
static Sound |
load(String soundAsset)
Loads a sound from the the asset catalog. |
Playback |
loop()
Loops this sound clip. |
Playback |
loop(Fixed level)
Loops this sound clip with the specified volume level (0.0 to 1.0). |
Playback |
loop(Fixed level,
Fixed pan)
Loops this sound clip with the specified volume level (0.0 to 1.0) and pan (-1.0 to 1.0). |
Playback |
play()
Plays this sound clip. |
Playback |
play(Fixed level)
Plays this sound clip with the specified colume level (0.0 to 1.0). |
Playback |
play(Fixed level,
Fixed pan)
Plays this sound clip with the specified level (0.0 to 1.0) and pan (-1.0 to 1.0). |
Playback |
play(Fixed level,
Fixed pan,
boolean loop)
Plays this sound clip with the specified level (0.0 to 1.0) and pan (-1.0 to 1.0), optionally looping. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Sound(int sampleRate)
sampleRate - the sample rate (samples per second, per channel).| Method Detail |
|---|
public final int getSampleRate()
public final int getSampleSize()
public final long getDuration()
public abstract int getNumFrames()
public abstract void getSamples(byte[] dest,
int destOffset,
int destChannels,
int srcFrame,
int numFrames)
dest - the destination buffer.destOffset - the offset, in bytes, in the destination buffer.destChannels - The number of channels of the destination (1 or 2).srcFrame - the frame position to start copying from.numFrames - the number of frames to copy.public final Playback play()
null if the sound could not be played.SoundEvent,
CoreSystem.setMute(boolean),
CoreSystem.isMute()public final Playback play(Fixed level)
null if the sound could not be played.SoundEvent,
CoreSystem.setMute(boolean),
CoreSystem.isMute()
public final Playback play(Fixed level,
Fixed pan)
null if the sound could not be played.SoundEvent,
CoreSystem.setMute(boolean),
CoreSystem.isMute()
public Playback play(Fixed level,
Fixed pan,
boolean loop)
null if the sound could not be played.SoundEvent,
CoreSystem.setMute(boolean),
CoreSystem.isMute()public final Playback loop()
null if the sound could not be played.SoundEvent,
CoreSystem.setMute(boolean),
CoreSystem.isMute()public final Playback loop(Fixed level)
null if the sound could not be played.SoundEvent,
CoreSystem.setMute(boolean),
CoreSystem.isMute()
public final Playback loop(Fixed level,
Fixed pan)
null if the sound could not be played.SoundEvent,
CoreSystem.setMute(boolean),
CoreSystem.isMute()
public static Sound load(byte[] data,
int sampleRate,
boolean stereo)
public static Sound load(String soundAsset)
Ogg Vorbis is supported with an add-on. See http://code.google.com/p/pulpcore/wiki/OggHowTo for details.
This method never returns null. If the sound cannot be loaded, or there is no
sound engine available, a zero-length Sound is returned.
Sounds are internally cached (using a WeakReference), and if the sound was previously loaded, this method may return the same reference.
soundAsset - The name of a AU, WAV, or OGG sound file.
|
PulpCore | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||