TVOAudioFormat Class Reference

Inherits from NSObject
Declared in TVOAudioFormat.h

Overview

TVOAudioFormat describes audio that is captured or rendered via a TVOAudioDevice. The class also offers convenience methods to help interoperate with CoreAudio and size your audio buffers appropriately.

  numberOfChannels

The number of channels in the audio stream.

@property (nonatomic, assign, readonly) size_t numberOfChannels

Discussion

Valid values for this property are either 1 or 2. Only mono and stereo LPCM audio are supported.

Declared In

TVOAudioFormat.h

  sampleRate

The sample rate of the audio stream in units of frequency (Hz), i.e. the number of audio samples per second.

@property (nonatomic, assign, readonly) uint32_t sampleRate

Discussion

Valid values for this property are 8000, 16000, 24000, 32000, 44100 and 48000 Hz.

Declared In

TVOAudioFormat.h

  framesPerBuffer

The maximum number of frames contained in a single audio buffer.

@property (nonatomic, assign, readonly) size_t framesPerBuffer

Discussion

The underlying media engine operates on 20 millisecond slices of LPCM audio. Ideally, your audio device should capture and render in exactly 10 millisecond buffers. However, in many cases this is not possible on iOS. If you’re using AudioUnits to produce or consume audio you should use AVAudioSession.preferredIOBufferDuration to request appropriately sized buffers.

Declared In

TVOAudioFormat.h

– init

Developers shouldn’t use init to create TVOAudioFormat.

- (null_unspecified instancetype)init

Discussion

Use initWithChannels:sampleRate:framesPerBuffer: instead.

Declared In

TVOAudioFormat.h

– initWithChannels:sampleRate:framesPerBuffer:

Initializes an instance of TVOAudioFormat.

- (nullable instancetype)initWithChannels:(size_t)channels sampleRate:(uint32_t)sampleRate framesPerBuffer:(size_t)framesPerBuffer

Parameters

channels

The number of channels in the audio stream.

sampleRate

The sample rate of the audio stream.

framesPerBuffer

The maximum number of frames contained in a single audio stream buffer.

Return Value

An instance of TVOAudioFormat, which is immutable once created. Returns nil if one or more parameters passed to the initializer are not supported by the SDK.

Discussion

TVOAudioFormat describes signed 16-bit LPCM audio. This is the working format used to interoperate between TVOAudioDevice and the underlying media engine. Please note that the media engine may be forced to perform a format conversion depending on the codecs used for sending and receiving audio. For example, ISAC accepts mono 32 kHz audio while OPUS accepts mono or stereo at 48 kHz.

See Also

Declared In

TVOAudioFormat.h

– bufferSize

Computes the required buffer size for a given audio format.

- (size_t)bufferSize

Return Value

The required buffer size, in bytes, to work with a given TVOAudioFormat.

Discussion

This helper method can be used to size audio buffers appropriately.

Declared In

TVOAudioFormat.h

– streamDescription

Generates an audio stream description which can be used with CoreAudio.

- (AudioStreamBasicDescription)streamDescription

Return Value

An AudioStreamBasicDescription which reflects the properties of the TVOAudioFormat being queried.

Discussion

AudioStreamBasicDescription can be used to describe many different constant bitrate audio formats. Since TVOAudioFormat defines only signed 16-bit LPCM audio there is a well known transformation between the two.

Declared In

TVOAudioFormat.h