admin管理员组文章数量:1291611
Using the Web Audio API, I have an oscillator node with a frequency of 1000. I want to change this frequency value, but not directly. I want to use a multiplier instead.
So, given 1.5
, the frequency would be made 1500
. Given 0.5
, it would become 500
.
I thought I could achieve this by connecting a gain node to the frequency parameter, like so (where context
is the audio context):
const oscNode = context.createOscillator();
oscNode.frequency.setValueAtTime(1000, context.currentTime);
const gainNode = context.createGain();
gainNode.connect(oscNode.frequency);
gainNode.gain.setValueAtTime(1.5, context.currentTime);
The following is not viable:
let multiplier = 1.5;
oscNode.frequency.setValueAtTime(1000 * multiplier, context.currentTime);
That’s because it must be possible to modulate the multiplier, say, with another oscillator acting as an LFO.
Perhaps gain
is not a generic signal multiplier as I thought and can only work as expected while augmenting other gains. If so, are there other ways to multiply arbitrary parameter values? Are there general ways to provide computed values to audio parameters in place of simple integers?
Note: I do not get an error and playback works as expected when connecting the gain node to the frequency param. It just does not appear to do anything.
本文标签: Web audio gain node as a generic multiplierStack Overflow
版权声明:本文标题:Web audio gain node as a generic multiplier? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741537154a2384093.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论