audio、video、image音频处理iOS MultiMedia

iOS音频开发学习

2015-12-29  本文已影响2717人  zjunchao

音频基础

iOS 开发中对应的结构

AudioStreamBasicDescription 结构体

struct AudioStreamBasicDescription
{
    Float64             mSampleRate;
    AudioFormatID       mFormatID;
    AudioFormatFlags    mFormatFlags;
    UInt32              mBytesPerPacket;
    UInt32              mFramesPerPacket;
    UInt32              mBytesPerFrame;
    UInt32              mChannelsPerFrame;
    UInt32              mBitsPerChannel;
    UInt32              mReserved;
};

mSampleRate:The number of frames per second of the data in the stream.

mFormatID:An identifier specifying the general audio data format in the stream. (kAudioFormatLinearPCM, etc.)

mFormatFlags:Format-specific flags to specify details of the format.(kLinearPCMFormatFlagIsSignedInteger, kLinearPCMFormatFlagIsFloat, kLinearPCMFormatFlagIsBigEndian, kLinearPCMFormatFlagIsPacked, kLinearPCMFormatFlagIsNonInterleaved, etc.)

mBytesPerPacket:The number of bytes in a packet of data
mFramesPerPacket:The number of sample frames in each packet of data.
mBytesPerFrame:The number of bytes in a single sample frame of data.
mChannelsPerFrame:The number of channels in each frame of data
mBitsPerChannel:The number of bits of sample data for each channel in a frame of data.

数据样例

(AudioStreamBasicDescription) _format = {
  mSampleRate = 44100 
  mFormatID = kAudioFormatLinearPCM 
  mFormatFlags = kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked 
  mBytesPerPacket = 1 
  mFramesPerPacket = 1152 
  mBytesPerFrame = 0 
  mChannelsPerFrame = 2 
  mBitsPerChannel = 0 
  mReserved = 0 
} 

iOS音频框架

苹果提供的处理音频的系统框架

  1. Extended Audio File Services有一些API,可用帮你计算每个包的大小;
  2. Audio File Service或Audio File Stream Services更智能,你只管塞数据给它,它自动把包组好给你。
  3. 在ffmpeg软解播放器中可以使用Auido Queue实现音频播放。
上一篇下一篇

猜你喜欢

热点阅读