AEAudioFileLoaderOperation Class Reference

Audio file loader operation. More...

#import <AEAudioFileLoaderOperation.h>

Inherits NSOperation.

Instance Methods

(id) - initWithFileURL:targetAudioDescription:
 Initializer.
 

Class Methods

(BOOL) + infoForFileAtURL:audioDescription:lengthInFrames:error:
 Get info for a file.
 

Properties

void(^ audioReceiverBlock )(AudioBufferList *audio, UInt32 lengthInFrames)
 A block to use to receive audio.
 
void(^ completedBlock )()
 
AudioBufferList * bufferList
 The loaded audio, once operation has completed, unless audioReceiverBlock is set.
 
UInt32 lengthInFrames
 The length of the audio file.
 
NSError * error
 The error, if one occurred.
 

Detailed Description

Audio file loader operation.

This in an NSOperation object that is used to load an arbitraty audio file into memory. Use it by creating an instance, passing in the file URL to the audio file, the audio description for the format you the loaded audio in, optionally setting a completion block, and adding the operation to an operation queue.

If you wish to load a file synchronously, then you can simply start the operation yourself, like so:

AEAudioFileLoaderOperation *operation = [[AEAudioFileLoaderOperation alloc] initWithFileURL:url
targetAudioDescription:audioDescription];
[operation start];
if ( operation.error ) {
// Load failed! Clean up, report error, etc.
} else {
// Load finished - grab the audio
_bufferList = operation.bufferList;
_lengthInFrames = operation.lengthInFrames;
}
[operation release]; // If not using ARC

Note that this class is not suitable for use with large audio files, which should be loaded incrementally as playback occurs.

Method Documentation

+ (BOOL) infoForFileAtURL: (NSURL *)  url
audioDescription: (AudioStreamBasicDescription *)  audioDescription
lengthInFrames: (UInt32 *)  lengthInFrames
error: (NSError **)  error 

Get info for a file.

Parameters
urlURL to the file
audioDescriptionOn output, if not NULL, will be filled with the file's audio description
lengthInFramesOn output, if not NULL, will indicated the file length in frames
errorIf not NULL, and an error occurs, this contains the error that occurred
Returns
YES if file info was loaded successfully
- (id) initWithFileURL: (NSURL *)  url
targetAudioDescription: (AudioStreamBasicDescription)  audioDescription 

Initializer.

Parameters
urlURL to the file to load
audioDescriptionThe target audio description

Property Documentation

- (void(^ audioReceiverBlock)(AudioBufferList *audio, UInt32 lengthInFrames))
readwritenonatomiccopy

A block to use to receive audio.

If this is set, then audio will be provided via this block as it is loaded, instead of stored within bufferList.

- (void(^ completedBlock)())
readwritenonatomiccopy
- (AudioBufferList*) bufferList
readnonatomicassign

The loaded audio, once operation has completed, unless audioReceiverBlock is set.

You are responsible for freeing both the memory pointed to by each mData pointer, as well as the buffer list itself. If an error occurred, this will be NULL.

- (UInt32) lengthInFrames
readnonatomicassign

The length of the audio file.

- (NSError*) error
readnonatomicstrong

The error, if one occurred.


The documentation for this class was generated from the following file: