AEAudioFileReader Class Reference

Audio file reader. More...

#import <AEAudioFileReader.h>

Inherits NSObject.

Instance Methods

(void) - cancel
 Cancel a load operation.
 

Class Methods

(BOOL) + infoForFileAtURL:audioDescription:length:error:
 Get info for a file.
 
(instancetype _Nonnull) + loadFileAtURL:targetAudioDescription:completionBlock:
 Load a file into memory all at once.
 
(instancetype _Nonnull) + readFileAtURL:targetAudioDescription:readBlock:completionBlock:
 Read file incrementally, with a read block.
 
(instancetype _Nonnull) + readFileAtURL:targetAudioDescription:readBlock:completionBlock:blockSize:
 Read file incrementally, with a read block and block size.
 

Detailed Description

Audio file reader.

This class is used to load an audio file. It can be used to either load an audio file completely into memory in a single operation, or to incrementally read pieces of the file.

Loading is done on a background thread.

Note that for live playback, you should use AEAudioFilePlayerModule.

Method Documentation

+ (BOOL) infoForFileAtURL: (NSURL *_Nonnull)  url
audioDescription: (AudioStreamBasicDescription *_Nullable)  audioDescription
length: (UInt32 *_Nullable)  lengthInFrames
error: (NSError *_Nullable *_Nullable)  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
+ (instancetype _Nonnull) loadFileAtURL: (NSURL *_Nonnull)  url
targetAudioDescription: (AudioStreamBasicDescription)  targetAudioDescription
completionBlock: (AEAudioFileReaderLoadBlock _Nonnull)  block 

Load a file into memory all at once.

Will load the entire file into memory in a background thread, then call the completion block on the main thread when finished.

Note that this is not suitable for large audio files, as the entire file will be loaded into memory.

Parameters
urlURL to the file to load
targetAudioDescriptionThe audio description for the loaded audio (e.g. AEAudioDescription)
blockBlock to call when load has finished
+ (instancetype _Nonnull) readFileAtURL: (NSURL *_Nonnull)  url
targetAudioDescription: (AudioStreamBasicDescription)  targetAudioDescription
readBlock: (AEAudioFileReaderIncrementalReadBlock _Nullable)  readBlock
completionBlock: (AEAudioFileReaderCompletionBlock _Nonnull)  completionBlock 

Read file incrementally, with a read block.

Will load the file incrementally, calling the reader block with fixed-size pieces of audio.

Parameters
urlURL to the file to load
targetAudioDescriptionThe audio description for the loaded audio (e.g. AEAudioDescription)
readBlockBlock to call for each segment of the file; will be called on a background thread
completionBlockBlock to call on main thread when read operation has completed, or an error occurs
+ (instancetype _Nonnull) readFileAtURL: (NSURL *_Nonnull)  url
targetAudioDescription: (AudioStreamBasicDescription)  targetAudioDescription
readBlock: (AEAudioFileReaderIncrementalReadBlock _Nullable)  readBlock
completionBlock: (AEAudioFileReaderCompletionBlock _Nonnull)  completionBlock
blockSize: (UInt32)  blockSize 

Read file incrementally, with a read block and block size.

Will load the file incrementally, calling the reader block with fixed-size pieces of audio that match the block size.

Parameters
urlURL to the file to load
targetAudioDescriptionThe audio description for the loaded audio (e.g. AEAudioDescription)
readBlockBlock to call for each segment of the file; will be called on a background thread
completionBlockBlock to call on main thread when read operation has completed, or an error occurs
blockSizeThe size of blocks to receive
- (void) cancel

Cancel a load operation.


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