Class JVMAudioInputStream

java.lang.Object
be.tarsos.dsp.io.jvm.JVMAudioInputStream
All Implemented Interfaces:
TarsosDSPAudioInputStream

public class JVMAudioInputStream
extends java.lang.Object
implements TarsosDSPAudioInputStream
Encapsulates an AudioInputStream to make it work with the core TarsosDSP library.
Author:
Joren Six
  • Constructor Summary

    Constructors 
    Constructor Description
    JVMAudioInputStream​(javax.sound.sampled.AudioInputStream stream)  
  • Method Summary

    Modifier and Type Method Description
    void close()
    Closes this audio input stream and releases any system resources associated with the stream.
    TarsosDSPAudioFormat getFormat()  
    long getFrameLength()  
    int read​(byte[] b, int off, int len)
    Reads up to a specified maximum number of bytes of data from the audio stream, putting them into the given byte array.
    long skip​(long bytesToSkip)
    Skip a number of bytes before reading the remaining bytes.
    static javax.sound.sampled.AudioFormat toAudioFormat​(TarsosDSPAudioFormat format)
    Converts a TarsosDSPAudioFormat to a AudioFormat.
    static TarsosDSPAudioFormat toTarsosDSPFormat​(javax.sound.sampled.AudioFormat format)
    Converts a AudioFormat to a TarsosDSPAudioFormat.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • JVMAudioInputStream

      public JVMAudioInputStream​(javax.sound.sampled.AudioInputStream stream)
  • Method Details

    • skip

      public long skip​(long bytesToSkip) throws java.io.IOException
      Description copied from interface: TarsosDSPAudioInputStream
      Skip a number of bytes before reading the remaining bytes.
      Specified by:
      skip in interface TarsosDSPAudioInputStream
      Parameters:
      bytesToSkip - The number of bytes to skip.
      Returns:
      The number of bytes skipped.
      Throws:
      java.io.IOException - If the underlying if an input or output error occurs #see read
    • read

      public int read​(byte[] b, int off, int len) throws java.io.IOException
      Description copied from interface: TarsosDSPAudioInputStream
      Reads up to a specified maximum number of bytes of data from the audio stream, putting them into the given byte array.

      This method will always read an integral number of frames. If len does not specify an integral number of frames, a maximum of len - (len % frameSize) bytes will be read.

      Specified by:
      read in interface TarsosDSPAudioInputStream
      Parameters:
      b - the buffer into which the data is read
      off - the offset, from the beginning of array b, at which the data will be written
      len - the maximum number of bytes to read
      Returns:
      the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached
      Throws:
      java.io.IOException - if an input or output error occurs
      See Also:
      TarsosDSPAudioInputStream.skip(long)
    • close

      public void close() throws java.io.IOException
      Description copied from interface: TarsosDSPAudioInputStream
      Closes this audio input stream and releases any system resources associated with the stream.
      Specified by:
      close in interface TarsosDSPAudioInputStream
      Throws:
      java.io.IOException - if an input or output error occurs
    • getFrameLength

      public long getFrameLength()
      Specified by:
      getFrameLength in interface TarsosDSPAudioInputStream
    • getFormat

      public TarsosDSPAudioFormat getFormat()
      Specified by:
      getFormat in interface TarsosDSPAudioInputStream
      Returns:
      The format of the underlying audio
    • toTarsosDSPFormat

      public static TarsosDSPAudioFormat toTarsosDSPFormat​(javax.sound.sampled.AudioFormat format)
      Converts a AudioFormat to a TarsosDSPAudioFormat.
      Parameters:
      format - The AudioFormat
      Returns:
      A TarsosDSPAudioFormat
    • toAudioFormat

      public static javax.sound.sampled.AudioFormat toAudioFormat​(TarsosDSPAudioFormat format)
      Converts a TarsosDSPAudioFormat to a AudioFormat.
      Parameters:
      format - The TarsosDSPAudioFormat
      Returns:
      A AudioFormat