AudioToolbox框架详细解析 (一) —— 基本概览

版本记录

版本号 时间
V1.0 2017.12.25

前言

AudioToolbox是专门处理声音的一个框架,AudioToolbox这个库是C的接口,偏向于底层,用于在线流媒体音乐的播放,可以调用该库的相关接口自己封装一个在线播放器类,接下来几篇我们就详细的解析一个这个框架。

Overview

首先看一下该框架的基本信息。

AudioToolbox框架详细解析 (一) —— 基本概览_第1张图片

录制或播放音频,转换格式,解析音频流以及配置音频会话。

AudioToolbox框架提供录制,回放和流解析的接口。 在iOS中,框架为管理音频会话提供了额外的接口。


框架基本

下面我们就看一下框架的基本情况。

AudioToolbox框架详细解析 (一) —— 基本概览_第2张图片

接着看一下API

/*!
    @file       AudioToolbox.h
    @framework  AudioToolbox.framework
    @copyright  (c) 2002-2015 by Apple, Inc., all rights reserved.
    @abstract   Umbrella header for AudioToolbox framework.
*/


#ifndef AudioToolbox_AudioToolbox_h
#define AudioToolbox_AudioToolbox_h

#define AUDIO_TOOLBOX_VERSION 1060

#include 
#include 
#if !defined(__COREAUDIO_USE_FLAT_INCLUDES__)
    #include 
    #include 
    #include 
    #include 
    #include 
    #include 
    #include 
    #include 
    #include 
    #include 
    #include 
    #include 
    #include 
    #include 
    #include 
    #include 

    #if !TARGET_OS_IPHONE
        // OS X only
        #include 
        #include 
        #include 
        #include 
        #include 
    #endif

    #ifdef __OBJC2__
        // iOS (all architectures), OS X 64-bit only
        #import 
        #import 
        #import 
    #endif

#else
    #include 
    #include 
    #include 
    #include 
    #include 
    #include 
    #include 
    #include 
    #include 
    #include 
    #include 
    #include 
    #include 
    #include 
    #include 
    #include 
    #include 

    #include 
    #include 
    #include 
    #include 
#endif

/*! @mainpage

    @section section_intro          Introduction

    The AudioUnit framework contains a set of related API's dealing with:
    
    - Audio components, providing various types of plug-in functionality.
    - Audio Units, audio processing plug-ins.
    - Audio codecs, plug-ins which decode and encode compressed audio.
    
    @section section_component      Audio Components
    
    See AudioComponent.h for API's to find and use audio components, as well as information
    on how audio components are packaged and built.
    
    In addition, `` provides a higher-level interface for
    finding audio unit components.
    
    See @ref AUExtensionPackaging and AUAudioUnitImplementation.h for information on creating
    version 3 audio units.
    
    @section section_audiounit      Audio Units
*/

#include 

CF_ASSUME_NONNULL_BEGIN

#if defined(__cplusplus)
extern "C"
{
#endif

// prints out the internal state of an object to stdio
extern void CAShow (void* inObject) 
                                            __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0);

// prints out the internal state of an object to the supplied FILE
extern void CAShowFile (void* inObject, FILE* inFile) 
                                            __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0);
    
#if !TARGET_OS_IPHONE
// this will return the name of a sound bank from a sound bank file
// the name should be released by the caller
struct FSRef;
extern OSStatus GetNameFromSoundBank (const struct FSRef *inSoundBankRef, CFStringRef __nullable * __nonnull outName)
                                            __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2,__MAC_10_5, __IPHONE_NA, __IPHONE_NA);
#endif

/*!
    @function       CopyNameFromSoundBank
     
    @discussion     This will return the name of a sound bank from a DLS or SF2 bank.
                    The name should be released by the caller.

    @param          inURL
                        The URL for the sound bank.
    @param          outName
                        A pointer to a CFStringRef to be created and returned by the function.
    @result         returns noErr if successful.
*/

extern OSStatus
CopyNameFromSoundBank (CFURLRef inURL, CFStringRef __nullable * __nonnull outName)
                                            __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_7_0);

