Given an audio file of duration 10s, if I want to seek to 2s, how do I obtain the sample frame offset?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
if it's LPCM (e.g. not compressed), then use the sample rate.
in pseudocode:
double sampleRate = audioFile.getSampleRate();
size_t offsetInSeconds = 2;
size_t sampleToRead = sampleRate * offsetInSeconds * audioFile.getChannelCount();
AudioSample sample = audioFile.getSampleAt(sampleToRead);