Package voltage.core

# Class VoltageAudioDevice

java.lang.Object
voltage.core.VoltageComponent
voltage.core.VoltageAudioDevice

public class VoltageAudioDevice extends VoltageComponent
Read and write to and from audio devices.

- ## Field Summary

  ### Fields inherited from class voltage.core.VoltageComponent

  `componentName, displayName`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `VoltageAudioDevice(String name, String displayName, VoltageModule module)`
  `VoltageAudioDevice(String name, VoltageModule module)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `Close()`
  Closes the audio device.
  `int`
  `GetBufferSize()`
  Gets the audio buffer size.
  `String[]`
  `GetInputDeviceNames()`
  Returns a list of available audio input devices.
  `String`
  `GetLastError()`
  Get the last error if OpenDevices() fails.
  `String[]`
  `GetOutputDeviceNames()`
  Return a list of available audio output devices.
  `void`
  `Initialize(boolean allowSharedMode, boolean allowExclusiveMode)`
  Must be called after creating VoltageAudioDevice object.
  `boolean`
  `OpenDevices(String inputDeviceName, String outputDeviceName)`
  Attempts to open the input device, the output device, or both.
  `boolean`
  `Start()`
  Starts playback, recording, or both.
  `boolean`
  `Stop()`
  Stops playback, recording, or both.

  ### Methods inherited from class voltage.core.VoltageComponent

  `AddChildComponent, GetComponentID, GetDisplayName, GetHeight, GetMaxValue, GetMinValue, GetRect, GetSkin, GetTooltipText, GetTransparency, GetUserProperty, GetValue, GetWidth, GetX, GetY, IsEnabled, IsVisible, RemoveChildComponent, SetCanBeAutomated, SetEnabled, SetPosition, SetRect, SetRect, SetSize, SetSkin, SetTransparency, SetUnits, SetUserProperty, SetValue, SetValue, SetValueNoNotification, SetVisible, SetWantsMouseNotifications, SetZOrder, SkewNormalizedValue, UpdateGUIValue, WantsMouseNotifications`

  ### Methods inherited from class java.lang.Object

  `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### VoltageAudioDevice

    public VoltageAudioDevice(String name, String displayName, VoltageModule module)

  - ### VoltageAudioDevice

    public VoltageAudioDevice(String name, VoltageModule module)

- ## Method Details

  - ### Initialize

    public void Initialize(boolean allowSharedMode, boolean allowExclusiveMode)
    Must be called after creating VoltageAudioDevice object. allowSharedMode -- First we attempt to open the audio device at 48,000 Hz in Shared Mode, if this flag is set. (Windows only) allowExclusiveMode -- if the device cannot be opened in Shared Mode, this flag determines if we attempt to open the device at 48,000 Hz in Exclusive Mode. (Windows only)
    Parameters:
      `allowSharedMode` - should shared mode be allowed?
      `allowExclusiveMode` - should exclusive mode be allowed. (Exclusive mode means that other programs will not be able to open this audio device.)

  - ### GetInputDeviceNames

    public String[] GetInputDeviceNames()
    Returns a list of available audio input devices.
    Returns:
      string array of input device names.

  - ### GetOutputDeviceNames

    public String[] GetOutputDeviceNames()
    Return a list of available audio output devices.
    Returns:
      string array of output device names.

  - ### OpenDevices

    public boolean OpenDevices(String inputDeviceName, String outputDeviceName)
    Attempts to open the input device, the output device, or both. Pass a blank string or a null if you don't want an input or output. The device is always opened at 48 kHz, in stereo if it's a stereo device. On Windows, some devices cannot be opened in Shared Mode at 48 kHz. If the device fails to open in Shared Mode, and Initialize() was called with allowExclusiveMode set to true, we will attempt to open the device in Exclusive Mode. This almost always succeeds.
    Parameters:
      `inputDeviceName` - the names of the input device.
      `outputDeviceName` - the names of the output device.
    Returns:
      false if the device or devices cannot be opened. Use GetLastError() to retrieve the error message.

  - ### GetBufferSize

    public int GetBufferSize()
    Gets the audio buffer size.
    Returns:
      the buffer size of the audio device. OpenDevices() must be successfully called before calling this function.

  - ### Close

    public void Close()
    Closes the audio device.

  - ### GetLastError

    public String GetLastError()
    Get the last error if OpenDevices() fails.
    Returns:
      the description of the last error. If OpenDevices fails, call this function to retrieve the error message.

  - ### Start

    public boolean Start()
    Starts playback, recording, or both.
    Returns:
      true if successfully started playback and/or recording (input).

  - ### Stop

    public boolean Stop()
    Stops playback, recording, or both.
    Returns:
      true if it successfully stopped playback and/or recording (input).