PlanetKitAudio

public class PlanetKitAudio : NSObject
extension PlanetKitAudio: PlanetKitAudioVolumeDelegate

A class that represents the audio device for PlanetKit.

  • The shared instance of PlanetKitAudio.

    Declaration

    Swift

    @objc
    public static let shared: PlanetKitAudio
  • The default audio manager for PlanetKit.

    Declaration

    Swift

    @objc
    public static var `default`: PlanetKitAudioManager { get }
  • Configures AVAudioSession open settings.

    Remark

    openSettings will be used by PlanetKit when it opens AVAudioSession for PlanetKitAudioMicSpk and PlanetKitAudioMic.

    Declaration

    Swift

    @objc
    public var openSettings: PlanetKitAudioSessionSettings? { get set }
  • Configures AVAudioSession close settings.

    Remark

    closeSettings will be used by PlanetKit when it closes AVAudioSession for PlanetKitAudioMicSpk and PlanetKitAudioMic.

    Declaration

    Swift

    @objc
    public var closeSettings: PlanetKitAudioSessionSettings? { get set }
  • spk

    Default speaker interface.

    Remark

    The default speaker should be configured before creating a call or conference instance. And if you set the PlanetKitAudio.vpioEnabled value, then the speaker interface will be reset by default.

    Declaration

    Swift

    @objc
    public var spk: PlanetKitAudioSpkControllable? { get set }
  • mic

    Default microphone interface.

    Remark

    The default microphone should be configured before creating a call or conference instance. And if you set the PlanetKitAudio.vpioEnabled value, then the microphone interface will be reset by default.

    Declaration

    Swift

    @objc
    public var mic: PlanetKitAudioMicControllable? { get set }
  • Configures the default I/O buffer duration.

    Remark

    This will set the AVAudioSession.ioBufferDuration value. The recommended value is 0.01, but if you set an unaffordable or incorrect value, it can affect the audio device, like causing a Bluetooth HFP device to become stuck or stop working. Please be careful when changing this value.

    Declaration

    Swift

    @objc
    public var defaultIOBufDuration: Float64 { get set }
  • Configures the default microphone sample rate.

    Remark

    The default microphone sample rate is 44100 (VPIO on) or 48000 (VPIO off) in macOS, and 32000 in iOS.

    Declaration

    Swift

    @objc
    public var defaultMicSampleRate: Float64 { get set }
  • Configures the default speaker sample rate.

    Remark

    The default speaker sample rate is 44100 (VPIO on) or 48000 (VPIO off) in macOS, and 32000 in iOS.

    Declaration

    Swift

    @objc
    public var defaultSpkSampleRate: Float64 { get set }
  • Indicates whether the VoiceProcessingIO is enabled.

    Remark

    This value will be modified during call setup by our service configuration. If you want to override our suggested configuration, you should call withIgnoreVpioServiceConfigKey(ignore:). The default value is true for iOS and false for macOS.

    Declaration

    Swift

    @objc
    public var vpioEnabled: Bool { get set }
  • Gets the available audio devices.

  • Gets or sets the microphone device.

    Remark

    The value can be changed at any time and will take effect at the next successful PlanetKitAudio.start() call. If micDevice is set to nil, the input device will be disabled. If you want to restore the default device, call PlanetKitAudio.setPreferredDefaultDevice(type:).
  • Gets or sets the speaker device.

    Remark

    The value can be changed at any time and will take effect at the next successful PlanetKitAudio.start() call. If spkDevice is set to nil, the output device will be disabled. If you want to restore the default device, call PlanetKitAudio.setPreferredDefaultDevice(type:).

Audio Volume

Audio Route

  • Adds a delegate to be notified of audio route changes.

    Declaration

    Swift

    @objc
    public func addAudioRouteChangeDelegate(_ delegate: PlanetKitAudioRouteChangeDelegate)

    Parameters

    delegate

    The delegate to be added.

  • Removes a delegate from being notified of audio route changes.

    Declaration

    Swift

    @objc
    public func removeAudioRouteChangeDelegate(_ delegate: PlanetKitAudioRouteChangeDelegate)

    Parameters

    delegate

    The delegate to be removed.

  • Indicates whether the audio input is from a Bluetooth device in the current audio session route.

    Declaration

    Swift

    @objc
    public var isBluetoothInput: Bool { get }
  • Indicates whether the audio output is from a built-in receiver or built-in speaker in the current audio session route.

    Declaration

    Swift

    @objc
    public var isBuiltInOutput: Bool { get }

PlanetKitAudioVolumeDelegate

  • Called when the volume level of the audio device changes.

    Declaration

    Swift

    public func didChangeVolume(_ type: PlanetKitAudioDeviceType, volume: Float)

    Parameters

    type

    The type of the audio device.

    volume

    The volume level of the audio device.

Notifications

  • The notification name for when the microphone is opened.

    Declaration

    Swift

    @objc
    public static let didOpenMicNotification: NSNotification.Name
  • The notification name for when the speaker is opened.

    Declaration

    Swift

    @objc
    public static let didOpenSpkNotification: NSNotification.Name
  • The notification name for when the microphone is closed.

    Declaration

    Swift

    @objc
    public static let didCloseMicNotification: NSNotification.Name
  • The notification name for when the speaker is closed.

    Declaration

    Swift

    @objc
    public static let didCloseSpkNotification: NSNotification.Name
  • The notification name for when the microphone is started.

    Declaration

    Swift

    @objc
    public static let didStartMicNotification: NSNotification.Name
  • The notification name for when the speaker is started.

    Declaration

    Swift

    @objc
    public static let didStartSpkNotification: NSNotification.Name
  • The notification name for when the microphone is stopped.

    Declaration

    Swift

    @objc
    public static let didStopMicNotification: NSNotification.Name
  • The notification name for when the speaker is stopped.

    Declaration

    Swift

    @objc
    public static let didStopSpkNotification: NSNotification.Name