Crossfire JXClient, Trunk
Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
com.realtime.crossfire.jxclient.sound.Processor Class Reference
Inheritance diagram for com.realtime.crossfire.jxclient.sound.Processor:
Inheritance graph
Collaboration diagram for com.realtime.crossfire.jxclient.sound.Processor:
Collaboration graph

Public Member Functions

 Processor (@NotNull final CharSequence name, @NotNull final AudioFileLoader audioFileLoader)
 
void run ()
 
void terminate (final boolean fadeOut)
 

Private Member Functions

void convertSample (final byte @NotNull[] buf, final int i)
 
AudioInputStream openAudioInputStream () throws IOException, UnsupportedAudioFileException
 

Private Attributes

final AudioFileLoader audioFileLoader
 
final CharSequence name
 
int state
 
float volume = MIN_VALUE
 

Static Private Attributes

static final float MAX_VOLUME = 0.2F
 
static final float MIN_VALUE = 1.0E-3F
 
static final float VOLUME_STEP_PER_SAMPLE = 1.00005F
 

Detailed Description

A thread that plays a music file over and over until terminated.

Author
Andreas Kirschbaum

Definition at line 39 of file Processor.java.

Constructor & Destructor Documentation

◆ Processor()

com.realtime.crossfire.jxclient.sound.Processor.Processor ( @NotNull final CharSequence  name,
@NotNull final AudioFileLoader  audioFileLoader 
)

Creates a new instance.

Parameters
namethe music name to play
audioFileLoaderthe audio file loader for loading audio files

Definition at line 86 of file Processor.java.

References com.realtime.crossfire.jxclient.sound.Processor.audioFileLoader, and com.realtime.crossfire.jxclient.sound.Processor.name.

Member Function Documentation

◆ convertSample()

void com.realtime.crossfire.jxclient.sound.Processor.convertSample ( final byte @NotNull[]  buf,
final int  i 
)
private

Converts one audio sample according to the current volume.

Parameters
bufthe buffer holding the sample
ithe sample offset

Definition at line 202 of file Processor.java.

References com.realtime.crossfire.jxclient.sound.Processor.MAX_VOLUME, and com.realtime.crossfire.jxclient.sound.Processor.volume.

Referenced by com.realtime.crossfire.jxclient.sound.Processor.run().

Here is the caller graph for this function:

◆ openAudioInputStream()

AudioInputStream com.realtime.crossfire.jxclient.sound.Processor.openAudioInputStream ( ) throws IOException, UnsupportedAudioFileException
private

Opens and returns an audio stream for name.

Returns
the audio stream
Exceptions
IOExceptionif the file cannot be opened
UnsupportedAudioFileExceptionif the file cannot be decoded

Definition at line 221 of file Processor.java.

References com.realtime.crossfire.jxclient.sound.Processor.audioFileLoader, com.realtime.crossfire.jxclient.sound.AudioFileLoader.getInputStream(), and com.realtime.crossfire.jxclient.sound.Processor.name.

Referenced by com.realtime.crossfire.jxclient.sound.Processor.run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ run()

void com.realtime.crossfire.jxclient.sound.Processor.run ( )

◆ terminate()

void com.realtime.crossfire.jxclient.sound.Processor.terminate ( final boolean  fadeOut)

Stops playing music. The music is faded out rather than cut off.

Parameters
fadeOutWhether tp fade out the music (
true
) or to cut it off (
false
).

Definition at line 96 of file Processor.java.

References com.realtime.crossfire.jxclient.sound.Processor.state.

Referenced by com.realtime.crossfire.jxclient.sound.MusicManager.restart(), and com.realtime.crossfire.jxclient.sound.MusicManager.shutdown().

Here is the caller graph for this function:

Member Data Documentation

◆ audioFileLoader

final AudioFileLoader com.realtime.crossfire.jxclient.sound.Processor.audioFileLoader
private

◆ MAX_VOLUME

final float com.realtime.crossfire.jxclient.sound.Processor.MAX_VOLUME = 0.2F
staticprivate

The maximum volume.

Definition at line 49 of file Processor.java.

Referenced by com.realtime.crossfire.jxclient.sound.Processor.convertSample().

◆ MIN_VALUE

final float com.realtime.crossfire.jxclient.sound.Processor.MIN_VALUE = 1.0E-3F
staticprivate

The minimum factor for fading in/out effects.

Definition at line 44 of file Processor.java.

Referenced by com.realtime.crossfire.jxclient.sound.Processor.run().

◆ name

final CharSequence com.realtime.crossfire.jxclient.sound.Processor.name
private

◆ state

int com.realtime.crossfire.jxclient.sound.Processor.state
private

The current state: 0=fade in, 1=playing, 2=fade out, 3=terminate, 4=terminate immediately.

Definition at line 73 of file Processor.java.

Referenced by com.realtime.crossfire.jxclient.sound.Processor.run(), and com.realtime.crossfire.jxclient.sound.Processor.terminate().

◆ volume

float com.realtime.crossfire.jxclient.sound.Processor.volume = MIN_VALUE
private

The current volume. It is a factor that is multiplied to all sample values while fading in/out.

Definition at line 79 of file Processor.java.

Referenced by com.realtime.crossfire.jxclient.sound.Processor.convertSample(), and com.realtime.crossfire.jxclient.sound.Processor.run().

◆ VOLUME_STEP_PER_SAMPLE

final float com.realtime.crossfire.jxclient.sound.Processor.VOLUME_STEP_PER_SAMPLE = 1.00005F
staticprivate

The step for the fading in/out factor. It is multiplied to the current value for each sample.

Definition at line 55 of file Processor.java.

Referenced by com.realtime.crossfire.jxclient.sound.Processor.run().


The documentation for this class was generated from the following file: