MTCoreAudioStreamDescription
Conforms to: NSCopying
An MTCoreAudioStreamDescription encapsulates a CoreAudio
AudioStreamBasicDescription,
which describes the audio data
format associated with an audio device and its streams.
Method Types
- Creating instances
- Descriptive summary
- Working with attributes
- Working with format flags
Class Methods
+ (MTCoreAudioStreamDescription *) nativeStreamDescription
Creates and returns a new MTCoreAudioStreamDescription configured for the canonical logical stream format (32-bit floating point, native endian, packed linear PCM, 1 frame per packet, interleaved), with zero channels and sample rate of zero Hz.
+ (MTCoreAudioStreamDescription *) streamDescription
Creates and returns a new, empty MTCoreAudioStreamDescription,
with linear PCM format and all other attributes set to 0. Note that although any field set
to 0 is supposed to be ignored,
kMTCoreAudioStreamPhysicalSides
may not like 0 attributes. Use
matchStreamDescription:forSide:
(MTCoreAudioStream) when constructing
an MTCoreAudioDescription for use on kMTCoreAudioStreamPhysicalSides.
+ (MTCoreAudioStreamDescription *) streamDescriptionWithAudioStreamBasicDescription:(AudioStreamBasicDescription)theDescription
Creates and returns an MTCoreAudioStreamDescription with its attributes
taken directly from theDescription.
Instance Methods
- (AudioStreamBasicDescription) audioStreamBasicDescription
Returns an AudioStreamBasicDescription
corresponding to the attributes of the instance.
- (UInt32) bitsPerChannel
Gets the number of bits per channel. For
kMTCoreAudioStreamLogicalSide,
this is always 32.
- (NSBundle *) bundleForDescriptionStrings
Returns the bundle containing the localized strings to use in constructing a textual description of the receiver. The default implementation returns the bundle in which class MTCoreAudioStreamDescription
is defined. Subclasses may override this method to indicate that a different bundle contains a StreamDescription.strings
file for use by description.
- (UInt32) bytesPerFrame
Gets the number of bytes per frame. One frame represents one sample from
each channel at one instant in time.
- (UInt32) bytesPerPacket
Gets the number of bytes per packet. See
CoreAudioTypes.h
for more information.
- (UInt32) channelsPerFrame
Gets the number of channels in one frame. A stream's audio data is a time-regular linear
sequence of frames, where each frame consists of one sample from each channel
in the stream at one instant in time.
- (NSString *) description
Returns a human-readable description of the attributes of
the MTCoreAudioStreamDescription. When the format is "lpcm 32-bit floating-point big-endian packed",
the "floating-point big-endian packed" part is not included.
- (UInt32) formatFlags
Gets the format flags. See
CoreAudioTypes.h
for more information.
- (UInt32) formatID
Returns the four-character-code identifying the audio data format. Usually 'lpcm'
(kAudioFormatLinearPCM).
- (UInt32) framesPerPacket
Gets the number of frames per packet. See
CoreAudioTypes.h
for more information.
- (MTCoreAudioStreamDescription *) init
Initializes a newly allocated instance with linear PCM format and all other attributes 0.
See class method streamDescription for more information.
- (MTCoreAudioStreamDescription *) initWithAudioStreamBasicDescription:(AudioStreamBasicDescription)theDescription
Initializes a new instance with its attributes taken directly from theDescription.
- (Boolean) isCanonicalFormat
Returns YES
if the receiver is in the canonical logical format (32-bit floating point, native endian, packed linear PCM, 1 frame per packet, interleaved or non-interleaved), and NO
otherwise. Note that the native logical format is the interleaved canonical format.
- (Boolean) isInterleaved
If the receiver's format is Linear PCM, returns YES
if samples for multiple channels are interleaved in the same buffer, and NO
if there is a separate buffer for each channel (de-interleaved). The result of this method is undefined if the format is not Linear PCM.
- (Boolean) isLinearPCMFormat
Returns YES
if the receiver's format is Linear Pulse Code Modulation (integer or floating point), and NO
otherwise.
- (Boolean) isNativeFormat
Returns YES
if the receiver is in the native logical format (32-bit floating point, native endian, packed linear PCM, 1 frame per packet, interleaved), and NO
otherwise.
- (Float32) sampleRate
Returns the sample rate in Hertz. If the sample rate is 0.0 in an instance obtained from
streamDescriptionsForChannel:forDirection:
(MTCoreAudioDevice) or
streamDescriptionsForSide:
(MTCoreAudioStream)
, that means any sample rate is supported. The device should always have a non-zero
sample rate set.
- (MTCoreAudioStreamDescription *) setBitsPerChannel:(UInt32)theBitsPerChannel
Sets the number of bits per channel.
Returns the receiver.
- (MTCoreAudioStreamDescription *) setBytesPerFrame:(UInt32)theBytesPerFrame
Sets the number of bytes per frame. One frame represents one sample from
each channel at one instant in time.
Returns the receiver.
- (MTCoreAudioStreamDescription *) setBytesPerPacket:(UInt32)theBytesPerPacket
Sets the number of bytes per packet. See
CoreAudioTypes.h
for more information.
Returns the receiver.
- (MTCoreAudioStreamDescription *) setChannelsPerFrame:(UInt32)theChannelsPerFrame
Sets the number of channels in one frame. A stream's audio data is a time-regular linear
sequence of frames, where each frame consists of one sample from each channel
in the stream at one instant in time. If the stream format is the canonical logical format,
then the bytes per frame and bytes per packet are updated as well.
Returns the receiver.
- (MTCoreAudioStreamDescription *) setFormatFlags:
Sets the format flags. See
CoreAudioTypes.h
for more information.
Returns the receiver.
- (MTCoreAudioStreamDescription *) setFormatID:(UInt32)theFormatID
Sets the four-character-code identifying the audio data format.
See formatID for more information.
Returns the receiver.
- (MTCoreAudioStreamDescription *) setFramesPerPacket:(UInt32)theFramesPerPacket
Sets the number of frames per packet. See
CoreAudioTypes.h
for more information.
Returns the receiver.
- (MTCoreAudioStreamDescription *) setIsInterleaved:(Boolean)interleave
If the receiver's format is Linear PCM, sets whether samples for multiple channels are interleaved in the same buffer or kept in separate buffers (de-interleaved).
If the stream format is the canonical logical format,
then the bytes per frame and bytes per packet are updated as well.
Has no effect if the format is not Linear PCM.
Returns the receiver.
- (MTCoreAudioStreamDescription *) setNativeFormat
Sets the receiver to the canonical logical format (32-bit floating point, native endian, packed linear PCM, 1 frame per packet, interleaved).
Sets the bytes per frame and bytes per packet based on the number of channels per frame.
Returns the receiver.
- (MTCoreAudioStreamDescription *) setSampleRate:(Float32)theSampleRate;
Sets the sample rate. The device should always have a non-zero sample rate.
Returns the receiver.
Mike >
Mac OS X >
MTCoreAudio.framework >
MTCoreAudioStreamDescription