如何根据音频文件的长度计算样本数?

发布于 2024-10-16 03:22:58 字数 48 浏览 6 评论 0原文

给定一个持续时间为 10 秒的音频文件,我如何找出 2 秒到 8 秒之间的样本数?

Given an audio file of duration say 10s, how do I find out the no of samples betweeen 2s and 8s?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

纵性 2024-10-23 03:22:58

如果是LPCM(例如未压缩),则使用采样率。

伪代码:

double sampleRate = audioFile.getSampleRate();
// you may also need to account for channel count here
size_t sampleCount = sampleRate * (8-2);

-- 其中 (8-2) 表示“2 和 8 之间”

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

in pseudocode:

double sampleRate = audioFile.getSampleRate();
// you may also need to account for channel count here
size_t sampleCount = sampleRate * (8-2);

-- where (8-2) represents "betweeen 2s and 8s"

妖妓 2024-10-23 03:22:58

您可以使用音频播放器的持续时间属性来达到此目的。

持续时间属性给出了音频播放器当前对象的持​​续时间(即当前正在播放的文件)

,因此您可以将所有音频文件提供给播放器一项一项地检查它们的持续时间并执行所需的操作...

干杯

You can use the duration property of the audio player for that purpose..

The duration property gives the duration of the current object of audio player(i.e the file that is currently being played)

So then you can supply all the audio files to the player one by one and check their durations and perform the required operations...

Cheers

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文