|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.beadsproject.beads.data.Sample
public class Sample
A Sample is a multi-channel buffer of audio data which can be read from a file or recorded from a UGen and written to a file.
Recorder
Field Summary | |
---|---|
javax.sound.sampled.AudioFormat |
audioFormat
The audio format. |
float[][] |
buf
The buffer containing the audio data. |
float |
length
The length in milliseconds. |
int |
nChannels
The number of channels. |
long |
nFrames
The number of sample frames. |
Constructor Summary | |
---|---|
Sample(javax.sound.sampled.AudioFormat audioFormat,
long totalFrames)
Instantiates a new empty buffer with the specified audio format and number of frames. |
|
Sample(java.lang.String fn)
Creates a new Sample from the specified file. |
Method Summary | |
---|---|
java.lang.String |
getFileName()
Gets the full file name. |
float[] |
getFrameCubic(int currentSample,
float fractionOffset)
Retrieves a frame of audio using cubic interpolation. |
float[] |
getFrameLinear(int currentSample,
float fractionOffset)
Retrieves a frame of audio using linear interpolation. |
java.lang.String |
getSimpleFileName()
Gets the simple file name. |
double |
msToSamples(double msTime)
Converts from milliseconds to samples based on the sample rate specified by audioFormat . |
void |
printAudioFormatInfo()
Prints audio format info to System.out. |
double |
samplesToMs(double sampleTime)
Converts from samples to milliseconds based on the sample rate specified by audioFormat . |
java.lang.String |
toString()
|
void |
write(java.lang.String fn)
Write Sample to a file. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public final javax.sound.sampled.AudioFormat audioFormat
public final int nChannels
public final long nFrames
public final float length
public final float[][] buf
nChannels
][nFrames
]
Constructor Detail |
---|
public Sample(javax.sound.sampled.AudioFormat audioFormat, long totalFrames)
audioFormat
- the audio format.totalFrames
- the number of sample frames.public Sample(java.lang.String fn) throws javax.sound.sampled.UnsupportedAudioFileException, java.io.IOException
SampleManager.sample(String)
, which adds the data to a static repository once it is loaded.
fn
- the file path.
javax.sound.sampled.UnsupportedAudioFileException
- Signals that the file format is not supported.
java.io.IOException
- Signals that an I/O exception has occurred.Method Detail |
---|
public double msToSamples(double msTime)
audioFormat
.
msTime
- the time in milliseconds.
public double samplesToMs(double sampleTime)
audioFormat
.
sampleTime
- the time in samples.
public float[] getFrameLinear(int currentSample, float fractionOffset)
currentSample
- the current sample.fractionOffset
- the offset from the current sample as a fraction of the time
to the next sample.
public float[] getFrameCubic(int currentSample, float fractionOffset)
currentSample
- the current sample.fractionOffset
- the offset from the current sample as a fraction of the time
to the next sample.
public void printAudioFormatInfo()
public void write(java.lang.String fn) throws java.io.IOException
fn
- the file name.
java.io.IOException
- Signals that an I/O exception has occurred.public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String getFileName()
public java.lang.String getSimpleFileName()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |