Class CaptureDevice

java.lang.Object
de.pottgames.tuningfork.capture.CaptureDevice
All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable

public class CaptureDevice extends Object implements com.badlogic.gdx.utils.Disposable
This class helps to record audio from input devices like microphones.
  • 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

      public void fetch8BitSamples(ByteBuffer buffer, int samples)
      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 buffer
      samples - 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 buffer
      samples - number of samples to fetch
    • fetch16BitSamples

      public void fetch16BitSamples(ShortBuffer buffer, int samples)
      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 buffer
      samples - number of samples to fetch
    • stopCapture

      public void stopCapture()
      Stops the capture.
    • getDeviceName

      public String getDeviceName()
      Returns the device name.
      Returns:
      the device name
    • getPcmFormat

      public PcmFormat getPcmFormat()
      Returns the pcm format of the device.
      Returns:
      the format
    • 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:
      dispose in interface com.badlogic.gdx.utils.Disposable
    • availableDevices

      public static List<String> availableDevices()
      Returns a list of available input devices.
      Returns:
      list of devices
    • getDefaultDeviceName

      public static String getDefaultDeviceName()
      Returns the name of the default input device.
      Returns:
      name of the default input device
    • open

      public static CaptureDevice open()
      Opens the default input device with default settings.
      Returns:
      the device
    • open

      public static CaptureDevice open(CaptureConfig config)
      Opens an input device with the given CaptureConfig.
      Parameters:
      config - the capture config
      Returns:
      the device