|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object game.sound.CSoundPlayer
public class CSoundPlayer
Sound player. There should be only one CSoundPlayer by game. This is enforced by static methods and private constructors.
Field Summary | |
---|---|
static javax.sound.sampled.AudioFormat |
AUDIO_FORMAT
|
static int |
BITS_PER_SAMPLE
|
static int |
BYTES_PER_FRAME
|
static int |
BYTES_PER_SAMPLE
|
static javax.sound.sampled.DataLine.Info |
DATA_LINE_INFO
|
static boolean |
IS_BIG_ENDIAN
|
static boolean |
IS_SIGNED
|
private byte[] |
m_aCriticalSoundData
|
private byte[] |
m_aMissSoundData
|
private byte[] |
m_aMultipleHitSoundData
|
private byte[] |
m_aSingleHitSoundData
|
private javax.sound.sampled.SourceDataLine[] |
m_aSourceDataLines
|
private byte[] |
m_aStartSoundData
|
private javax.sound.sampled.Mixer |
m_mixer
|
private static CSoundPlayer |
m_soundPlayer
The only CSoundPlayer object. |
static int |
MAX_AMPLITUDE
|
static int |
NB_CHANNELS
|
static int |
NB_SIMULTANEOUS_SOUNDS
|
static float |
SAMPLE_RATE
|
Constructor Summary | |
---|---|
private |
CSoundPlayer()
Private constructor, forbids external instanciation. |
Method Summary | |
---|---|
static void |
clear()
Clears the SourceDataLines. |
private void |
closeSourceDataLines()
Cleanup function. |
private static byte[] |
generateModulation(float freq1,
float freq2,
float sLength)
Generates a sine modulation between two frequencies and store it in a byte array. |
private javax.sound.sampled.SourceDataLine |
getSourceDataLine()
Returns the first available SourceDataLine, or null if they are all busy. |
static void |
init()
Use this function to init java audio system, avoids lag at first sound played. |
static void |
playCriticalSound()
|
static void |
playMissSound()
|
static void |
playMultipleHitSound()
|
static void |
playSingleHitSound()
|
private void |
playSoundData(byte[] soundData)
Sound threads creation. |
static void |
playStartSound()
|
private static float |
sin(float f,
float t)
Usefull sine function. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final float SAMPLE_RATE
public static final int BITS_PER_SAMPLE
public static final int NB_CHANNELS
public static final int BYTES_PER_SAMPLE
public static final int BYTES_PER_FRAME
public static final int NB_SIMULTANEOUS_SOUNDS
public static final boolean IS_SIGNED
public static final boolean IS_BIG_ENDIAN
public static final javax.sound.sampled.AudioFormat AUDIO_FORMAT
public static final javax.sound.sampled.DataLine.Info DATA_LINE_INFO
public static final int MAX_AMPLITUDE
private static CSoundPlayer m_soundPlayer
private final byte[] m_aStartSoundData
private final byte[] m_aSingleHitSoundData
private final byte[] m_aMultipleHitSoundData
private final byte[] m_aMissSoundData
private final byte[] m_aCriticalSoundData
private javax.sound.sampled.SourceDataLine[] m_aSourceDataLines
private javax.sound.sampled.Mixer m_mixer
Constructor Detail |
---|
private CSoundPlayer()
Method Detail |
---|
public static void init()
private final javax.sound.sampled.SourceDataLine getSourceDataLine()
private final void closeSourceDataLines()
public static void clear()
private final void playSoundData(byte[] soundData)
soundData
- : the sound data to be played by the thread.public static final void playStartSound()
public static final void playSingleHitSound()
public static final void playMultipleHitSound()
public static final void playMissSound()
public static final void playCriticalSound()
private static final byte[] generateModulation(float freq1, float freq2, float sLength)
freq1
- freq2
- : frequencies in HzsLength
- : length of the sound in seconds
private static final float sin(float f, float t)
f
- : frequencyt
- : time
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |