com.frinika.audio.io
Class AudioReader

java.lang.Object
  extended by com.frinika.audio.io.AudioWavReader
      extended by com.frinika.audio.io.AudioReader
All Implemented Interfaces:
BlockableAudioProcess, LimitedAudioReader, uk.org.toot.audio.core.AudioProcess
Direct Known Subclasses:
EnvelopedAudioReader

public class AudioReader
extends AudioWavReader
implements BlockableAudioProcess, uk.org.toot.audio.core.AudioProcess, LimitedAudioReader


Field Summary
protected  long endByte
           
protected  long fPtrBytes
           
protected  long startByte
           
 
Fields inherited from class com.frinika.audio.io.AudioWavReader
audioDataByteLength, audioDataStartBytePtr, bytecount, format, lengthInFrames, nChannels, riffdata, sp
 
Fields inherited from interface uk.org.toot.audio.core.AudioProcess
AUDIO_DISCONNECT, AUDIO_OK
 
Constructor Summary
AudioReader(RandomAccessFileIF fisIF, float Fs)
           
 
Method Summary
 void close()
           
 boolean eof()
           
protected  void fill(uk.org.toot.audio.core.AudioBuffer buffer, int startChunk, int endChunk)
           
protected  void fillConstantGain(uk.org.toot.audio.core.AudioBuffer buffer, int startChunk, int endChunk, double gain)
           
protected  void fillLinearInterpolate(uk.org.toot.audio.core.AudioBuffer buffer, int startChunk, int endChunk, double gain1, double gain2)
           
 int getEnvelopedLengthInFrames()
           
 double getSampleRate()
           
 long milliToByte(double milli)
           
 void open()
           
 int processAudio(uk.org.toot.audio.core.AudioBuffer buffer)
          Read from file into byte buffer and advance the fPtrBytes pointer it is OK to read before/after start/end of the file you'll just get zeros.
 void processAudioBlock(uk.org.toot.audio.core.AudioBuffer buffer)
          this version will block if the file is being written to and there is not enough data to fill the buffer
protected  void processAudioImp(uk.org.toot.audio.core.AudioBuffer buffer, int startChunk, int endChunk)
           
 void seekEnvelopeStart(boolean b)
           
 void seekFrame(long framePos, boolean realTime)
           
 void seekFrameInEnvelope(long framePtr, boolean b)
           
 void seekTimeInMicros(double micros, boolean realTime)
           
 void setBoundsInMicros(double start, double end)
           
 
Methods inherited from class com.frinika.audio.io.AudioWavReader
getChannels, getDataSize, getFormat, getLengthInFrames, readChunkHeader, readFormat
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.frinika.audio.io.BlockableAudioProcess
getChannels, getLengthInFrames
 
Methods inherited from interface com.frinika.audio.io.LimitedAudioReader
getChannels, getFormat
 

Field Detail

startByte

protected long startByte

endByte

protected long endByte

fPtrBytes

protected long fPtrBytes
Constructor Detail

AudioReader

public AudioReader(RandomAccessFileIF fisIF,
                   float Fs)
            throws java.io.IOException
Throws:
java.io.IOException
Method Detail

milliToByte

public final long milliToByte(double milli)

seekTimeInMicros

public void seekTimeInMicros(double micros,
                             boolean realTime)
                      throws java.io.IOException
Throws:
java.io.IOException

seekFrame

public void seekFrame(long framePos,
                      boolean realTime)
               throws java.io.IOException
Parameters:
framePos - frame postition reltive to start of audio. e.g. zero is start of audio.
Throws:
java.io.IOException

eof

public boolean eof()

setBoundsInMicros

public void setBoundsInMicros(double start,
                              double end)

close

public void close()
Specified by:
close in interface uk.org.toot.audio.core.AudioProcess

open

public void open()
Specified by:
open in interface uk.org.toot.audio.core.AudioProcess

processAudioBlock

public void processAudioBlock(uk.org.toot.audio.core.AudioBuffer buffer)
                       throws java.lang.Exception
this version will block if the file is being written to and there is not enough data to fill the buffer

Specified by:
processAudioBlock in interface BlockableAudioProcess
Parameters:
buffer -
Throws:
java.io.IOException
java.lang.Exception

processAudio

public int processAudio(uk.org.toot.audio.core.AudioBuffer buffer)
Read from file into byte buffer and advance the fPtrBytes pointer it is OK to read before/after start/end of the file you'll just get zeros. fPtrBytes is advanced by appropriate byte count.

Specified by:
processAudio in interface LimitedAudioReader
Specified by:
processAudio in interface uk.org.toot.audio.core.AudioProcess
Parameters:
byteBuffer - buffer to fill
offSet - offset into byteBuffer
n - number of bytes to be read
Throws:
java.io.IOException

processAudioImp

protected void processAudioImp(uk.org.toot.audio.core.AudioBuffer buffer,
                               int startChunk,
                               int endChunk)

fillLinearInterpolate

protected void fillLinearInterpolate(uk.org.toot.audio.core.AudioBuffer buffer,
                                     int startChunk,
                                     int endChunk,
                                     double gain1,
                                     double gain2)
Parameters:
buffer -
startChunk -
endChunk -
gain1 -
gain2 -

fillConstantGain

protected void fillConstantGain(uk.org.toot.audio.core.AudioBuffer buffer,
                                int startChunk,
                                int endChunk,
                                double gain)

fill

protected void fill(uk.org.toot.audio.core.AudioBuffer buffer,
                    int startChunk,
                    int endChunk)

getEnvelopedLengthInFrames

public int getEnvelopedLengthInFrames()
Specified by:
getEnvelopedLengthInFrames in interface LimitedAudioReader

seekEnvelopeStart

public void seekEnvelopeStart(boolean b)
                       throws java.io.IOException
Specified by:
seekEnvelopeStart in interface LimitedAudioReader
Throws:
java.io.IOException

seekFrameInEnvelope

public void seekFrameInEnvelope(long framePtr,
                                boolean b)
                         throws java.io.IOException
Specified by:
seekFrameInEnvelope in interface LimitedAudioReader
Throws:
java.io.IOException

getSampleRate

public double getSampleRate()
Specified by:
getSampleRate in interface LimitedAudioReader