当使用 AudioBufferSourceNode 创建声音时,我可以设置偏移量和持续时间(以秒为单位)。
我有样本位置的偏移量和持续时间,我想我必须将其转换为时间,但我不知道从哪里开始。是否有可能获得精确匹配?
早期版本的 web-api 中似乎有示例偏移量和长度,但没有更多。
来自文档:( w3c )
Please note that as a low-level implementation detail, the AudioBuffer is at a specific sample-rate (usually the same as the AudioContext sample-rate), and that the loop times (in seconds) must be converted to the appropriate sample-frame positions in the buffer according to this sample-rate.
最佳答案
匹配应该是精确的,只需将样本位置除以采样率即可,
第二偏移量=样本偏移量/样本率
和
第二持续时间 = 样本持续时间/样本率
关于javascript - 如何在 AudioBufferSourceNode 中设置循环以精确匹配底层缓冲区中的特定偏移量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14882994/