Class CaptureDevice
java.lang.Object
de.pottgames.tuningfork.capture.CaptureDevice
- All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable
This class helps to record audio from input devices like microphones.
-
Method Summary
Modifier and TypeMethodDescriptionReturns a list of available input devices.intReturns the number of captured samples.voiddispose()voidfetch16BitSamples(short[] buffer, int samples) Retrieves pcm data from the input device and saves it to a short array.voidfetch16BitSamples(ShortBuffer buffer, int samples) Retrieves pcm data from the input device and saves it to a ShortBuffer.voidfetch8BitSamples(ByteBuffer buffer, int samples) Retrieves pcm data from the input device and saves it to a ByteBuffer.intReturns the size of the internal buffer of the device.static StringReturns the name of the default input device.Returns the device name.intReturns the frequency of the device.Returns the pcm format of the device.static CaptureDeviceopen()Opens the default input device with default settings.static CaptureDeviceopen(CaptureConfig config) Opens an input device with the givenCaptureConfig.voidStarts the capture.voidStops the capture.
-
Method Details
-
startCapture
public void startCapture()Starts the capture. If there were previously recorded samples, they will be overwritten by this method. -
capturedSamples
public int capturedSamples()Returns the number of captured samples.- Returns:
- number of samples
-
fetch8BitSamples
Retrieves pcm data from the input device and saves it to a ByteBuffer. Use this for 8-Bit data only unless you know what you're doing.- Parameters:
buffer- the buffersamples- number of samples to fetch
-
fetch16BitSamples
public void fetch16BitSamples(short[] buffer, int samples) Retrieves pcm data from the input device and saves it to a short array. Use this for 16-Bit data only unless you know what you're doing.- Parameters:
buffer- the buffersamples- number of samples to fetch
-
fetch16BitSamples
Retrieves pcm data from the input device and saves it to a ShortBuffer. Use this for 16-Bit data only unless you know what you're doing.- Parameters:
buffer- the buffersamples- number of samples to fetch
-
stopCapture
public void stopCapture()Stops the capture. -
getDeviceName
-
getPcmFormat
-
getFrequency
public int getFrequency()Returns the frequency of the device.- Returns:
- the frequency
-
getBufferSize
public int getBufferSize()Returns the size of the internal buffer of the device.- Returns:
- the buffer size
-
dispose
public void dispose()- Specified by:
disposein interfacecom.badlogic.gdx.utils.Disposable
-
availableDevices
-
getDefaultDeviceName
Returns the name of the default input device.- Returns:
- name of the default input device
-
open
Opens the default input device with default settings.- Returns:
- the device
-
open
Opens an input device with the givenCaptureConfig.- Parameters:
config- the capture config- Returns:
- the device
-