com.frinika.sequencer.model.audio
Class BufferedRandomAccessFile
java.lang.Object
com.frinika.sequencer.model.audio.BufferedRandomAccessFile
- All Implemented Interfaces:
- RandomAccessFileIF
public class BufferedRandomAccessFile
- extends java.lang.Object
- implements RandomAccessFileIF
Provides an implementation of RandomAccessFileIF that uses a cyclic cache.
Collaborates with a BufferedRandomAccessFileManager
File relative pointers
ptr1 -> (ptr2-1) files sample in buffer
endPtr end of file samples (+1)
ptr being read from the cache.
- Author:
- pjl
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
BufferedRandomAccessFile
public BufferedRandomAccessFile(java.io.RandomAccessFile in,
int buffSize,
BufferedRandomAccessFileManager manager)
isFull
public final boolean isFull()
getRandomAccesFile
public java.io.RandomAccessFile getRandomAccesFile()
availableInCache
public final int availableInCache()
read
public int read(byte[] byteBuffer,
int offSet,
int n,
boolean realTime)
throws java.io.IOException
- read the next n bytes
- Specified by:
read in interface RandomAccessFileIF
- Parameters:
byteBuffer - offSet - n -
- Returns:
-
- Throws:
java.io.IOException
getFilePointer
public long getFilePointer()
length
public long length()
throws java.io.IOException
- Specified by:
length in interface RandomAccessFileIF
- Throws:
java.io.IOException
seek
public void seek(long l,
boolean realTime)
throws java.io.IOException
- if (!realTime) may block. the buffer is filled else seek for processAudio
thread. only sets the pointer (avoid synchronisation issues)
- Specified by:
seek in interface RandomAccessFileIF
- Parameters:
l - new file position
- Throws:
java.io.IOException
close
public void close()
getRandomAccessFile
public java.io.RandomAccessFile getRandomAccessFile()
- Specified by:
getRandomAccessFile in interface RandomAccessFileIF