AVAudioFile
是音频的为读和写的一个类,不管文件的实际格式是什么,读写文件都是通过
AVAudioPCMBuffer
对象,包含AVAudioCommonFormat
的样本,称为文件的“处理格式”。执行to和from的转换文件的实际格式。 读和写始终是顺序的,但是可以通过设置 framePosition
进行。
@interface AVAudioFile : NSObject {
@private
void *_impl;
}
/*! @method initForReading:error:
@abstract Open a file for reading.
为读或写而打开的音频文件
@param fileURL
the file to open
@param outError
on exit, if an error occurs, a description of the error
@discussion
This opens the file for reading using the standard format (deinterleaved floating point).
*/
- (nullable instancetype)initForReading:(NSURL *)fileURL error:(NSError **)outError;
/*! @method readIntoBuffer:error:
@abstract Read an entire buffer.
@param buffer
要从文件中读取的缓冲区。它的格式必须与文件的格式匹配
处理格式
@param outError
on exit, if an error occurs, a description of the error
@return
YES for success.
@discussion
Reading sequentially from framePosition, attempts to fill the buffer to its capacity. On
return, the buffer's length indicates the number of sample frames successfully read.
*/
- (BOOL)readIntoBuffer:(AVAudioPCMBuffer *)buffer error:(NSError **)outError;
- (BOOL)readIntoBuffer:(AVAudioPCMBuffer *)buffer frameCount:(AVAudioFrameCount)frames error:(NSError **)outError;
/*! @property url
@abstract The URL the file is reading or writing.
*/
@property (nonatomic, readonly) NSURL *url;
/*! @property fileFormat
@abstract The on-disk format of the file.
文件在磁盘的格式
*/
@property (nonatomic, readonly) AVAudioFormat *fileFormat;
/*! @property processingFormat
@abstract The processing format of the file.
文件的处理格式。不同机型加载不同音频文件处理格式不同
*/
@property (nonatomic, readonly) AVAudioFormat *processingFormat;
/*! @property length
@abstract The number of sample frames in the file.
文件中本帧的数量
@discussion
Note: this can be expensive to compute for the first time.
*/
@property (nonatomic, readonly) AVAudioFramePosition length;
@end
网友评论