public class SoundSample extends Object implements Disposable
setPitch(float) and setVolume(float)).
Note that SoundSample differs from MusicPlayer
in the sense that a sample is completely loaded into memory before
playing. Thus, it makes sense to play short samples but not complete
songs (for background music for instance).| Modifier and Type | Field and Description |
|---|---|
protected float |
pitch |
protected Sound |
s |
protected float |
volume |
| Constructor and Description |
|---|
SoundSample(String file)
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
void |
dispose()
Release resources when done working with them
|
protected void |
finalize() |
long |
loop()
|
void |
modifyPitch(float newPitch,
long id)
Changes the pitch of a currently playing sound, specified by its
id (which is returned by the
play() method). |
void |
mofidyPlayingVolument(float newVolume,
long id)
Changes the volume of a currently playing sound, specified by its
id (which is returned by the
play() method). |
long |
play()
|
void |
setPitch(float p)
Changes the speed (pitch) at which the sound is played.
|
void |
setVolume(float v)
Changes volume of the song played
|
void |
stop()
Stops playing the sample
|
protected Sound s
protected float volume
protected float pitch
public SoundSample(String file)
file - the file to be loaded, using internal path representationpublic void setVolume(float v)
v - Should be between 0 and 1public void setPitch(float p)
p - Speed (pitch) of the soundpublic void modifyPitch(float newPitch,
long id)
play() method). If the sound
is no longer playing, nothing happensnewPitch - See setPitch(float)id - See play()public void mofidyPlayingVolument(float newVolume,
long id)
play() method). If the sound
is no longer playing, nothing happensnewVolume - See setVolume(float)id - See play()public long play()
pitch and volume. If it is already playing, another
sample will start, concurrently.public void stop()
public long loop()
public void dispose()
dispose in interface DisposableCopyright © 2014-2016 gdx2d - https://github.com/hevs-isi/gdx2d