SFBAudioConverter
@interface SFBAudioConverter : NSObject
An audio converter converts audio from one format to another through a PCM intermediate format.
An audio converter reads PCM audio from an audio decoder in the decoder’s processing format, converts that audio to an intermediate PCM format, and then writes the intermediate PCM audio to an audio encoder which performs the final conversion to the desired format.
The decoder’s processing format and intermediate format must both be PCM but do not have to have the same sample rate, bit depth, channel count, or channel layout.
AVAudioConverter
is used to convert from the decoder’s processing format
to the intermediate format, performing sample rate conversion and channel mapping as required.
-
Converts audio and writes to the specified URL
Note
The file type to create is inferred from the file extension of \c destinationURLDeclaration
Objective-C
+ (BOOL)convertFromURL:(nonnull NSURL *)sourceURL toURL:(nonnull NSURL *)destinationURL error:(NSError *_Nullable *_Nullable)error;
Parameters
sourceURL
The URL to convert
destinationURL
The destination URL
error
An optional pointer to an \c NSError object to receive error information
Return Value
\c YES on success, \c NO otherwise
-
Converts audio using \c encoder
Declaration
Objective-C
+ (BOOL)convertFromURL:(nonnull NSURL *)sourceURL usingEncoder:(nonnull id<SFBPCMEncoding>)encoder error:(NSError *_Nullable *_Nullable)error;
Parameters
sourceURL
The URL to convert
encoder
The encoder processing the decoded audio
error
An optional pointer to an \c NSError object to receive error information
Return Value
\c YES on success, \c NO otherwise
-
Converts audio from \c decoder and writes to the specified URL
Note
The file type to create is inferred from the file extension of \c destinationURLDeclaration
Objective-C
+ (BOOL)convertFromDecoder:(nonnull id<SFBPCMDecoding>)decoder toURL:(nonnull NSURL *)destinationURL error:(NSError *_Nullable *_Nullable)error;
Parameters
decoder
The decoder providing the audio to convert
destinationURL
The destination URL
error
An optional pointer to an \c NSError object to receive error information
Return Value
\c YES on success, \c NO otherwise
-
Converts audio from \c decoder using \c encoder
Declaration
Objective-C
+ (BOOL)convertFromDecoder:(nonnull id<SFBPCMDecoding>)decoder usingEncoder:(nonnull id<SFBPCMEncoding>)encoder error:(NSError *_Nullable *_Nullable)error;
Parameters
decoder
The decoder providing the audio to convert
encoder
The encoder processing the decoded audio
error
An optional pointer to an \c NSError object to receive error information
Return Value
\c YES on success, \c NO otherwise
-
Unavailable
Undocumented
Declaration
Objective-C
+ (instancetype)new NS_UNAVAILABLE;
-
Unavailable
Undocumented
Declaration
Objective-C
- (instancetype)init NS_UNAVAILABLE;
-
Returns an initialized \c SFBAudioConverter object for the given URLs or \c nil on failure
Declaration
Objective-C
- (nullable instancetype)initWithURL:(nonnull NSURL *)sourceURL destinationURL:(nonnull NSURL *)destinationURL;
Parameters
sourceURL
The source URL
destinationURL
The destination URL
Return Value
An initialized \c SFBAudioConverter object for the specified URLs, or \c nil on failure
-
Returns an initialized \c SFBAudioConverter object for the given URLs or \c nil on failure
Declaration
Objective-C
- (nullable instancetype)initWithURL:(nonnull NSURL *)sourceURL destinationURL:(nonnull NSURL *)destinationURL error:(NSError *_Nullable *_Nullable)error;
Parameters
sourceURL
The source URL
destinationURL
The destination URL
error
An optional pointer to a \c NSError to receive error information
Return Value
An initialized \c SFBAudioConverter object for the specified URLs, or \c nil on failure
-
Returns an initialized \c SFBAudioConverter object for the given URL and encoder or \c nil on failure
Declaration
Objective-C
- (nullable instancetype)initWithURL:(nonnull NSURL *)sourceURL encoder:(nonnull id<SFBPCMEncoding>)encoder;
Parameters
sourceURL
The source URL
encoder
The encoder
Return Value
An initialized \c SFBAudioConverter object for the specified URL and encoder, or \c nil on failure
-
Returns an initialized \c SFBAudioConverter object for the given URL and encoder or \c nil on failure
Declaration
Objective-C
- (nullable instancetype)initWithURL:(nonnull NSURL *)sourceURL encoder:(nonnull id<SFBPCMEncoding>)encoder error:(NSError *_Nullable *_Nullable)error;
Parameters
sourceURL
The source URL
encoder
The encoder
error
An optional pointer to a \c NSError to receive error information
Return Value
An initialized \c SFBAudioConverter object for the specified URL and encoder, or \c nil on failure
-
Returns an initialized \c SFBAudioConverter object for the given decoder and URL or \c nil on failure
Declaration
Objective-C
- (nullable instancetype)initWithDecoder:(nonnull id<SFBPCMDecoding>)decoder destinationURL:(nonnull NSURL *)destinationURL;
Parameters
decoder
The decoder
destinationURL
The destination URL
Return Value
An initialized \c SFBAudioConverter object for the specified decoder and URL, or \c nil on failure
-
Returns an initialized \c SFBAudioConverter object for the given decoder and URL or \c nil on failure
Declaration
Objective-C
- (nullable instancetype)initWithDecoder:(nonnull id<SFBPCMDecoding>)decoder destinationURL:(nonnull NSURL *)destinationURL error:(NSError *_Nullable *_Nullable)error;
Parameters
decoder
The decoder
destinationURL
The destination URL
error
An optional pointer to a \c NSError to receive error information
Return Value
An initialized \c SFBAudioConverter object for the specified decoder and URL, or \c nil on failure
-
Returns an initialized \c SFBAudioConverter object for the given decoder and encoder or \c nil on failure
Declaration
Objective-C
- (nullable instancetype)initWithDecoder:(nonnull id<SFBPCMDecoding>)decoder encoder:(nonnull id<SFBPCMEncoding>)encoder;
Parameters
decoder
The decoder
encoder
The encoder
Return Value
An initialized \c SFBAudioConverter object for the specified decoder and encoder, or \c nil on failure
-
Returns an initialized \c SFBAudioConverter object for the given decoder and encoder or \c nil on failure
Declaration
Objective-C
- (nullable instancetype)initWithDecoder:(nonnull id<SFBPCMDecoding>)decoder encoder:(nonnull id<SFBPCMEncoding>)encoder error:(NSError *_Nullable *_Nullable)error;
Parameters
decoder
The decoder
encoder
The encoder
error
An optional pointer to a \c NSError to receive error information
Return Value
An initialized \c SFBAudioConverter object for the specified decoder and encoder, or \c nil on failure
-
Returns an initialized \c SFBAudioConverter object for the given decoder and encoder or \c nil on failure
Declaration
Objective-C
- (nullable instancetype)initWithDecoder:(nonnull id<SFBPCMDecoding>)decoder encoder:(nonnull id<SFBPCMEncoding>)encoder requestedIntermediateFormat: (nullable AVAudioFormat *_Nonnull (^)(AVAudioFormat *_Nonnull)) intermediateFormatBlock error:(NSError *_Nullable *_Nullable)error;
Parameters
decoder
The decoder
encoder
The encoder
intermediateFormatBlock
An optional block to receive the proposed intermediate format and return the requested intermediate format. A change in intermediate format allows operations such as sample rate conversion or channel mapping.
error
An optional pointer to a \c NSError to receive error information
Return Value
An initialized \c SFBAudioConverter object for the specified decoder and encoder, or \c nil on failure
-
The decoder supplying the audio to be converted
Declaration
Objective-C
@property (nonatomic, readonly) id<SFBPCMDecoding> _Nonnull decoder;
-
The
AVAudioConverter
object producing the intermediate PCM audioProperties such as
channelMap,
dither,
downmix,
sampleRateConverterQuality,
andsampleRateConverterAlgorithm
may be set before conversion.Declaration
Objective-C
@property (nonatomic, readonly) AVAudioConverter *_Nonnull intermediateConverter;
-
The encoder receving the intermediate audio for encoding
Declaration
Objective-C
@property (nonatomic, readonly) id<SFBPCMEncoding> _Nonnull encoder;
-
Converts audio
Declaration
Objective-C
- (BOOL)convertReturningError:(NSError *_Nullable *_Nullable)error;
Parameters
error
An optional pointer to an \c NSError object to receive error information
Return Value
\c YES on success, \c NO otherwise