|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object nl.captcha.audio.Sample
public class Sample
Class representing a sound sample, typically read in from a file. Note that at this time this class only supports wav files with the following characteristics:
Data files in other formats will cause an
IllegalArgumentException
to be thrown.
Field Summary | |
---|---|
static javax.sound.sampled.AudioFormat |
SC_AUDIO_FORMAT
|
Constructor Summary | |
---|---|
Sample(java.io.InputStream is)
|
Method Summary | |
---|---|
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)
|
javax.sound.sampled.AudioInputStream |
getAudioInputStream()
|
void |
getChannelSamples(int channel,
double[] interleavedSamples,
double[] channelSamples)
Extract samples of a particular channel from interleavedSamples and copy them into channelSamples |
javax.sound.sampled.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. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final javax.sound.sampled.AudioFormat SC_AUDIO_FORMAT
Constructor Detail |
---|
public Sample(java.io.InputStream is)
Method Detail |
---|
public javax.sound.sampled.AudioInputStream getAudioInputStream()
public javax.sound.sampled.AudioFormat getFormat()
public long getSampleCount()
public double[] getInterleavedSamples()
public double[] getInterleavedSamples(long begin, long end, double[] samples) throws java.io.IOException, java.lang.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 allocated
begin
- end
- samples
-
java.io.IOException
java.lang.IllegalArgumentException
public void getChannelSamples(int channel, double[] interleavedSamples, double[] channelSamples)
channel
- interleavedSamples
- channelSamples
- public void getStereoSamples(double[] leftSamples, double[] rightSamples) throws java.io.IOException
leftSamples
- rightSamples
-
java.io.IOException
public 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.
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |