|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectsampled.AudioCapture
public class AudioCapture
Use this class to capture audio directly from a microphone. The default i s 16kHz at 16bit. Other sampling and bit rates are possible, but capturing is limited to signed, little endian. Use the main program to list available mixer names; if no mixer name is specified on instantiation, the Java AudioSystem default is used.
Field Summary | |
---|---|
java.lang.String |
mixerName
name of the target mixer or null if default mixer |
static java.lang.String |
synopsis
|
Constructor Summary | |
---|---|
AudioCapture()
Create the default capture object: 16kHz at 16bit |
|
AudioCapture(int bitRate,
int sampleRate)
Create a specific capture object (bound to signed, little endian). |
|
AudioCapture(java.lang.String mixerName)
Create an AudioCapture object reading from the specified mixer. |
|
AudioCapture(java.lang.String mixerName,
boolean defaultMixerFallBack)
Create an AudioCapture object reading from the specified mixer. |
|
AudioCapture(java.lang.String mixerName,
boolean defaultMixerFallBack,
int bitRate,
int sampleRate)
Create an AudioCapture object reading from the specified mixer using the given sample rate and bit rate. |
|
AudioCapture(java.lang.String mixerName,
int bitRate,
int sampleRate)
Create an AudioCapture object reading from the specified mixer using the given sample rate and bit rate. |
Method Summary | |
---|---|
void |
disableDCShift()
turn DC shift off |
void |
disableInternalBuffer()
Disable the use of the internal buffer (the internal buffer won't be used if read() receives a valid buffer. |
void |
disableScaling()
Disable the [-1;1] scaling to retrieve the original numeric values of the signal. |
void |
enableDCShift(int contextSize)
enables the DC shift or updates the instance for the given context size |
void |
enableInternalBuffer(int bufferSize)
Enable the internal Buffer (instead of the local one) |
void |
enableScaling()
Enable scaling of the signal to [-1;1] depending on its bit rate |
double[] |
getBuffer()
Return the converted buffer containing (normalized) values |
static java.lang.String[] |
getMixerList()
Return a list of Strings matching the mixer names. |
boolean |
getPreEmphasis()
Does the AudioSource perform pre-emphasis? |
byte[] |
getRawBuffer()
Return the raw buffer; mind 8/16 bit and signed/unsigned conversion! |
int |
getSampleRate()
Return the current sampling rate |
static void |
main(java.lang.String[] args)
|
int |
read(double[] buf)
Read the next buf.length samples (blocking). |
void |
setPreEmphasis(boolean applyPreEmphasis,
double a)
Enable pre-emphasis with given factor |
void |
tearDown()
Tear down the audio capture environment (free resources) |
java.lang.String |
toString()
Return a string representation of the capture device |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public java.lang.String mixerName
public static final java.lang.String synopsis
Constructor Detail |
---|
public AudioCapture() throws java.io.IOException
java.io.IOException
public AudioCapture(int bitRate, int sampleRate) throws java.io.IOException
bitRate
- target bit rate (usually 8 or 16bit)sampleRate
- target sample rate (usually 8 or 16kHz)
java.io.IOException
public AudioCapture(java.lang.String mixerName) throws java.io.IOException
mixerName
- Name of the mixer to use; searches for any occurance of
'mixerName' in the available mixer names
java.io.IOException
public AudioCapture(java.lang.String mixerName, boolean defaultMixerFallBack) throws java.io.IOException
mixerName
- Name of the mixer to usedefaultMixerFallBack
- fall back to default mixer if desired mixer not available
java.io.IOException
public AudioCapture(java.lang.String mixerName, boolean defaultMixerFallBack, int bitRate, int sampleRate) throws java.io.IOException
mixerName
- Name of the mixer to read fromdefaultMixerFallBack
- fall back to default mixer if desired mixer not availablebitRate
- bit rate to use (usually 8 or 16 bit)sampleRate
- sample rate to read (usually 8000 or 16000)
java.io.IOException
public AudioCapture(java.lang.String mixerName, int bitRate, int sampleRate) throws java.io.IOException
mixerName
- Name of the mixer to read frombitRate
- bit rate to use (usually 8 or 16 bit)sampleRate
- sample rate to read (usually 8000 or 16000)
java.io.IOException
Method Detail |
---|
public void disableDCShift()
public void disableInternalBuffer()
public void disableScaling()
public void enableDCShift(int contextSize)
public void enableInternalBuffer(int bufferSize)
bufferSize
- public void enableScaling()
public double[] getBuffer()
public static java.lang.String[] getMixerList()
public boolean getPreEmphasis()
AudioSource
getPreEmphasis
in interface AudioSource
public byte[] getRawBuffer()
public int getSampleRate()
getSampleRate
in interface AudioSource
public static void main(java.lang.String[] args) throws java.io.IOException
java.io.IOException
public int read(double[] buf) throws java.io.IOException
read
in interface AudioSource
buf
- double buffer; will try to read as many samples as fit in the
buffer. If buf is null, the internal buffer will be used (call enableInternalBuffer
in advance!)
java.io.IOException
AudioFileReader.read
public void setPreEmphasis(boolean applyPreEmphasis, double a)
setPreEmphasis
in interface AudioSource
applyPreEmphasis
- apply pre-emphasis?a
- the pre-emphasis factor: x'(n) = x(n) - a*x(n-1)public void tearDown() throws java.io.IOException
tearDown
in interface AudioSource
java.io.IOException
public java.lang.String toString()
toString
in interface AudioSource
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |