AEUtilities.h File Reference
#import <Foundation/Foundation.h>
#import <AudioToolbox/AudioToolbox.h>
#import "AETypes.h"

Go to the source code of this file.

Macros

#define AECheckOSStatus(result, operation)   (_AECheckOSStatus((result),(operation),strrchr(__FILE__, '/')+1,__LINE__))
 Check an OSStatus condition.
 

Functions

AudioComponentDescription AEAudioComponentDescriptionMake (OSType manufacturer, OSType type, OSType subtype)
 Create an AudioComponentDescription structure.
 
BOOL AERateLimit (void)
 Rate limit an operation.
 
void AEError (OSStatus result, const char *_Nonnull operation, const char *_Nonnull file, int line)
 An error occurred within AECheckOSStatus.
 
ExtAudioFileRef _Nullable AEExtAudioFileCreate (NSURL *_Nonnull url, AEAudioFileType fileType, double sampleRate, int channelCount, NSError *_Nullable *_Nullable error)
 Initialize an ExtAudioFileRef for writing to a file.
 
ExtAudioFileRef _Nullable AEExtAudioFileOpen (NSURL *_Nonnull url, AudioStreamBasicDescription *_Nullable outAudioDescription, UInt64 *_Nullable outLengthInFrames, NSError *_Nullable *_Nullable error)
 Open an audio file for reading.
 

Macro Definition Documentation

#define AECheckOSStatus (   result,
  operation 
)    (_AECheckOSStatus((result),(operation),strrchr(__FILE__, '/')+1,__LINE__))

Check an OSStatus condition.

Parameters
resultThe result
operationA description of the operation, for logging purposes

Function Documentation

AudioComponentDescription AEAudioComponentDescriptionMake ( OSType  manufacturer,
OSType  type,
OSType  subtype 
)

Create an AudioComponentDescription structure.

Parameters
manufacturerThe audio component manufacturer (e.g. kAudioUnitManufacturer_Apple)
typeThe type (e.g. kAudioUnitType_Generator)
subtypeThe subtype (e.g. kAudioUnitSubType_AudioFilePlayer)
Returns
An AudioComponentDescription structure with the given attributes
BOOL AERateLimit ( void  )

Rate limit an operation.

This can be used to prevent spamming error messages to the console when something goes wrong.

void AEError ( OSStatus  result,
const char *_Nonnull  operation,
const char *_Nonnull  file,
int  line 
)

An error occurred within AECheckOSStatus.

Create a symbolic breakpoint with this function name to break on errors.

ExtAudioFileRef _Nullable AEExtAudioFileCreate ( NSURL *_Nonnull  url,
AEAudioFileType  fileType,
double  sampleRate,
int  channelCount,
NSError *_Nullable *_Nullable  error 
)

Initialize an ExtAudioFileRef for writing to a file.

This provides a simple way to create an audio file writer, initialised appropriately for the given file type. To begin recording asynchronously, you should use ExtAudioFileWriteAsync(audioFile, 0, NULL); to prime asynchronous recording. For writing on the main thread, use ExtAudioFileWrite.

Finish writing and close the file by using ExtAudioFileDispose once you are done.

Use this function only on the main thread.

Parameters
urlURL to the file to write to
fileTypeThe type of the file to write
sampleRateSample rate to use for input & output
channelCountNumber of channels for input & output
errorIf not NULL, the error on output
Returns
The initialized ExtAudioFileRef, or NULL on error
ExtAudioFileRef _Nullable AEExtAudioFileOpen ( NSURL *_Nonnull  url,
AudioStreamBasicDescription *_Nullable  outAudioDescription,
UInt64 *_Nullable  outLengthInFrames,
NSError *_Nullable *_Nullable  error 
)

Open an audio file for reading.

This utility creates a new reader instance, and returns the reader, the client format AudioStreamBasicDescription used for reading, and the total length in frames, both usually useful for operating on files.

It will be configured to use the standard AEAudioDescription format, with the channel count and sample rate determined by the file format - this configured format is returned via the outAudioDescription parameter. Use kExtAudioFileProperty_ClientDataFormat to change this if required.

Parameters
urlURL to the file to read from
outAudioDescriptionOn output, the AEAudioDescription-derived stream format for reading (the client format)
outLengthInFramesOn output, the total length in frames
errorIf not NULL, the error on output
Returns
The initialized ExtAudioFileRef, or NULL on error