zoukankan      html  css  js  c++  java
  • Multimedia Programming Guide & Audio 不及格的程序员

    iOS offers a rich set of tools for working with sound in your application.
    These tools are arranged into frameworks according to the features they provide, as follows:

     ■ Use theMedia Player framework to play songs, audio books, or audio podcasts froma user’s iPod library.
      For details, seeMedia Player Framework Reference, iPod LibraryAccess ProgrammingGuide, and the AddMusic sample code project.

     ■ Use the AV Foundation framework to play and record audio using a simple Objective-C interface.
       For details, see AV Foundation Framework Reference and the avTouch sample code project.

     ■ Use the Audio Toolbox framework to play audio with synchronization capabilities, access packets of incoming audio, parse audio streams,
       convert audio formats, and record audio with access to individual packets.
       For details, see Audio Toolbox Framework Reference and the SpeakHere sample code project.

     ■ Use the Audio Unit framework to connect to and use audio processing plug-ins. For details, see Audio Unit Hosting Guide for iOS.

     ■ Use the OpenAL framework to provide positional audio playback in games and other applications.
       iOS supports OpenAL 1.1. For information on OpenAL, see the OpenAL website, OpenAL FAQ for iPhone OS,and the oalTouch sample code project.

    1 Playing Media Items with iPod Library Access

    2 Playing UI Sound Effects or Invoking Vibration Using System Sound Services (require Audio Toolbox framework)


    To play user-interface sound effects (such as button clicks), or to invoke vibration on devices that support it,
    use System Sound Services. This compact interface is described in System Sound Services Reference.
    You can find sample code in the Audio UI Sounds (SysSound) sample in the iOS Dev Center.
    Note:  Sounds played with System Sound Services are not subject to configuration using your audio session.
    As a result, you cannot keep the behavior of System Sound Services audio in line with other audio behavior
    in your application. This is the most important reason to avoid using System Sound Services for any audio
    apart from its intended uses.
    The AudioServicesPlaySystemSound function lets you very simply play short sound files. The simplicity
    carries with it a few restrictions. Your sound files must be:
       ■ No longer than 30 seconds in duration
       ■ In linear PCM or IMA4 (IMA/ADPCM) format
       ■ Packaged in a .caf, .aif, or .wav file

    In addition, when you use the AudioServicesPlaySystemSound function:
       ■ Sounds play at the current system audio volume, with no programmatic volume control available
       ■ Sounds play immediately
       ■ Looping and stereo positioning are unavailable
       ■ Simultaneous playback is unavailable: You can play only one sound at a time
    The similar AudioServicesPlayAlertSound function plays a short sound as an alert. If a user has configured
    their device to vibrate in Ring Settings, calling this function invokes vibration in addition to playing the sound
    file.

    3 Playing Sounds Easily with the AVAudioPlayer Class
    The AVAudioPlayer class provides a simple Objective-C interface for playing sounds. If your application
    does not require stereo positioning or precise synchronization, and if you are not playing audio captured
    from a network stream, Apple recommends that you use this class for playback.
    Using an audio player you can:
       ■ Play sounds of any duration
       ■ Play sounds from files or memory buffers
       ■ Loop sounds
       ■ Play multiple sounds simultaneously (although not with precise synchronization)
       ■ Control relative playback level for each sound you are playing
       ■ Seek to a particular point in a sound file, which supports application features such as fast forward and rewind
       ■ Obtain audio power data that you can use for audio level metering

     4 Playing Sounds with Control Using Audio Queue Services Audio Queue Services adds playback capabilities beyond those available with the AVAudioPlayer class.
      Using Audio Queue Services for playback lets you:
       ■ Precisely schedule when a sound plays, allowing synchronization
       ■ Precisely control volume on a buffer-by-buffer basis
       ■ Play audio that you have captured from a stream using Audio File Stream Services

     

    5 Playing Sounds with Positioning Using OpenAL

    The open-sourced OpenAL audio API, available in iOS in the OpenAL framework, provides an interface
    optimized for positioning sounds in a stereo field during playback. Playing, positioning, and moving sounds
    works just as it does on other platforms. OpenAL also lets you mix sounds. OpenAL uses the I/O unit for
    playback, resulting in the lowest latency.

    For all of these reasons, OpenAL is your best choice for playing sounds in game applications on iOS-based
    devices. However, OpenAL is also a good choice for general iOS application audio playback needs.

    南来地,北往的,上班的,下岗的,走过路过不要错过!

    ======================个性签名=====================

    之前认为Apple 的iOS 设计的要比 Android 稳定,我错了吗?

    下载的许多客户端程序/游戏程序,经常会Crash,是程序写的不好(内存泄漏?刚启动也会吗?)还是iOS本身的不稳定!!!

    如果在Android手机中可以简单联接到ddms,就可以查看系统log,很容易看到程序为什么出错,在iPhone中如何得知呢?试试Organizer吧,分析一下Device logs,也许有用.

    我的开发工具

    对于博客园里的网友,不敢称为叫"程序员"的人,你们攻击性太强,看来你们是不会想到我的用意的.园子里有不少人都非常喜欢Jeffrey,是因为它的第一版 框架设计 CLR via C#.
    可是从第一版到现在的第三版,没有看到真正底层的东西,内容仅仅是比MSDN文档更丰富一些,可能是我的要求太高了吧.
    也就是因为它很多时候会接触到微软开发人员,会经常聊聊某些问题而已,而它又将这些问题反应到书中.也许它就像一个小记者.
    它的年龄大我们不多,我的孩子与它小儿子一般大,如果我能向它那样出入微软与它们开发人员长时间交流,不仅仅会牛成它这样.....
    可是微软的开发人员不会扔太多时间在它这儿的.所以它会整天追着这个,赶它那个..屁颠个不停吧...
    而它的另一版被称为好书的 Windows核心编程,更是没有什么深度可言,仅仅是将windows提供的api,以及内核功能再重申了一遍.
    这些书对晋及编程知识是有些贡献的,再说一遍我不是在匾低谁,说说想法而已.

  • 相关阅读:
    浅析 KMP
    【GOJ 3049】玩具
    较详细的gdb入门教程
    【GOJ 2963】记者
    【GOJ 2961】数数
    GF OIer's Talk 维护笔记
    Linux 中 UFW 的使用
    开源是什么?能吃吗?
    个人介绍
    NOIP2020 爆零记
  • 原文地址:https://www.cnblogs.com/ioriwellings/p/2149123.html
Copyright © 2011-2022 走看看