WebAudio API:更改样本的音高(例如 mp3) [英] WebAudio API: Change pitch of samples (for example mp3)

查看:23
本文介绍了WebAudio API:更改样本的音高(例如 mp3)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想我可以使用 playbackRate 来拉伸样本,但是我该如何设置音高呢?我试图在不使用任何库的情况下实现这一目标.

I figured I can stretch a sample using playbackRate but how do I set the pitch? Im trying to achieve this without using any libraries.

我在规范中发现了一些关于多普勒音高效应的信息,但除此之外,我找不到与我的目标真正相关的任何内容.只是一个简单的音高转换,这甚至可能吗?如果是,那怎么办?

I found something about a doppler pitch effect in the specification but other than that I couldnt find anything truly relevant to my objective. Just a simple pitch shift, is this even possible? If so then how?

编辑:是不是 playbackRate 也改变了音高,但浏览器应用了某种修正?我认为情况可能是这样.如果是这种情况并且可能的话,我必须禁用它.

Edit: Could it be that playbackRate changes the pitch as well but the browser applies some sort of correction? I think this might be the case. I have to disable it then if that is the case and possible.

推荐答案

样本没有简单"的音高变化.有很多方法可以在不改变播放速率的情况下改变音高 - 颗粒再合成、相移声码 - 但它们都不是微不足道的,也没有被纳入 Web Audio API.(顺便说一下,多普勒正在被删除,因为它非常笨拙.)回放速率实际上是采样将通过的速率 - 这将影响速度"和(音高采样的)表观音高.

There is no "simple" pitch shift for samples. There are lots of ways to change the pitch without changing the playback rate - granular resynthesis, phase-shift vocoding - but none of them are trivial, and none are baked into the Web Audio API. (Doppler is being removed, by the way, since it was pretty hacky.) playbackRate is literally the rate at which the samples will be run through - which will affect both "speed" and apparent pitch (of pitched samples).

我在 输入效果演示中实现了音高转换(颗粒再合成)效果- 使用丛林.js 库 - 但这不是一件容易的事.HTML 的 <audio> 元素会拉伸,但没有指定算法,这使得它有很多解释.

I implemented a pitch-shifting (granular resynthesis) effect in the Input Effects demo - using the jungle.js library - but this isn't a trivial thing to do. HTML's <audio> element does stretching, but doesn't specify the algorithm, which leaves it open to a lot of interpretations.

这篇关于WebAudio API:更改样本的音高(例如 mp3)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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