iPhone-获取线性PCM音频文件的持续时间
我的应用程序中有一个线性PCM文件(.wav),我想通过编程获得它的持续时间。我可以使用AudioStreamBasicDescription找到以下内容,但无法确定如何以秒为单位获得持续时间iPhone-获取线性PCM音频文件的持续时间,iphone,core-audio,Iphone,Core Audio,我的应用程序中有一个线性PCM文件(.wav),我想通过编程获得它的持续时间。我可以使用AudioStreamBasicDescription找到以下内容,但无法确定如何以秒为单位获得持续时间 mFormatID mSampleRate mChannelsPerFrame mBytesPerPacket mFramesPerPacket mBytesPerFrame mBitsPerChannel 有人能告诉我怎样才能得到持续时间吗 谢谢。您可以使用文件创建AVAudioPlayer实例。AV
mFormatID
mSampleRate
mChannelsPerFrame
mBytesPerPacket
mFramesPerPacket
mBytesPerFrame
mBitsPerChannel
有人能告诉我怎样才能得到持续时间吗
谢谢。您可以使用文件创建AVAudioPlayer实例。AVAudioPlayer具有duration属性 您可以使用文件创建AVAudioPlayer实例。AVAudioPlayer具有duration属性 使用音频文件kAudioFilePropertyEstimatedDuration属性是最好的,但是如果您想了解PCM的数学:duration=totalNumpackes*ASBD.mFramesPerPacket/ASBD.mSampleRate使用音频文件kAudioFilePropertyEstimatedDuration属性是最好的,但是,如果您想要PCM的数学:duration=totalNumpackes*ASBD.mFramesPerPacket/ASBD.mSampleRateHmm。。。您可以使用AudioFileGetProperty方法并检查kAudioFilePropertyEstimatedDuration属性的值。对于PCM,获取kAudioFilePropertyEstimatedDuration应该会给您一个准确的持续时间,因为它是恒定的比特率,因此可以根据ASBD和样本数精确计算。。。您可以使用AudioFileGetProperty方法并检查kAudioFilePropertyEstimatedDuration属性的值。对于PCM,获取kAudioFilePropertyEstimatedDuration应该会给您一个准确的持续时间,因为它是恒定的比特率,因此可以根据ASBD和采样数精确计算。