获得样本框对应于音频文件,iPhone一定时间偏移 [英] obtain sample frame offset corresponding to certain time in audio file-iPhone

查看:148
本文介绍了获得样本框对应于音频文件,iPhone一定时间偏移的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于持续时间10秒的音频文件,如果我想寻求2S,我该如何索取样本帧偏移?

Given an audio file of duration 10s, if I want to seek to 2s, how do I obtain the sample frame offset?

推荐答案

如果是LPCM(例如不COM pressed),然后用采样率。

if it's LPCM (e.g. not compressed), then use the sample rate.

在伪code:

double sampleRate = audioFile.getSampleRate();
size_t offsetInSeconds = 2;
size_t sampleToRead = sampleRate * offsetInSeconds * audioFile.getChannelCount();
AudioSample sample = audioFile.getSampleAt(sampleToRead);

这篇关于获得样本框对应于音频文件,iPhone一定时间偏移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