IVSAudioDevice

Objective-C

@protocol IVSAudioDevice <IVSDevice>

Swift

protocol IVSAudioDevice : IVSDevice

This represents an IVSDevice that provides audio samples.

  • Gets the gain for this audio device.

    Declaration

    Objective-C

    - (float)gain;

    Swift

    func gain() -> Float
  • Sets the gain for this audio device. This will be clamped between 0 and 2. A gain of 1 means no change. A gain less than 1 will suppress, and greater than 1 will amplify.

    Declaration

    Objective-C

    - (void)setGain:(float)gain;

    Swift

    func setGain(_ gain: Float)

    Parameters

    gain

    the requested gain

  • Set a callback to receive audio stats for this device. This will always be invoked on the main queue.

    Declaration

    Objective-C

    - (void)setStatsCallback:(nullable IVSAudioDeviceStatsCallback)callback;

    Swift

    func setStatsCallback(_ callback: IVSAudioDeviceStatsCallback?)

    Parameters

    callback

    that takes two floats: peak and rms.

  • Set a callback to receive the raw PCM audio buffers as they move through this device.

    The callback fires on the audio thread for lowest latency, exactly as the audio is delivered. Implementations must return quickly and must not block, or audio glitches may occur. The callback must not call setOnPCMBufferCallback: re-entrantly. Pass nil to clear the callback.

    Declaration

    Objective-C

    - (void)setOnPCMBufferCallback:
        (nullable void (^)(AVAudioPCMBuffer *_Nonnull,
                           AVAudioTime *_Nonnull))callback;

    Swift

    func setOnPCMBufferCallback(_ callback: ((AVAudioPCMBuffer, AVAudioTime) -> Void)?)

    Parameters

    callback

    A block that receives the PCM data as an AVAudioPCMBuffer and an AVAudioTime representing the presentation timestamp, monotonically increasing from the start of audio at the buffer’s sample rate.