GF4J 0.9.4 Beta

gameframe.engines.jdk12x
Class CSoundEngine.CJava2Sample

java.lang.Object
  |
  +--gameframe.engines.jdk12x.CSoundEngine.CJava2Sample
All Implemented Interfaces:
Sample, Sound
Enclosing class:
CSoundEngine

class CSoundEngine.CJava2Sample
extends java.lang.Object
implements Sample

Implementation of Sound that implements a Java 2 sound clip.


Field Summary
private  java.applet.AudioClip m_audioClip
           
private  java.net.URL m_fileLocation
           
private  boolean m_fPlaying
           
private  float m_pan
           
private  float m_volume
           
 
Constructor Summary
(package private) CSoundEngine.CJava2Sample(java.applet.AudioClip audioClip, java.net.URL fileLocation)
          Constructs a new Java 2 sound clip from the given parameters.
 
Method Summary
 void finalize()
          Upon finalization stop everything (just in case) and remove this sound clip from the list of created sound clips.
 Sample getCopy()
          Returns a copy of this sound object that is independent from the original sound object.
 float getPan()
          Returns the pan of the sound.
 float getVolume()
          Returns the volume of the sound.
 boolean isPlaying()
          Returns true if sound should be playing at the moment
 void playLooped()
          Plays the given sample over and over again (looping).
 void playOnce()
          Plays this sample once and then stops
 void setPan(float pan)
          Sets the pan of the sound.
 void setVolume(float volume)
          Sets the volume of the sound.
 void stop()
          Stops playing the given sample
 
Methods inherited from class java.lang.Object
, clone, equals, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

m_audioClip

private java.applet.AudioClip m_audioClip

m_fileLocation

private java.net.URL m_fileLocation

m_fPlaying

private boolean m_fPlaying

m_pan

private float m_pan

m_volume

private float m_volume
Constructor Detail

CSoundEngine.CJava2Sample

CSoundEngine.CJava2Sample(java.applet.AudioClip audioClip,
                          java.net.URL fileLocation)
Constructs a new Java 2 sound clip from the given parameters.
Parameters:
audioClip - The audio clip object used to play the sounds.
fileLocation - The audio clip file location URL.
Method Detail

playOnce

public void playOnce()
Plays this sample once and then stops
Specified by:
playOnce in interface Sound

playLooped

public void playLooped()
Plays the given sample over and over again (looping).
Specified by:
playLooped in interface Sound

stop

public void stop()
Stops playing the given sample
Specified by:
stop in interface Sound

getCopy

public Sample getCopy()
Returns a copy of this sound object that is independent from the original sound object. This new sound object can be started/stopped independently from the original sound object. Using this method to get multiple instances of one sound will save memory on some implementations and is thus preferred way to duplicate sound objects.
Specified by:
getCopy in interface Sample
Returns:
A independent copy of this sound or null if copy fails.

finalize

public void finalize()
Upon finalization stop everything (just in case) and remove this sound clip from the list of created sound clips.
Specified by:
finalize in interface Sound
Overrides:
finalize in class java.lang.Object

isPlaying

public boolean isPlaying()
Returns true if sound should be playing at the moment
Specified by:
isPlaying in interface Sound

setVolume

public void setVolume(float volume)
Sets the volume of the sound. Value of 0.0 means that the sound should be inaudible and value of 1.0 means the sound is played at its normal volume. Values above 1.0 are treated as 1.0.
Specified by:
setVolume in interface Sample
Parameters:
volume - The sounds volume.

setPan

public void setPan(float pan)
Sets the pan of the sound. Value of -1.0 means that the sound will be heard only from the left speaker and value of 1.0 means that the sound will be heard only from the right speaker. Value of 0.0 means that the sound is heard with equal volume from both speakers.
Specified by:
setPan in interface Sample
Parameters:
pan - The pan of the sound.

getVolume

public float getVolume()
Returns the volume of the sound. Value of 0.0 means that the sound should be inaudible and value of 1.0 means the sound is played at its normal volume.
Specified by:
getVolume in interface Sample
Returns:
The sounds volume.

getPan

public float getPan()
Returns the pan of the sound. Value of -1.0 means that the sound will be heard only from the left speaker and value of 1.0 means that the sound will be heard only from the right speaker. Value of 0.0 means that the sound is heard with equal volume from both speakers.
Specified by:
getPan in interface Sample
Returns:
The pan of the sound.

GF4J 0.9.4 Beta