Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add detune AudioParam for ConstantSourceNode #2405

Open
rtoy opened this issue Jul 31, 2020 · 4 comments
Open

Add detune AudioParam for ConstantSourceNode #2405

rtoy opened this issue Jul 31, 2020 · 4 comments

Comments

@rtoy
Copy link
Member

rtoy commented Jul 31, 2020

Describe the feature
Add a detune AudioParam to the ConstantSourceNode

Is there a prototype?
This could be prototyped with an AudioWorklet, but I didn't do that.

Describe the feature in more detail
The AudioBufferSourceNode and OscillatorNode both have a detune parameter that modifies the playbackRate, and frequency, respectively.

Adding one to the ConstantSourceNode seems natural since these other source nodes have one.

This would result in a computed offset = offset * pow(2, detune / 1200).

This would be useful (as mentioned recently in the WebAudio slack channel today) to do some processing for an oscillator. The example was an LFO with a frequency of 500 Hz feeding an oscillator with a frequency of 250 Hz. The LFO would cause negative frequencies, but the user wanted the sum to be clipped to 0.

This is possible to simulate by feeding the LFO to the offset param of the ConstantSourceNode where the offset is set to the oscillator frequency. The output is then sent to the frequency AudioParam of the oscillator with the oscillator frequency set to zero. To get the desired clipping, insert a WaveShaperNode after the constant source.

And instead of modulating the oscillator frequency, you'd modulate the constant source node offset. But if you also want to modulate the oscillator detune, you can't model that with this structure. But if you had a detune for the constant source, this would work just fine.

@rtoy
Copy link
Member Author

rtoy commented Aug 6, 2020

Teleconf: Seems reasonable to make it consistent with other source nodes.

@rtoy
Copy link
Member Author

rtoy commented Aug 17, 2020

Oh, also from the teleconf, @rtoy should find the source of where this question came up. I thought it was Stack Overflow, but it looks like the webaudio slack channel: https://web-audio.slack.com/archives/C04PVA2DH/p1596224674252600

@rtoy
Copy link
Member Author

rtoy commented Aug 18, 2020

How this would work:

The computedOffset is offset * 2^(detune/1200), pretty much like how the computedOscFrequency is derived from the frequency and detune values for an oscillator.

@padenot
Copy link
Member

padenot commented May 21, 2021

AudioWG F2F:

  • Let's do this.

@mdjp mdjp transferred this issue from WebAudio/web-audio-api-v2 Sep 29, 2021
@mdjp mdjp added this to Untriaged in v.next via automation Sep 29, 2021
@mdjp mdjp moved this from Untriaged to In discussion in v.next Sep 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
v.next
In discussion
Development

No branches or pull requests

3 participants