Class SignalProcessor
java.lang.Object
games.stendhal.client.sound.system.SignalProcessor
- Direct Known Subclasses:
DirectedSound
,Interruptor
,MonoMixer
,OggVorbisDecoder
,PCMStreamConverter
,Recorder
,Recorder.Player
,ReSampler
,SoundFile
,SoundLayers.VolumeAdjustor
,SoundSystem.Output
,SoundSystemNG.Output
,ToneGenerator
,VolumeAdjustor
Every class that either wants to modify or generate a stream of
PCM audio data should derive from this class
Each SignalProcessor is a chain link in a doubly linked list, a processing chain. The first SignalProcessor in such a chain should always generate audio data otherwise no data will arrive at the quit of the chain
- Author:
- silvio
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
connectTo(SignalProcessor processor, boolean before)
static void
createChain(SignalProcessor... processors)
This function will create a processing chain by connecting any number of SignalProcessors togethervoid
Removes this SignalProcessor from the processing chain leaving adjacent SignalProcessors disconnectedprotected void
finished()
protected boolean
generate()
This function should be overwritten by all classes that want to generate an PCM audio stream e.g.void
insert(SignalProcessor processor, boolean before)
Connects this SignalProcessor to the next one (it is inserted in the processing chain before nextProcessor)protected void
modify(float[] data, int frames, int channels, int rate)
This function should be overwritten by all classes that want to modify an PCM audio stream.protected void
propagate(float[] data, int samples, int channels, int rate)
This function should be called from a derived class to propagate the modified audio data to the next SignalProcessor in the chainvoid
quit()
void
replace(SignalProcessor processor)
Replaces this SignalProcessor with "processor" in the processing chainboolean
request()
This will call the generate() method of the first SignalProcessor in the processing chainvoid
split(boolean before)
-
Constructor Details
-
SignalProcessor
public SignalProcessor()
-
-
Method Details
-
insert
Connects this SignalProcessor to the next one (it is inserted in the processing chain before nextProcessor)- Parameters:
processor
- nextProcessorbefore
- flag to insert processor before this object
-
connectTo
-
split
public final void split(boolean before) -
replace
Replaces this SignalProcessor with "processor" in the processing chain- Parameters:
processor
-
-
disconnect
public final void disconnect()Removes this SignalProcessor from the processing chain leaving adjacent SignalProcessors disconnected -
propagate
protected final void propagate(float[] data, int samples, int channels, int rate)This function should be called from a derived class to propagate the modified audio data to the next SignalProcessor in the chain- Parameters:
data
-samples
-channels
-rate
-
-
quit
public final void quit() -
request
public boolean request()This will call the generate() method of the first SignalProcessor in the processing chain- Returns:
true
, until the stream is finished
-
modify
protected void modify(float[] data, int frames, int channels, int rate)This function should be overwritten by all classes that want to modify an PCM audio stream. The audio data is uniform and interleaved. uniform: Each sample has a value between -1.0 and 1.0 interleaved: The channels are not separated. They are bundled in frames e.g. if there is stereo PCM data: data[0] and data[1] are the left and right channels of sample 0 data[2] and data[3] are the left and right channels of sample 1 data[4] and data[5] are the left and right channels of sample 2 and so on ... The number of samples can be calculated by: frames * channels- Parameters:
data
- the audio dataframes
- the number of sample frames contained in "data"channels
- number of channelsrate
- the sample rate
-
generate
protected boolean generate()This function should be overwritten by all classes that want to generate an PCM audio stream e.g. a mp3 decoder, a frequency generator, ...- Returns:
true
, until the stream is finished
-
finished
protected void finished() -
createChain
This function will create a processing chain by connecting any number of SignalProcessors together- Parameters:
processors
- any number of SignalProcessors to insert together
-