Class RtAudio

RtAudio provides a common API (Application Programming Interface) for realtime audio input/output across Linux (native ALSA, Jack, and OSS), Macintosh OS X (CoreAudio and Jack), and Windows (DirectSound, ASIO and WASAPI) operating systems.

Constructors

  • Create an RtAudio instance.

    Parameters

    • Optional api: RtAudioApi

      The audio API to use. (Default will be automatically selected)

    Returns RtAudio

Properties

outputVolume: number

The volume of the output device. This should be a number between 0 and 1.

streamTime: number

The number of elapsed seconds since the stream was started. This should be a time in seconds greater than or equal to 0.0.

Methods

  • Clears the output stream queue.

    Returns void

  • A function that closes a stream and frees any associated stream memory.

    Returns void

  • Returns the full display name of the current used API.

    Returns string

  • Returns the id of the default input device.

    Returns number

  • Returns the id of the default output device.

    Returns number

  • Returns the internal stream latency in sample frames.

    Returns number

  • Returns actual sample rate in use by the stream.

    Returns number

  • Returns true if a stream is open and false if not.

    Returns boolean

  • Returns true if the stream is running and false if it is stopped or not open.

    Returns boolean

  • A public function for opening a stream with the specified parameters. Returns the actual frameSize used by the stream, useful if a frameSize of 0 is passed.

    Parameters

    • outputParameters: null | RtAudioStreamParameters

      Specifies output stream parameters to use when opening a stream. For input-only streams, this argument should be null.

    • inputParameters: null | RtAudioStreamParameters

      Specifies input stream parameters to use when opening a stream. For output-only streams, this argument should be null.

    • format: RtAudioFormat

      An RtAudio.Format specifying the desired sample data format.

    • sampleRate: number

      The desired sample rate (sample frames per second).

    • frameSize: number

      The amount of samples per frame. Can be 0 for some APIs, in which case the lowest allowable value is determined; this is necessary for the ASIO & Jack APIs where the user can set an overriding global buffer size for their device.

    • streamName: string

      A stream name (currently used only in Jack).

    • inputCallback: null | ((inputData) => void)

      A callback that is called when a new input signal is available. Should be null for output-only streams.

    • frameOutputCallback: null | (() => void)

      A callback that is called when a frame is finished playing in the output device.

    • Optional flags: RtAudioStreamFlags

      A bit-mask of stream flags (RtAudio.StreamFlags).

    • Optional errorCallback: null | ((type, msg) => void)

      A callback that is called when an error has occurred.

    Returns number

    The actual frame-size used for stream. Useful if passed 0 as frameSize.

  • Sets the frame output playback for the output device.

    Parameters

    • callback: null | (() => void)

      A callback that is called when a frame is finished playing in the output device.

    Returns void

  • Sets the input callback function for the input device.

    Parameters

    • callback: null | ((inputData) => void)

      A callback that is called when a new input signal is available. Should be null for output-only streams.

    Returns void

  • Queues a new output PCM data to be played using the stream.

    Parameters

    • pcm: Buffer

      The raw PCM data. The length should be frame_size * no_of_output_channels * size_of_sample.

    Returns void