iOS Guides | Samples

MonoTouch.AudioToolbox.AudioQueue Class

Base class for Input and Output audio queues.

See Also: AudioQueue

Syntax

public abstract class AudioQueue : IDisposable

Remarks

AudioQueues can be used to record audio from the system input devices into a stream, and to play back audio. They are responsible for encoding your audio when recording or decoding your compressed audio when playing back and interact directly with the audio hardware and decoding hardware where appropriate.

AudioQueue is a base class for both the InputAudioQueue which is used to record audio and the OutputAudioQueue which is used to playback audio. This class provides services to start, prime, stop, pause the queues as well as volume control, resource management and event notifications.

When you use AudioQueues, you must allocate buffers for playback or recording. You use the AudioQueue.AllocateBuffer method or the AudioQueue.AllocateBufferWithPacketDescriptors to allocate them and you use the AudioQueue.FreeBuffer to release them. You keep a collection of buffers around that the underlying hardware can use to either playback audio, or record into. As the buffers are used, a notification callback is invoked. In the OutputAudioQueue case, you connect to the OutputCompleted event to be notified when a buffer has been fully played back, and in the InputAudioQueue you use the InputCompleted event to be notified when a recording has fully utilized a buffer.

Unless otherwise specified, the callbacks for processing a filled audio buffer, or filling out an audio buffer are invoked on an AudioQueue thread. You can change this by providing an instance of the CFRunLoop that you want to use for processing the events in your queue.

When processing an input or output queue, you might want to listen to a few property changes raised by the queues during their processing (See the AudioToolBox.AudioQueueProperty for a list of events that you can listen to). To do this, use the AudioQueue.AddListener(AudioQueueProperty,AudioQueuePropertyChanged) method to add a listener and use the AudioQueue.RemoveListener(AudioQueueProperty,AudioQueuePropertyChanged) method to remove the listener.

You can see the StreamingAudio to see how to use AudioBuffers.

The various AudioQueue properties are exposed as high-level C# properties. In addition to the high-level properties, a low-level interface to the AudioQueue property system is exposed in case Apple introduces a new property that was not previously bound or if you need finer grained control. The low-level interface is provided by the GetProperty and SetProperty family of methods.

Related content

Requirements

Namespace: MonoTouch.AudioToolbox
Assembly: monotouch (in monotouch.dll)
Assembly Versions: 0.0.0.0

The members of MonoTouch.AudioToolbox.AudioQueue are listed below.

See Also: Object

Protected Fields

Public Properties

[read-only]
AudioStreamDescriptionAudioStreamBasicDescription.
[read-only]
AudioStreamPacketDescriptionAudioStreamBasicDescription. The audio queue's AudioStreamBasicDescription.
ChannelLayoutAudioChannelLayout. The audio queue channel layout.
[read-only]
ConverterErrorUInt32. Contains the most recent error generated in the audio queue's encoding or decoding process.
CurrentDeviceString. Unique identifier for the device associated with this Audio Queue.
[read-only]
CurrentLevelMeterAudioQueueLevelMeterState[]. Current Level meters, one per channel in the range zero (minimum) to one (maximum).
[read-only]
CurrentLevelMeterDBAudioQueueLevelMeterState[]. Current Level meters, one per channel in decibels.
[read-only]
CurrentTimeAudioTimeStamp. Returns the current time for the hardware device.
[read-only]
DecodeBufferSizeFramesInt32.
[read-only]
DeviceChannelsInt32.
EnableLevelMeteringBoolean. Enables level metering on the audio queue.
[read-only]
HandleIntPtr. Handle (pointer) to the unmanaged object representation.
HardwareCodecPolicyAudioQueueHardwareCodecPolicy.
[read-only]
IsRunningBoolean.
MagicCookieByte[]. Audio metadata required by certain formats.
[read-only]
MaximumOutputPacketSizeInt32.
PanSingle.
[read-only]
SampleRateDouble.
VolumeSingle. The volume
VolumeRampTimeSingle.

Public Methods

