TVIAudioFormat Class Reference

Inherits from NSObject
Declared in TVIAudioFormat.h

Overview

TVIAudioFormat describes audio that is captured or rendered via a TVIAudioDevice. 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

TVIAudioFormat.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

TVIAudioFormat.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 10 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

TVIAudioFormat.h

– init

Developers shouldn’t use init to create TVIAudioFormat.

- (null_unspecified instancetype)init

Discussion

Use initWithChannels:sampleRate:framesPerBuffer: instead.

Declared In

TVIAudioFormat.h

– initWithChannels:sampleRate:framesPerBuffer:

Initializes an instance of TVIAudioFormat.

- (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 TVIAudioFormat, which is immutable once created. Returns nil if one or more parameters passed to the initializer are not supported by the SDK.

Discussion

TVIAudioFormat describes signed 16-bit LPCM audio. This is the working format used to interoperate between TVIAudioDevice 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

TVIAudioFormat.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 TVIAudioFormat.

Discussion

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

Declared In

TVIAudioFormat.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 TVIAudioFormat being queried.

Discussion

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

Declared In

TVIAudioFormat.h