美文网首页
5期_AVFoundation-AVAudioFile

5期_AVFoundation-AVAudioFile

作者: 萧修 | 来源:发表于2023-11-08 01:00 被阅读0次

    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
    

    相关文章

      网友评论

          本文标题:5期_AVFoundation-AVAudioFile

          本文链接:https://www.haomeiwen.com/subject/wcynidtx.html