AddListener(AudioQueueProperty, AudioQueue+AudioQueuePropertyChanged) : AudioQueueStatus
Use this method to track changes to the audio queue properties.
AllocateBuffer(Int32, out AudioQueueBuffer*) : AudioQueueStatus
Allocates an audio buffer associated with this AudioQueue
AllocateBuffer(Int32, out IntPtr) : AudioQueueStatus
Allocates an audio buffer associated with this AudioQueue, used for fixed bit rate buffers.
AllocateBufferWithPacketDescriptors(Int32, Int32, out IntPtr) : AudioQueueStatus
Allocates an audio queue object for variable-bit-rate buffers.
CreateProcessingTap(AudioQueueProcessingTapCallback, AudioQueueProcessingTapFlags, out AudioQueueStatus) : AudioQueueProcessingTap
Obsolete, use CreateProcessingTap (AudioQueueProcessingTapDelegate, AudioQueueProcessingTapFlags, out AudioQueueStatus) instead.
CreateProcessingTap(AudioQueueProcessingTapDelegate, AudioQueueProcessingTapFlags, out AudioQueueStatus) : AudioQueueProcessingTap
Creates a processing tap in the AudioQueue.
CreateTimeline() : AudioQueueTimeline
Creates a timeline object that can be used to track discontinuities in the audio queue's audio.
Dispose()
Releases the resources used by the AudioQueue object.
Dispose(Boolean, Boolean)
Releases the resources used by the AudioQueue object.
EnqueueBuffer(AudioQueueBuffer*, AudioStreamPacketDescription[]) : AudioQueueStatus
Adds a buffer to the buffer queue of an audio queue.
EnqueueBuffer(IntPtr, AudioStreamPacketDescription[]) : AudioQueueStatus
EnqueueBuffer(IntPtr, Int32, AudioStreamPacketDescription[]) : AudioQueueStatus
Adds a buffer to the buffer queue of an audio queue.
EnqueueBuffer(AudioQueueBuffer*, Int32, AudioStreamPacketDescription[], Int32, Int32, AudioQueueParameterEvent[], out AudioTimeStamp) : AudioQueueStatus
Adds a buffer that should play as soon as possible to the buffer queue of a playback audio queue.
EnqueueBuffer(IntPtr, Int32, AudioStreamPacketDescription[], Int32, Int32, AudioQueueParameterEvent[], out AudioTimeStamp) : AudioQueueStatus
Adds a buffer that should play as soon as possible to the buffer queue of a playback audio queue.
EnqueueBuffer(AudioQueueBuffer*, Int32, AudioStreamPacketDescription[], Int32, Int32, AudioQueueParameterEvent[], ref AudioTimeStamp, out AudioTimeStamp) : AudioQueueStatus
Adds a buffer to the buffer queue of a playback audio queue, specifying start time and parameters.
EnqueueBuffer(IntPtr, Int32, AudioStreamPacketDescription[], Int32, Int32, AudioQueueParameterEvent[], ref AudioTimeStamp, out AudioTimeStamp) : AudioQueueStatus
Adds a buffer to the buffer queue of a playback audio queue, specifying start time and parameters.
static
FillAudioData(IntPtr, Int32, IntPtr, Int32, Int32)
Copies raw audio data contained at the location pointed to by source+sourceOffset at the specified offset into the AudioQueueBuffer.
Finalize()
Finalizer for the AudioQueue object
Flush() : AudioQueueStatus
FreeBuffer(IntPtr)
Releases an AudioQueue buffer.
GetCurrentTime(AudioQueueTimeline, ref AudioTimeStamp, ref Boolean) : AudioQueueStatus
Returns the current time for the audio queue.
GetNearestStartTime(AudioTimeStamp) : AudioTimeStamp
GetProperty(AudioQueueProperty, out Int32) : IntPtr
Low-level API to fetch AudioQueue properties.
GetProperty(AudioQueueProperty, ref Int32, IntPtr) : Boolean
Low-level API to fetch AudioQueue properties.
GetProperty<T>(AudioQueueProperty) : T
Low-level API to fetch AudioQueue properties.
Pause() : AudioQueueStatus
Prime(Int32, out Int32) : AudioQueueStatus
Used to prepare the audio buffers to play back and ensure that there is data ready to be played by the audio hardware.
QueueDispose()
RemoveListener(AudioQueueProperty, AudioQueue+AudioQueuePropertyChanged)
Reset() : AudioQueueStatus
SetChannelAssignments(params AudioQueueChannelAssignment[]) : AudioQueueStatus
SetProperty(AudioQueueProperty, Int32, IntPtr) : Boolean
Start() : AudioQueueStatus
Starts the audio queue.
Start(AudioTimeStamp) : AudioQueueStatus
Stop(Boolean) : AudioQueueStatus
Stops the AudioQueue.
TranslateTime(AudioTimeStamp) : AudioTimeStamp