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:
java.io.Closeable,java.lang.AutoCloseable
public class MixingFloatAudioInputStream extends javax.sound.sampled.AudioInputStreamMixing 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
Constructors Constructor Description MixingFloatAudioInputStream(javax.sound.sampled.AudioFormat audioFormat, javax.sound.sampled.AudioInputStream original, javax.sound.sampled.AudioInputStream background, float backgroundAttenuationFactor)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intavailable()The minimum of available() of all input stream is calculated and returned.voidclose()static floatdecibel2linear(float decibels)longgetFrameLength()The maximum of the frame length of the input stream is calculated and returned.voidmark(int nReadLimit)Calls mark() on all input streams.booleanmarkSupported()returns 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.
-
-
-
Constructor Detail
-
MixingFloatAudioInputStream
public MixingFloatAudioInputStream(javax.sound.sampled.AudioFormat audioFormat, javax.sound.sampled.AudioInputStream original, javax.sound.sampled.AudioInputStream background, float backgroundAttenuationFactor)- Parameters:
audioFormat- the audio Formatoriginal- the originalbackground- the backgroundbackgroundAttenuationFactor- the backgroundAttenuationFactor
-
-
Method Detail
-
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 classjavax.sound.sampled.AudioInputStream- Returns:
- the frame length
-
read
public int read() throws java.io.IOException- Overrides:
readin classjavax.sound.sampled.AudioInputStream- Returns:
- the byte read
- Throws:
java.io.IOException- the IOException
-
read
public int read(byte[] abData, int nOffset, int nLength) throws java.io.IOException- Overrides:
readin classjavax.sound.sampled.AudioInputStream- Parameters:
abData- the DatanOffset- the OffsetnLength- the Length- Returns:
- the byte read
- Throws:
java.io.IOException- the IOException
-
skip
public long skip(long lLength) throws java.io.IOExceptioncalls 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 classjavax.sound.sampled.AudioInputStream- Parameters:
lLength- the length- Returns:
- the length
- Throws:
java.io.IOException- the IOException
-
available
public int available() throws java.io.IOExceptionThe minimum of available() of all input stream is calculated and returned.- Overrides:
availablein classjavax.sound.sampled.AudioInputStream- Returns:
- the available
- Throws:
java.io.IOException- the IOException
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjavax.sound.sampled.AudioInputStream- Throws:
java.io.IOException- the IOException
-
mark
public void mark(int nReadLimit)
Calls mark() on all input streams.- Overrides:
markin classjavax.sound.sampled.AudioInputStream- Parameters:
nReadLimit- the read limit
-
reset
public void reset() throws java.io.IOExceptionCalls reset() on all input streams.- Overrides:
resetin classjavax.sound.sampled.AudioInputStream- Throws:
java.io.IOException- the IOException
-
markSupported
public boolean markSupported()
returns true if all input stream return true for markSupported().- Overrides:
markSupportedin classjavax.sound.sampled.AudioInputStream- Returns:
- false if mark supported
-
decibel2linear
public static float decibel2linear(float decibels)
- Parameters:
decibels- the decibels- Returns:
- the decibel linear
-
-