fr.paris.lutece.plugins.captcha.modules.jcaptcha.service.sound
Class MixingFloatAudioInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by javax.sound.sampled.AudioInputStream
          extended by fr.paris.lutece.plugins.captcha.modules.jcaptcha.service.sound.MixingFloatAudioInputStream
All Implemented Interfaces:
Closeable

public class MixingFloatAudioInputStream
extends AudioInputStream

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.


Field Summary
 
Fields inherited from class javax.sound.sampled.AudioInputStream
format, frameLength, framePos, frameSize
 
Constructor Summary
MixingFloatAudioInputStream(AudioFormat audioFormat, AudioInputStream original, AudioInputStream background, float backgroundAttenuationFactor)
           
 
Method Summary
 int available()
          The minimum of available() of all input stream is calculated and returned.
 void close()
           
static float decibel2linear(float decibels)
           
 long getFrameLength()
          The maximum of the frame length of the input stream is calculated and returned.
 void mark(int nReadLimit)
          Calls mark() on all input streams.
 boolean markSupported()
          returns true if all input stream return true for markSupported().
 int read()
           
 int read(byte[] abData, int nOffset, int nLength)
           
 void reset()
          Calls reset() on all input streams.
 long skip(long lLength)
          calls skip() on all input streams.
 
Methods inherited from class javax.sound.sampled.AudioInputStream
getFormat, read
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MixingFloatAudioInputStream

public MixingFloatAudioInputStream(AudioFormat audioFormat,
                                   AudioInputStream original,
                                   AudioInputStream background,
                                   float backgroundAttenuationFactor)
Parameters:
audioFormat - the audio Format
original - the original
background - the background
backgroundAttenuationFactor - 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 length AudioInputStream.NOT_SPECIFIED, this value is returned.

Overrides:
getFrameLength in class AudioInputStream
Returns:
the frame length

read

public int read()
         throws IOException
Overrides:
read in class AudioInputStream
Returns:
the byte read
Throws:
IOException - the IOException

read

public int read(byte[] abData,
                int nOffset,
                int nLength)
         throws IOException
Overrides:
read in class AudioInputStream
Parameters:
abData - the Data
nOffset - the Offset
nLength - the Length
Returns:
the byte read
Throws:
IOException - the IOException

skip

public long skip(long lLength)
          throws IOException
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:
skip in class AudioInputStream
Parameters:
lLength - the length
Returns:
the length
Throws:
IOException - the IOException

available

public int available()
              throws IOException
The minimum of available() of all input stream is calculated and returned.

Overrides:
available in class AudioInputStream
Returns:
the available
Throws:
IOException - the IOException

close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Overrides:
close in class AudioInputStream
Throws:
IOException - the IOException

mark

public void mark(int nReadLimit)
Calls mark() on all input streams.

Overrides:
mark in class AudioInputStream
Parameters:
nReadLimit - the read limit

reset

public void reset()
           throws IOException
Calls reset() on all input streams.

Overrides:
reset in class AudioInputStream
Throws:
IOException - the IOException

markSupported

public boolean markSupported()
returns true if all input stream return true for markSupported().

Overrides:
markSupported in class AudioInputStream
Returns:
false if mark supported

decibel2linear

public static float decibel2linear(float decibels)
Parameters:
decibels - the decibels
Returns:
the decibel linear


Copyright © 2014 Mairie de Paris. All Rights Reserved.