MediaPipeTasksCommon Framework Reference

AudioRecord

final class AudioRecord: Sendable

Continuously records microphone samples into a thread-safe circular buffer.

  • Maximum supported audio channel count (2).

    Declaration

    Swift

    static let maximumChannelCount: Int
  • Creates a microphone recorder backed by a ring buffer of capacity bufferLength.

    Declaration

    Swift

    init(audioDataFormat: AudioDataFormat, bufferLength: Int) throws
  • Audio format specifying the channel count and sample rate of recorded samples.

    Declaration

    Swift

    final let audioDataFormat: AudioDataFormat
  • Maximum number of samples retained across all channels.

    Declaration

    Swift

    final let bufferLength: Int
  • Reads length samples starting at offset from the oldest sample.

    Declaration

    Swift

    final func read(offset: Int, length: Int) throws -> FloatBuffer
  • Starts tapping microphone samples using AVAudioEngine.

    Declaration

    Swift

    final func startRecording() throws
  • Stops recording audio and clears buffered samples.

    Declaration

    Swift

    final func stop() throws