Audio Queue

Audio Queue

Change AudioQueueEnqueueBuffer to AudioQueueEnqueueBufferWithParameters with an AudiTimeStamp argument.

Source code

The second argument of the function AudioQueueStart is a pointer to an AudioTimeStamp which specifies exactly when the playback will begin.

  1. Queue.zip
  2. main.m
  3. Class QueueAppDelegate
  4. Class View

Create the project

  1. To create the .h and .m files for class View,
    File → New File…
    Choose a template for your new file: Objective-C class
    Subclass of UIView
    Next
    File Name: View
    also create "View.h"
    Finish

  2. Project → Edit Active Target “Queue” → General → Linked Libraries
    Press + to add AudioToolbox.framework.
    Add

Audio Queue Links

  1. Audio Queue Services Programing Guide. I had to make two changes to get the example code to run.
    1. To compile the code in Objective C, not in C++, the second argument of the function DeriveBufferSize and the first argument of the other function DeriveBufferSize had to be pointers, not references.
    2. In the play method of class view, I had to set aqPlayerData.mIsRunning = true; immediately before the for loop that calls HandleOutputBuffer.
  2. Audio Queue Services Reference: list of functions.
  3. SpeakHere: a project with sample code.
    Project → Edit Project Settings → Build → Base SDK → iPhone Device 4.0
    Simulator - 4.0 | Debug | SpeakHere