Accessor: audio/AudioCapture

audio/AudioCapture

Capture audio from the default audio source on the host (typically the microphone or line in).

If the triggered parameter is true (the default), then capture starts when an event appears on the trigger input port and stops after capturing one segment of audio. Otherwise, the accessor continuously captures segments of audio, initiating a new capture after each segment is completed. The captureTime parameter specifies the duration of each segment of audio that is captured (in milliseconds).

The outputFormat parameter specifies the form in which the audio should appear on the output. The available formats may include:

  • "raw": The output is a byte array representing audio data exactly as captured by default on the host. This is the default and is supported by all hosts.
  • "array": The audio data is converted into an array of arrays of numbers (one array per channel), where each number is in the range from -1.0 to 1.0. The output is an array of arrays, where the first index specifies the channel number.
  • "aiff": The audio data is converted into the AIFF file format historically associated with Apple computers.
  • "aifc": The audio data is converted into the AIFF-C, a compressed version of AIFF.
  • "au": The audio data is converted into the AU file format historically associated with Sun Microsystems and Unix computers.
  • "wav": The audio data is converted into the WAVE file format historically associated with Windows PCs.

    The captureFormat parameter is an object with the following properties, all of which are optional:

  • bitsPerSample: The number of bits per sample. This is an integer that defaults to 16.

  • channels: The number of channels. This defaults to 1.
  • sampleRate: The sample rate. This is an integer that defaults to 8000. Typical supported sample rates are 8000, 11025, 22050, 44100, and 48000.

    This accessor requires the optional 'audio' module, which may or may not be provided by an accessor host. Moreover, a host may not support all capture formats and all output formats.

    The default captureFormat is {bitsPerSample: 16, channels: 1, sampleRate: 8000}.

Version:
  • $$Id$$
Author:
  • Edward A. Lee and Ilge Akkya
Source:
Inputs:
Name Type Description
trigger A trigger input for triggered mode. The value is ignored and can be anything.
trigger Input that triggers recording.
Outputs:
Name Type Description
signal Object The audio output.
signal number A sequence of numbers representing the captured audio signal.
Parameters:
Name Type Description
captureFormat The details of the audio format as an object. See the accessor comment for the default.
captureTime int The length of time for each audio capture (in milliseconds). This defaults to 1000, capturing 1 second of audio at a time.
outputFormat string The format of the output data representing captured audio. This is a string that defaults to 'raw', meaning that the raw bytes are produced on the output.
triggered boolean If true, use triggered mode. Otherwise, use open-loop mode. This is a boolean that defaults to true. This parameter is checked only upon initialization.