Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/39.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iPhone-获取线性PCM音频文件的持续时间_Iphone_Core Audio - Fatal编程技术网

iPhone-获取线性PCM音频文件的持续时间

iPhone-获取线性PCM音频文件的持续时间,iphone,core-audio,Iphone,Core Audio,我的应用程序中有一个线性PCM文件(.wav),我想通过编程获得它的持续时间。我可以使用AudioStreamBasicDescription找到以下内容,但无法确定如何以秒为单位获得持续时间 mFormatID mSampleRate mChannelsPerFrame mBytesPerPacket mFramesPerPacket mBytesPerFrame mBitsPerChannel 有人能告诉我怎样才能得到持续时间吗 谢谢。您可以使用文件创建AVAudioPlayer实例。AV

我的应用程序中有一个线性PCM文件(.wav),我想通过编程获得它的持续时间。我可以使用AudioStreamBasicDescription找到以下内容,但无法确定如何以秒为单位获得持续时间

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.mSampleRate

Hmm。。。您可以使用AudioFileGetProperty方法并检查kAudioFilePropertyEstimatedDuration属性的值。对于PCM,获取kAudioFilePropertyEstimatedDuration应该会给您一个准确的持续时间,因为它是恒定的比特率,因此可以根据ASBD和样本数精确计算。。。您可以使用AudioFileGetProperty方法并检查kAudioFilePropertyEstimatedDuration属性的值。对于PCM,获取kAudioFilePropertyEstimatedDuration应该会给您一个准确的持续时间,因为它是恒定的比特率,因此可以根据ASBD和采样数精确计算。