创建AVAudioPCMBuffer


    _audioFormat = [[AVAudioFormat alloc] initWithCommonFormat:AVAudioPCMFormatInt16 sampleRate:16000 channels:1 interleaved:false];

    NSData *data = [NSData dataWithContentsOfFile:@""]

    AVAudioPCMBuffer *pcmBuffer = [[AVAudioPCMBuffer alloc] initWithPCMFormat:_audioFormat frameCapacity:(uint32_t)(data.length) / _audioFormat.streamDescription->mBytesPerFrame];
    
    pcmBuffer.frameLength = pcmBuffer.frameCapacity;
    
    [data getBytes:*pcmBuffer.int16ChannelData length:data.length];

你可能感兴趣的:(创建AVAudioPCMBuffer)