/*!
    @function       CopyInstrumentInfoFromSoundBank
     
    @discussion     This will return a CFArray of CFDictionaries, one per instrument found in the DLS or SF2 bank.
                    Each dictionary will contain four items accessed via CFStringRef versions of the keys kInstrumentInfoKey_MSB,
                    kInstrumentInfoKey_LSB, kInstrumentInfoKey_Program, and kInstrumentInfoKey_Name.
                        MSB: An NSNumberRef for the most-significant byte of the bank number.  GM melodic banks will return 120 (0x78).
                             GM percussion banks will return 121 (0x79).  Custom banks will return their literal value.
                        LSB: An NSNumberRef for the least-significant byte of the bank number.  All GM banks will return
                             the bank variation number (0-127).
                        Program Number: An NSNumberRef for the program number (0-127) of an instrument within a particular bank.
                        Name: A CFStringRef containing the name of the instrument.
 
                    Using these MSB, LSB, and Program values will guarantee that the correct instrument is loaded by the DLS synth
                    or Sampler Audio Unit.
                    The CFArray should be released by the caller.

    @param          inURL
                        The URL for the sound bank.
    @param          outInstrumentInfo
                        A pointer to a CFArrayRef to be created and returned by the function.
    @result         returns noErr if successful.
*/

extern OSStatus CopyInstrumentInfoFromSoundBank (CFURLRef inURL, CFArrayRef __nullable * __nonnull outInstrumentInfo)
                                                        __OSX_AVAILABLE_STARTING(__MAC_10_8,__IPHONE_7_0);
    
#define kInstrumentInfoKey_Name     "name"
#define kInstrumentInfoKey_MSB      "MSB"
#define kInstrumentInfoKey_LSB      "LSB"
#define kInstrumentInfoKey_Program  "program"

#if defined(__cplusplus)
}
#endif

CF_ASSUME_NONNULL_END

#endif // AudioToolbox_AudioToolbox_h

框架详细

下面我们就看一下框架的详细情况。

1. Classes

  • AUAudioUnit

    • AUAudioUnit类定义了一个音频单元的主机接口。
  • AUAudioUnitBus

    • AUAudioUnitBus类定义音频单元上的输入或输出连接点。
  • AUAudioUnitBusArray

    • AUAudioUnitBusArray类定义音频单元输入或输出总线的容器。
  • AUAudioUnitPreset

    • AUAudioUnitPreset类描述audio unit开发人员提供的自定义参数设置的接口。 这些预设通常会产生有用的声音或起点。
  • AUAudioUnitV2Bridge

    • AUAudioUnitV2Bridge类将version 2 audio unit包装在AUAudioUnit子类中。
  • AUParameter

    • AUParameter对象表示单个音频单元audio unit参数。
  • AUParameterGroup

    • AUParameterGroup对象表示一组相关的音频单元参数。 一个参数组对于其子类是符合KVC的。
  • AUParameterNode

    • AUParameterNode对象表示音频单元参数树中的节点。 节点是AUParameterAUParameterGroup类的实例。
  • AUParameterTree

    • AUParameterTree对象是顶级group节点,代表所有音频单元的参数。 音频单元的参数被组织成一个包含组和参数的树(组可以嵌套)。

2. Protocols

  • AUAudioUnitFactory

    • 实现这个协议来创建一个version 3 audio unit
  • AUCocoaUIBase

3. Reference

  • Audio Converter Services
  • Audio File Services
  • Audio File Stream Services
  • Audio Format Services
  • Audio Queue Services
  • Audio Session Services
  • Audio Toolbox Debugging
  • Audio Unit Processing Graph Services
  • Extended Audio File Services
  • System Sound Services
  • AudioToolbox Structures
  • AudioToolbox Enumerations
  • AudioToolbox Constants
  • AudioToolbox Functions
  • AudioToolbox Data Types

后记

未完,待续~~~

AudioToolbox框架详细解析 (一) —— 基本概览_第3张图片

你可能感兴趣的:(AudioToolbox框架详细解析 (一) —— 基本概览)