|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.beadsproject.beads.data.audiofile.AudioFile
public abstract class AudioFile
An AudioFile provides a handle to an audio file located either on disk or
online.
AudioFile is used by Sample
.
Depending on the AudioIO implementation different audio file types may or may
not be available.
Nested Class Summary | |
---|---|
static class |
AudioFile.OperationUnsupportedException
Thrown if an operation is unsupported for this AudioFile. |
static class |
AudioFile.Type
Audio File Format Type |
Field Summary | |
---|---|
protected SampleAudioFormat |
audioFormat
The format of the decoded audio data. |
protected java.util.Map<java.lang.String,java.lang.Object> |
audioInfo
Additional properties of this AudioFile. |
protected float |
length
Length of the file in milliseconds If <0 then it is unknown. |
protected java.lang.String |
name
The name of this audiofile. |
protected long |
nFrames
The total number of frames. |
protected boolean |
trace
Advanced. |
protected AudioFile.Type |
type
The file format type, default is WAV. |
Constructor Summary | |
---|---|
protected |
AudioFile()
Don't implement me. |
protected |
AudioFile(java.io.InputStream is)
Implement to create an AudioFile from a specified input stream. |
protected |
AudioFile(SampleAudioFormat audioFormat)
Implement this, even if you don't do anything. |
protected |
AudioFile(java.lang.String filename)
Implement to create an AudioFile from a specified filename. |
Method Summary | |
---|---|
abstract void |
close()
Close the audio file. |
int |
getBitDepth()
|
SampleAudioFormat |
getFormat()
|
int |
getFrameSize()
|
java.lang.String |
getInformation()
|
float |
getLength()
|
java.lang.String |
getName()
|
int |
getNumChannels()
|
long |
getNumFrames()
|
java.util.Map<java.lang.String,java.lang.Object> |
getProperties()
|
abstract boolean |
isClosed()
Is the file stream closed? |
boolean |
isOpen()
Is the file stream open? |
abstract void |
open()
Opens the audio file. |
abstract int |
read(byte[] buffer)
Read bytes from this audiofile. |
abstract int |
read(float[][] buffer)
Read decoded audio data in a non-interleaved, Beads-friendly format. |
void |
reset()
Reset the audio input stream. |
void |
seek(int frame)
Seek to a specific frame number. |
protected void |
setLength(float length)
|
protected void |
setNumFrames(long nFrames)
|
void |
setTrace(boolean trace)
A debugging tool. |
void |
skip(long frames)
Skips a number of frames. |
abstract void |
write(java.lang.String fn,
AudioFile.Type type,
byte[] audioDataBytes)
Writes data to file from interleaved byte array. |
abstract void |
write(java.lang.String fn,
AudioFile.Type type,
float[][] audioDataFloat)
Writes data to file from float array of form [channels][samples]. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.lang.String name
protected SampleAudioFormat audioFormat
protected long nFrames
protected float length
protected java.util.Map<java.lang.String,java.lang.Object> audioInfo
protected boolean trace
protected AudioFile.Type type
Constructor Detail |
---|
protected AudioFile(java.lang.String filename)
filename
- protected AudioFile(java.io.InputStream is)
is
- protected AudioFile(SampleAudioFormat audioFormat)
protected AudioFile()
Method Detail |
---|
public void reset() throws AudioFile.OperationUnsupportedException
OperationUnsupported
AudioFile.OperationUnsupportedException
public void skip(long frames) throws AudioFile.OperationUnsupportedException
OperationUnsupported
AudioFile.OperationUnsupportedException
public void seek(int frame) throws AudioFile.OperationUnsupportedException
frame
- The frame number, relative to the start of the audio data.
OperationUnsupported
AudioFile.OperationUnsupportedException
public abstract void open() throws java.io.IOException
java.io.IOException
public java.lang.String getName()
public java.lang.String getInformation()
public abstract void close() throws java.io.IOException
java.io.IOException
public boolean isOpen()
public abstract boolean isClosed()
public SampleAudioFormat getFormat()
public abstract int read(byte[] buffer)
buffer
- A buffer to fill.
public abstract int read(float[][] buffer)
buffer
- The buffer to fill. After execution buffer[i][j] will contain
the sample in channel i, frame j. Buffer has size
(numChannels,numFramesRequested).
public abstract void write(java.lang.String fn, AudioFile.Type type, byte[] audioDataBytes) throws java.io.IOException
fn
- the file name.type
- the file format.audioDataBytes
- the byte data.
java.io.IOException
public abstract void write(java.lang.String fn, AudioFile.Type type, float[][] audioDataFloat) throws java.io.IOException
fn
- the file name.type
- the file format.audioDataFloat
- the float data.
java.io.IOException
public java.util.Map<java.lang.String,java.lang.Object> getProperties()
public int getNumChannels()
protected void setNumFrames(long nFrames)
public long getNumFrames()
protected void setLength(float length)
public float getLength()
public int getBitDepth()
public int getFrameSize()
public void setTrace(boolean trace)
trace
- Enable or disable a trace of file accesses. Useful for
debugging.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |