public class Sample extends Object
Data files in other formats will cause an
IllegalArgumentException to be thrown.
| 限定符和类型 | 字段和说明 |
|---|---|
static AudioFormat |
SC_AUDIO_FORMAT |
| 构造器和说明 |
|---|
Sample(InputStream is) |
| 限定符和类型 | 方法和说明 |
|---|---|
byte[] |
asByteArray()
Return the interleaved samples as a
byte[]. |
static byte[] |
asByteArray(long sampleCount,
double[] sample)
Helper method to convert a double[] to a byte[] in a format that can be
used by
AudioInputStream. |
void |
decodeBytes(byte[] audioBytes,
double[] audioSamples) |
AudioInputStream |
getAudioInputStream() |
void |
getChannelSamples(int channel,
double[] interleavedSamples,
double[] channelSamples)
Extract samples of a particular channel from interleavedSamples and copy
them into channelSamples
|
AudioFormat |
getFormat() |
double[] |
getInterleavedSamples() |
double[] |
getInterleavedSamples(long begin,
long end,
double[] samples)
Get the interleaved decoded samples for all channels, from sample index
begin (included) to sample index end (excluded)
and copy them into samples. |
long |
getSampleCount()
Return the number of samples of all channels
|
void |
getStereoSamples(double[] leftSamples,
double[] rightSamples)
Convenience method.
|
String |
toString() |
public static final AudioFormat SC_AUDIO_FORMAT
public Sample(InputStream is)
public AudioInputStream getAudioInputStream()
public AudioFormat getFormat()
public long getSampleCount()
public double[] getInterleavedSamples()
public double[] getInterleavedSamples(long begin,
long end,
double[] samples)
throws IOException,
IllegalArgumentException
begin (included) to sample index end (excluded)
and copy them into samples. end must not exceed
getSampleCount(), and the number of samples must not be so
large that the associated byte array cannot be allocatedbegin - end - samples - IOExceptionIllegalArgumentExceptionpublic void getChannelSamples(int channel,
double[] interleavedSamples,
double[] channelSamples)
channel - interleavedSamples - channelSamples - public void getStereoSamples(double[] leftSamples,
double[] rightSamples)
throws IOException
leftSamples - rightSamples - IOExceptionpublic void decodeBytes(byte[] audioBytes,
double[] audioSamples)
public final byte[] asByteArray()
byte[].public static final byte[] asByteArray(long sampleCount,
double[] sample)
AudioInputStream. Typically this will be used with
a Sample that has been modified from its original.Copyright © 2015. All rights reserved.