|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.util.Observable com.softsynth.jsyn.SynthObject com.softsynth.jsyn.SynthChannelData com.softsynth.jsyn.SynthSample
public class SynthSample
The SynthSample class is a container for digital audio data.
The actual data may need to reside in memory that is accessible to
DMA or to a DSP so we cannot assume that it is in main memory. We also need to maintain cache coherence if the data is
going to be read or written by hardware other than the CPU. For this reason, Samples cannot use memory allocated by, or
accessable to the application.
Synth
,
SynthTable
,
SampleReader_16V1
,
SampleReader_16F1
,
SampleReader_16F2
,
SampleWriter_16F1
,
SampleWriter_16F2
,
DelayUnit
Field Summary | |
---|---|
static int |
AIFF
|
byte[] |
byteData
Used to store raw bytes temporarily when parsing a sample file. |
static int |
UNRECOGNIZED
|
static int |
WAV
|
Fields inherited from class com.softsynth.jsyn.SynthChannelData |
---|
cuePoints |
Constructor Summary | |
---|---|
SynthSample()
|
|
SynthSample(int numFrames)
Create a monophonic sample with the specified number of frames. |
|
SynthSample(int maxFrames,
int channelsPerFrame)
|
|
SynthSample(SynthContext synthContext)
Create an empty sample. |
|
SynthSample(SynthContext synthContext,
int maxFrames)
|
|
SynthSample(SynthContext synthContext,
int maxFrames,
int channelsPerFrame)
Create a digital audio sample with the specified number of frames, and channels per frame. |
Method Summary | |
---|---|
void |
allocate(int numFrames,
int channelsPerFrame)
Allocate low level sample resources and memory to hold sample data. |
void |
clear()
|
void |
clear(int firstSampleFrame,
int numFrames)
Clear part of a SynthSample. |
java.lang.String |
dump()
|
double |
getBaseFrequency()
The best frequency to associate with the perceived pitch of the instrument when played at the recorded SampleRate. |
int |
getChannelsPerFrame()
|
long |
getFileSize()
This can be read by another thread when load()ing a sample to determine how many bytes need to be read. |
static int |
getFileType(java.lang.String fileName)
Determine file type based on suffix, case insensitive. |
long |
getNumBytesRead()
This can be read by another thread when load()ing a sample to determine how many bytes have been read so far. |
long |
getOffset()
Return number of bytes from beginning of stream where sound data resides. |
double |
getSampleRate()
|
void |
load(java.io.InputStream stream)
|
void |
load(java.io.InputStream stream,
boolean ifLoadData)
Load the sample from the given stream. |
short[] |
loadShorts(java.io.InputStream stream,
boolean ifLoadData)
|
void |
read(int firstSampleFrame,
short[] data,
int firstDataIndex,
int numFrames)
Read from the SynthSample into an array of shorts. |
void |
read(short[] data)
|
void |
setBaseFrequency(double baseFrequency)
|
void |
setHighAmplitude(double highestAmplitude)
|
void |
setHighFrequency(double highestFrequency)
|
void |
setLowAmplitude(double lowestAmplitude)
Set range of Amplitudes for which this sample could be chosen when doing MultiSample selection. |
void |
setLowFrequency(double lowestFrequency)
Set range of Amplitudes for which this sample could be chosen when doing MultiSample selection. |
void |
setSampleRate(double sampleRate)
Set rate at which sample was recorded. |
void |
write(int firstSampleFrame,
short[] data,
int firstDataIndex,
int numFrames)
Write data from an array of shorts to the Samples internal storage area. |
void |
write(short[] data)
|
Methods inherited from class com.softsynth.jsyn.SynthChannelData |
---|
findCuePoint, findCuePosition, getMaxFrames, getNumFrames, getReleaseBegin, getReleaseEnd, getReleaseSize, getSustainBegin, getSustainEnd, getSustainSize, insertSortedCue, setNumFrames, setReleaseLoop, setSustainLoop |
Methods inherited from class com.softsynth.jsyn.SynthObject |
---|
delete, deleteAll, enableDeletionByGarbageCollector, enableTracking, getPeer, getSynthContext, isTrackingEnabled, toString, track |
Methods inherited from class java.util.Observable |
---|
addObserver, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int UNRECOGNIZED
public static final int AIFF
public static final int WAV
public byte[] byteData
Constructor Detail |
---|
public SynthSample(SynthContext synthContext)
public SynthSample()
public SynthSample(SynthContext synthContext, int maxFrames, int channelsPerFrame) throws SynthException
maxFrames
- Number of sample frames to allocate.channelsPerFrame
- Number of channels in a frame, eg. 1 for mono, 2 for stereo.
SynthException
- If there is insufficient memory.public SynthSample(int maxFrames, int channelsPerFrame) throws SynthException
SynthException
public SynthSample(SynthContext synthContext, int maxFrames)
public SynthSample(int numFrames) throws SynthException
SynthException
- If there is insufficient memory.Method Detail |
---|
public static int getFileType(java.lang.String fileName)
public void allocate(int numFrames, int channelsPerFrame) throws SynthException
SynthException
- If there is insufficient memory.public void write(int firstSampleFrame, short[] data, int firstDataIndex, int numFrames) throws SynthException
firstSampleFrame
- = Index of first frame of sample to be written to. A frame in a mono sample is one short. A frame in a stereo sample is two shorts.data
- = array of shorts containing sample data.firstDataIndex
- = index of first element in data array to write from. Note that for stereo samples, the firstDataIndex is twice the equivalent frame index.numFrames
- = number of frames to write.
SynthException
- If frames are out of range.public void write(short[] data) throws SynthException
SynthException
public void clear(int firstSampleFrame, int numFrames)
firstSampleFrame
- = Index of first frame of sample to clear. A frame in a mono sample is one short. A frame in a stereo sample is two shorts.numFrames
- = number of frames to clear.
SynthException
- If frames are out of range.public void clear()
public void read(int firstSampleFrame, short[] data, int firstDataIndex, int numFrames) throws SynthException
firstSampleFrame
- = Index of first frame of sample to be read from. A frame in a mono sample is one short. A frame in a stereo sample is two shorts.data
- = array of shorts containing sample data.firstDataIndex
- = index of first element in data array to read into. Note that for stereo samples, the firstDataIndex is twice the equivalent frame index.numFrames
- = number of frames to write.
SynthException
- If frames are out of range.public void read(short[] data) throws SynthException
SynthException
public void setSampleRate(double sampleRate)
public double getSampleRate()
public void setBaseFrequency(double baseFrequency)
public double getBaseFrequency()
public int getChannelsPerFrame()
public void setLowFrequency(double lowestFrequency)
public void setHighFrequency(double highestFrequency)
public void setLowAmplitude(double lowestAmplitude)
public void setHighAmplitude(double highestAmplitude)
public java.lang.String dump()
public long getOffset()
public void load(java.io.InputStream stream) throws SynthException, java.io.IOException
SynthException
java.io.IOException
public void load(java.io.InputStream stream, boolean ifLoadData) throws SynthException, java.io.IOException
stream
- May be any stream from a file, a URL, a byte array, etc.ifLoadData
- If true, sample data will be loaded into memory.
SynthException
- If parsing fails, or there is insufficient memory.
java.io.IOException
public short[] loadShorts(java.io.InputStream stream, boolean ifLoadData) throws SynthException, java.io.IOException
SynthException
java.io.IOException
public long getNumBytesRead()
public long getFileSize()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |