PlanetKitAudioMic
public class PlanetKitAudioMic : NSObject
extension PlanetKitAudioMic: PlanetKitAudioMicControllable
extension PlanetKitAudioMic: PlanetAudioUnitTargetDelegate
The PlanetKitAudioMic
class provides the microphone audio processing unit.
-
Indicates whether the VoiceProcessingIO is enabled.
Remark
ThevpioEnabled
property is alwaysfalse
because the microphone audio processing unit does not support voice processing I/O. If you need to use voice processing I/O, you should use thePlanetKitAudioMicSpk
class.Declaration
Swift
public var vpioEnabled: Bool { get set }
-
A Boolean value indicating whether the microphone is enabled or disabled.
Declaration
Swift
public var micEnabled: Bool
-
Sets a private delegate for a
PlanetKitCall
orPlanetKitConference
instance.Remark
You should not set this delegate directly. It will be called when the call is connected or the conference is joined. If you implement it, you should call the delegate’sdidCapture(frameCnt:channels:sampleRate:sampleType:timestamp:outData:outDataLen:)
when the speaker needs to play sound.Declaration
Swift
public weak var micPrivateDelegate: PlanetKitAudioMicCaptureDelegate? { get set }
-
Sets a modifier to receive audio data before sending audio to the server.
The modifier can modify audio data.
Declaration
Swift
public weak var micModifier: PlanetKitAudioMicCaptureDelegate? { get set }
Parameters
micModifier
The modifier to receive audio data before audio transmission.
-
Sets a receiver to receive volume level events at intervals for the microphone.
Declaration
Swift
public weak var micVolumeReceiver: PlanetKitAudioDeviceVolumeDelegate? { get set }
-
Sets the volume level event interval for the microphone.
Declaration
Swift
public var micVolumeInterval: TimeInterval { get set }
-
A textual representation of
PlanetKitAudioMic
instance.Declaration
Swift
public override var description: String { get }
-
Queries whether the audio device instance is opened.
Declaration
Swift
public var isOpened: Bool { get }
-
Queries whether the audio device instance is started.
Declaration
Swift
public var isStarted: Bool { get }
-
Creates an audio processing unit instance and configures AVAudioSession.
iOS Only
If you have configured
PlanetKitAudio.shared.openSettings
, the configuration ofAVAudioSession
will be changed to the configuration ofPlanetKitAudio.shared.openSettings
.Declaration
Swift
public func open()
-
Starts audio processing for the microphone.
iOS Only
It will call
AVAudioSession.sharedInstance().setActive(true)
internally.Declaration
Swift
public func start()
-
Stops audio processing for the microphone.
Declaration
Swift
public func stop()
-
Releases the audio processing unit instance and resets AVAudioSession.
iOS Only
If you have configured
PlanetKitAudio.shared.closeSettings
, the configuration ofAVAudioSession
will be changed to the configuration ofPlanetKitAudio.shared.closeSettings
.Declaration
Swift
public func close()
-
Executes the
completion
handler after all current audio work items are completed.Remark
If you use this function for frequent or heavy jobs, it will affect the performance of setting up the microphone device. Be sure not to enqueue an overload job.Declaration
Swift
public func async(completion: @escaping () -> Void)
-
Represents the currently used microphone device.
Remark
This property is reflected identically toPlanetKitAudio.shared.micDevice
. -
Provides device type information to PlanetKit, indicating if it is a real device or a virtual device.
Remark
The value of theisVirtualDevice
property is alwaysfalse
.See
PlanetKitAudioMicControllable
, PlanetKitAudioSpkControllable`Declaration
Swift
public var isVirtualDevice: Bool { get }
-
Adds a microphone receiver to receive a copy of captured audio data.
Declaration
Swift
public func addMicReceiver(_ micReceiver: PlanetKitAudioMicCaptureDelegate)
-
Removes the targeted microphone receiver.
Declaration
Swift
public func removeMicReceiver(_ micReceiver: PlanetKitAudioMicCaptureDelegate)
-
Processes the captured audio frames.
Declaration
Swift
public func onFrames(_ unitId: UInt32, frameNum frameNums: UInt32, format: UnsafeMutablePointer<AudioStreamBasicDescription>!, timestamp: UnsafePointer<AudioTimeStamp>!, buffer aBuffer: UnsafeMutableRawPointer!, size aBufferSize: UInt32) -> Int32
Parameters
unitId
The ID of the audio unit.
frameNums
The number of frames in the captured audio.
format
A pointer to the audio stream basic description.
timestamp
A pointer to the audio timestamp.
aBuffer
A pointer to the audio buffer.
aBufferSize
The size of the audio buffer.
Return Value
An integer indicating the result of the processing. If successful, the return value is 0. If fails, the return value is any other value.