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
sourceURLThe URL to convert
destinationURLThe destination URL
errorAn 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
sourceURLThe URL to convert
encoderThe encoder processing the decoded audio
errorAn 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
decoderThe decoder providing the audio to convert
destinationURLThe destination URL
errorAn 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
decoderThe decoder providing the audio to convert
encoderThe encoder processing the decoded audio
errorAn 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
sourceURLThe source URL
destinationURLThe 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
sourceURLThe source URL
destinationURLThe destination URL
errorAn 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
sourceURLThe source URL
encoderThe 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
sourceURLThe source URL
encoderThe encoder
errorAn 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
decoderThe decoder
destinationURLThe 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
decoderThe decoder
destinationURLThe destination URL
errorAn 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
decoderThe decoder
encoderThe 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
decoderThe decoder
encoderThe encoder
errorAn 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
decoderThe decoder
encoderThe encoder
intermediateFormatBlockAn 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.
errorAn 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
AVAudioConverterobject producing the intermediate PCM audioProperties such as
channelMap,dither,downmix,sampleRateConverterQuality,andsampleRateConverterAlgorithmmay 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
errorAn optional pointer to an \c NSError object to receive error information
Return Value
\c YES on success, \c NO otherwise
View on GitHub
SFBAudioConverter Class Reference