Coreaudio for iOS audio Development

Source: Internet
Author: User

 

Those who have been familiar with IOS audio development know that core audio is the basis for digital audio processing on iOS and Mac. It provides applications.ProgramA set of software frameworks used to process audio. All IOS audio development interfaces are provided by core audio or encapsulated by interfaces provided by it, according to the official statement, it is a professional technology that integrates playback and audio processing and recording. Through our program, we can record and play one or more audio streams at the same time to automatically adapt to the headset, bluetooth headsets and other hardware, response to various phone interruptions, mute, vibration, and so on, and even provide 3D effect music playing.

The core audio API structure is divided into three layers, for example:

 

 

 

 

The low-level layer is the API layer for hardware interfaces. This layer of APIS is mainly provided to MAC for writing interfaces that require real-time performance audio processing, generally, applications do not use this level of API. Core audio provides a higher level of API for IOS Mobile platform to process real-time audio. This API is more compact and efficient.

 

The mid-level layer provides complete functions, including audio data format conversion, audio file read/write, audio stream parsing, and plug-in support.

Audio convert Services API Converts audio data formats

 

Audio File Services API reads and writes audio data

Audio Unit services and Audio Processing Graph services support digital signal processing plug-ins such as balancer and mixer.

Audio File scream Services is responsible for stream Parsing

Core audio clock services synchronizes audio and audio clock

 

The high-level layer is a group of high-level applications combined from the lower-layer interfaces. Basically, many of our work on audio development can be completed at this layer.

Audio queue Services provides recording, playing, pausing, looping, and synchronizing audio. It automatically uses the necessary codecs to process compressed audio formats.

 

Avaudioplayer is an audio playback class based on the objective-C interface provided by the iOS platform. It supports playing all audio supported by IOS.

Openal is the implementation of coreaudio on the openal standard. It can play 3D sound mixing effects.

 

Coreaudio APIs are not encapsulated into a separate framework. Their interfaces are scattered across different frameworks. For example:

 

Audiotoolbox. FrameworkProvideCoreaudioOfAPIServices, we often dealAvaudiosessionClass is included in this library, used to process the application's control over the context of the audio device. It allows you to set the audio capability of a program, process calls and other high-priority speech processing, resulting in interruptions and recovery operations.

Audiounit. FrameworkThis library providesDSPPlug-ins related to digital signal processing, including coding/decoding, sound mixing, and audio balancing.

Avfoundation. FrameworkThis library provides a streamlined music playing class that can play allIOSSupported audio.

OPenal. Framework3D sound playback

Coreaudio is designed to manage and operate the status and behavior of audio objects through attribute pairs. We can see this way in various classes:

 

1. An Attribute key is usually an enumeration constant defined by a mnemonic name, such as kaudiofilepropertyfileformat or kaudioqueuedeviceproperty_numberchannels.

2. An attribute value is usually a specific data type suitable for describing this attribute, such as void *, afloat64, and an audiochannel data structure.

 

Coreaudio uses the access function to obtain the attribute value corresponding to the key. If the attribute value can be written, you can also use the key to modify the attribute of the key. Of course, coreaudio also provides common interfaces to obtain object values. For exampleKaudiosessionproperty_overridecategorydefaulttospeaker

Uint32 audiorouteoverride = kaudiosessionoverrideaudioroute_none;

Audiosessionsetproperty (kaudiosessionproperty_overridecategorydefatospeaker, sizeof (audiorouteoverride), & audiorouteoverride );

 

The coreaudio interface provides a callback mechanism to notify your application when a certain attribute of the audio object changes. When the application uses the audioqueue class to play music, it implements this callback function, and set it to the audioqueue object. Then, the audioqueue object calls this function after the audio playback operation is completed.

 
 

Typedef void (* audioqueuepropertylistenerproc )(

Void * inuserdata,

Audioqueueref inaq,

Audioqueuepropertyid inid

);

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.