iOS音頻開發之`AudioStreamBasicDescription`,ios音視頻開發
這個類提供了對於音頻檔案的描述
An audio stream is a continuous series of data that represents a sound, such as a song.
A channel is a discrete track of monophonic audio. A monophonic stream has one channel; a stereo stream has two channels.
A sample is single numerical value for a single audio channel in an audio stream.
A frame is a collection of time-coincident samples. For instance, a linear PCM stereo sound file has two samples per frame, one for the left channel and one for the right channel.
A packet is a collection of one or more contiguous frames. A packet defines the smallest meaningful set of frames for a given audio data format, and is the smallest data unit for which time can be measured. In linear PCM audio, a packet holds a single frame. In compressed formats, it typically holds more; in some formats, the number of frames per packet varies.
The sample rate for a stream is the number of frames per second of uncompressed (or, for compressed formats, the equivalent in decompressed) audio.
首先,音頻檔案的產生是類比訊號->PCM以後的數字訊號->壓縮、編碼以後的音頻檔案。
PCM時採樣頻率叫做sample rate。
每一次採樣可以得到若干採樣資料,對應多個channel。
每一個採樣點得到的若干採樣資料群組合起來,叫做一個frame。
若干frame組合起來叫做一個packet。
mSampleRate,就是採用頻率
mBitsPerChannel,就是每個採樣資料的位元
mChannelsPerFrame,可以理解為聲道數,也就是一個採樣時刻產生幾個採樣資料。
mFramesPerPacket,就是每個packet的中frame的個數,等於這個packet中經曆了幾次採樣間隔。
mBytesPerPacket,每個packet中資料的位元組數。
mBytesPerFrame,每個frame中資料的位元組數
計算公式