at.tuwien.ifs.feature.extraction.audio.input
Class AudioFileSegmentReader

java.lang.Object
  extended by at.tuwien.ifs.feature.extraction.audio.input.AudioFileSegmentReader

public class AudioFileSegmentReader
extends java.lang.Object

Copyright Vienna University of Technology

Version:
$Id: AudioFileSegmentReader.java 173 2010-06-17 16:28:05Z mayer $
Author:
Thomas Lidy, Jakob Frank

Field Summary
private  javax.sound.sampled.AudioFileFormat audioFileFormat
           
private  javax.sound.sampled.AudioFormat audioFormat
           
private  javax.sound.sampled.AudioInputStream audioInputStream
           
private  long durationMicrosec
           
private  java.io.InputStream inStream
           
private  boolean isMpeg
           
private  long lengthInFrames
           
private  javax.sound.sampled.AudioInputStream mpegInputStream
           
private  int nChannels
           
private  boolean open
           
private  int sampleRate
           
private  int sampleSizeInBits
           
private  long streamLength
           
 
Constructor Summary
AudioFileSegmentReader(javax.sound.sampled.AudioInputStream inStream)
           
AudioFileSegmentReader(java.io.File file)
           
 
Method Summary
 void closeStream()
           
private static byte[] convertFileToByteArray(java.io.File f)
           
 int getDurationInSeconds()
           
 long getNumberOfSamples()
           
 int getSampleRate()
           
 int getSampleSizeInBits()
           
 void openStream()
           
 int read(byte[] outputArray)
           
 int read(short[] outputArray)
           
 int readMono(short[] outputArray)
           
private  void readMpegProperties()
           
 void resetStream()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

inStream

private java.io.InputStream inStream

audioInputStream

private javax.sound.sampled.AudioInputStream audioInputStream

mpegInputStream

private javax.sound.sampled.AudioInputStream mpegInputStream

audioFileFormat

private javax.sound.sampled.AudioFileFormat audioFileFormat

audioFormat

private javax.sound.sampled.AudioFormat audioFormat

open

private boolean open

isMpeg

private boolean isMpeg

sampleRate

private int sampleRate

sampleSizeInBits

private int sampleSizeInBits

nChannels

private int nChannels

lengthInFrames

private long lengthInFrames

durationMicrosec

private long durationMicrosec

streamLength

private long streamLength
Constructor Detail

AudioFileSegmentReader

public AudioFileSegmentReader(java.io.File file)
                       throws javax.sound.sampled.UnsupportedAudioFileException,
                              java.io.IOException
Throws:
javax.sound.sampled.UnsupportedAudioFileException
java.io.IOException

AudioFileSegmentReader

public AudioFileSegmentReader(javax.sound.sampled.AudioInputStream inStream)
                       throws javax.sound.sampled.UnsupportedAudioFileException,
                              java.io.IOException
Throws:
javax.sound.sampled.UnsupportedAudioFileException
java.io.IOException
Method Detail

convertFileToByteArray

private static byte[] convertFileToByteArray(java.io.File f)
                                      throws java.io.IOException
Throws:
java.io.IOException

getSampleRate

public int getSampleRate()

getSampleSizeInBits

public int getSampleSizeInBits()

getNumberOfSamples

public long getNumberOfSamples()

getDurationInSeconds

public int getDurationInSeconds()

readMpegProperties

private void readMpegProperties()

openStream

public void openStream()
                throws javax.sound.sampled.UnsupportedAudioFileException,
                       java.io.IOException
Throws:
javax.sound.sampled.UnsupportedAudioFileException
java.io.IOException

resetStream

public void resetStream()
                 throws java.io.IOException
Throws:
java.io.IOException

closeStream

public void closeStream()
                 throws java.io.IOException
Throws:
java.io.IOException

readMono

public int readMono(short[] outputArray)
             throws java.io.IOException
Throws:
java.io.IOException

read

public int read(short[] outputArray)
         throws java.io.IOException
Throws:
java.io.IOException

read

public int read(byte[] outputArray)
         throws java.io.IOException
Parameters:
outputArray - array into which input is read (# of bytes to read equals size of array)
Returns:
number of bytes actually read (can be smaller at the end of file, or -1 in case of errors)
Throws:
java.io.IOException