Class MixingFloatAudioInputStream
java.lang.Object
java.io.InputStream
javax.sound.sampled.AudioInputStream
fr.paris.lutece.plugins.captcha.modules.jcaptcha.service.sound.MixingFloatAudioInputStream
- All Implemented Interfaces:
Closeable,AutoCloseable
Mixing of multiple AudioInputStreams to one AudioInputStream. This class takes a collection of AudioInputStreams and mixes them together. Being a subclass of
AudioInputStream itself, reading from instances of this class behaves as if the mixdown result of the input streams is read.
This class uses the FloatSampleBuffer for easy conversion using normalized samples in the buffers.
-
Constructor Summary
ConstructorsConstructorDescriptionMixingFloatAudioInputStream(AudioFormat audioFormat, AudioInputStream original, AudioInputStream background, float backgroundAttenuationFactor) -
Method Summary
Modifier and TypeMethodDescriptionintThe minimum of available() of all input stream is calculated and returned.voidclose()static floatdecibel2linear(float decibels) longThe maximum of the frame length of the input stream is calculated and returned.voidmark(int nReadLimit) Calls mark() on all input streams.booleanreturns true if all input stream return true for markSupported().intread()intread(byte[] abData, int nOffset, int nLength) voidreset()Calls reset() on all input streams.longskip(long lLength) calls skip() on all input streams.Methods inherited from class javax.sound.sampled.AudioInputStream
getFormat, readMethods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo
-
Constructor Details
-
MixingFloatAudioInputStream
public MixingFloatAudioInputStream(AudioFormat audioFormat, AudioInputStream original, AudioInputStream background, float backgroundAttenuationFactor) - Parameters:
audioFormat- the audio Formatoriginal- the originalbackground- the backgroundbackgroundAttenuationFactor- the backgroundAttenuationFactor
-
-
Method Details
-
getFrameLength
public long getFrameLength()The maximum of the frame length of the input stream is calculated and returned. If at least one of the input streams has lengthAudioInputStream.NOT_SPECIFIED, this value is returned.- Overrides:
getFrameLengthin classAudioInputStream- Returns:
- the frame length
-
read
- Overrides:
readin classAudioInputStream- Returns:
- the byte read
- Throws:
IOException- the IOException
-
read
- Overrides:
readin classAudioInputStream- Parameters:
abData- the DatanOffset- the OffsetnLength- the Length- Returns:
- the byte read
- Throws:
IOException- the IOException
-
skip
calls skip() on all input streams. There is no way to assure that the number of bytes really skipped is the same for all input streams. Due to that, this method always returns the passed value. In other words: the return value is useless (better ideas appreciated).- Overrides:
skipin classAudioInputStream- Parameters:
lLength- the length- Returns:
- the length
- Throws:
IOException- the IOException
-
available
The minimum of available() of all input stream is calculated and returned.- Overrides:
availablein classAudioInputStream- Returns:
- the available
- Throws:
IOException- the IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classAudioInputStream- Throws:
IOException- the IOException
-
mark
public void mark(int nReadLimit) Calls mark() on all input streams.- Overrides:
markin classAudioInputStream- Parameters:
nReadLimit- the read limit
-
reset
Calls reset() on all input streams.- Overrides:
resetin classAudioInputStream- Throws:
IOException- the IOException
-
markSupported
public boolean markSupported()returns true if all input stream return true for markSupported().- Overrides:
markSupportedin classAudioInputStream- Returns:
- false if mark supported
-
decibel2linear
public static float decibel2linear(float decibels) - Parameters:
decibels- the decibels- Returns:
- the decibel linear
-