-
Notifications
You must be signed in to change notification settings - Fork 166
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
Phase-offset of oscillator nodes #2402
Comments
+1, agreed that this is needed. A couple more use cases:
|
Seems like a significant gap. We want to get implementors' feedback on the effort involved. |
@hoch and I took a quick look at this a while back. Seems doable without huge effort. |
Yeah it's not very hard and very useful, we should do it. |
I concur. On Wed, Sep 23, 2015 at 2:00 AM, Paul Adenot notifications@github.com
Ray |
With this I would have more control on the wave and could change the oscillator's gain more smoothly. Currently the gain doesn't wait for the wave to reach 0, so it cuts the wave anywhere, resulting in a clicking sound whenever the gain is changed. Please look at my bugzilla report for examples: https://bugzilla.mozilla.org/show_bug.cgi?id=1232644 |
I agree with @meszaros-lajos-gyorgy -- make it easy/possible to do the most common thing, which would be to avoid pops/clicks. They're almost never what you want... |
To add another example: I'm currently developing an app, which heavily relies on the Audio API's oscillators and gains and it is about constantly changing the volume and pitch of the generated frequencies. You can hear the clicking an popping almost every time you change something. Live project: http://meszaros-lajos-gyorgy.github.io/microtonal/monochord/ |
@meszaros-lajos-gyorgy fwiw i ran into similar issues and worked around them with |
also, it would be great to get a sync input/output on the oscillator node. then to implement hard sync you could do something like:
i suppose i could see this as a callback too (similar to |
sorry, one more thing:
won't you potentially get weird behavior here if you have something other than a vanilla oscillator connected directly to the |
@meszaros-lajos-gyorgy - I have added a combination of SetValueAtTime and LinearRampToValueAtTime to your fiddle (see http://jsfiddle.net/0pjapu9c/1/). I think it fixes your problem. |
@pendragon-andyh - I can still hear the clicking for every 'boop' in Firefox 43 |
This is likely to be a firefox bug. |
This was asked for again (twice) at the WG plenary panel at WAC2016. One was a call for oscillator sync, to the hard sync effect, which can be done by resetting the phase. The second was the request for pulse waves, with a-rate modulation of mark/space ratio - which could be done with phase control, or could be added directly (to oscillator, or as a new pulseOscillator node). |
Note that naive hard-sync will introduce aliasing because the hard-synced waveform is no longer bandlimited. But see "Hard Sync Without Aliasing" http://www.cs.cmu.edu/~eli/papers/icmc01-hardsync.pdf |
+1 on this feature request. What I want to do more by OscillatorNode is
The first three could be realized by having |
I believe the intent is to add a phase (name TBD) AudioParam. I have been trying to implement this in Chrome and it's rather hard if we want to preserve the band-limited requirement of the Oscillator. It's easy if you drop this requirement, but I think it's important for the oscillator to be band-limited. |
Is this to reuse a single oscillator without creating a new one? This is doable with
Yeap. Also doable with
This has been bugging me for a while. I believe hard-syncing 2 oscillators on zero-crossing might not be possible with this AudioParam approach. |
Currently Chrome's PeriodicWave::waveDataForFundamentalFrequency() function decides the lower and higher band-limited-tables to use from the frequency passed-in by the OscillatorHandler::process() function. Instead of indexing the tables by their fundamental frequency, would it be possible to index by their phase-increment? A large phase-increment indicates a high frequency - so you need to cull more of its high harmonics. |
I anticipated that the phase parameter would have a values like:
I would not expect this to work. In most designs, the phase parameter is normally an offset to what the unmodified phase of the oscillator would be. An easier way is to just start a new oscillator.
I have a theory that (if we have a phase parameter) you could achieve this by the following steps:
The "(sine*square)=>waveshaper" trick was the most accurate way that I have found of getting a true sawtooth. Most people would reach for a BufferSourceNode - but the interpolation between samples means that the result is a bit noisy. |
I assume writing values to the This is my understanding. Here, I assume the range for a loop is 0 through 1, and the value will be clipped as
This makes a sine wave in frequency
This can generate a periodic wave with 1.5 cycle of sine wave. This is what I meant in my previous comment about sync modulation. |
On Tue, Aug 2, 2016 at 2:06 AM, Takashi Toyoshima notifications@github.com
That's a good question. No one has actually proposed anything yet, but I s(2_pi_f*t + phi(t)) where phi(t) is the phase input to the node. You can achieve what you want I was also assuming that s(t) would still be band-limited when including
Almost. Since osc2 is band-limited, the resulting sawtooth has ringing so
Ray |
New feature; need to defer to a later iteration. |
Discussed at March 2018 f2f. Hard (phase reset) and soft (reversing) sync, difficulty of maintaining bandlimited with hard sync. |
This comment has been minimized.
This comment has been minimized.
Hi! I don't want to rush anyone, but since the ticket has been opened for over 3 years now, I feel an urge to ask: is there any progress with this? is anyone working on this? have every question been answered regarding this feature? can we help in any way to make this feature happen sooner? Thanks! |
It is rather a design problem; how parameters do we expose? Is it involved with 2 oscillator nodes or a new node with multiple oscillators? I think the right course of action is to build a prototype design with AudioWorklet and gather feedback from the dev community. |
Let's keep this issue about a phase offset for the |
|
Any news on this issue? phase control seems kinda essential when it comes to any kind of synthesis. |
I think what we need is to have a clearer idea of what is expected, mostly about band-limiting. A |
We get distortion from instantaneously changing most AudioParams. My original thought was that you could apply the phase offset directly to the waveform's lookup index. You would probably get a small amount of aliasing if you modulate like crazy on a square wave. I don't actually need this feature for pulse width modulation any more (I used a worklet in https://github.com/pendragon-andyh/junox and used polyblep to minimise aliasing). I can use worklets for hard-sync and phase modulation. |
This is really nice and kind of the we intended new feature requests to work: a feature is requested, a polyfill with a worklet is created to show how it might work, and this is used to guide the design. Thanks! |
Is this an implementation issue -- regarding band-limiting? We already have a-rated |
The question is if it should be band-limited in principle. The a-rate I personally am ok with phase offset potentially not being band-limited since the oscillator itself isn't always band-limited. |
I'm personally okay with that too, and for the same reason. |
Here's my mock-up of OscillatorNode with phase AudioParam. https://khoin.github.io/OscillatorNodeP/ You can simply test that |
We should group WebAudio/web-audio-api-v2#9 WebAudio/web-audio-api-v2#7 & WebAudio/web-audio-api-v2#1 together. Worth discussing with Chris L |
It's 2022, I & my college mates are making a web audio host, which require precise control of phases of source nodes. |
What is the recommended way to apply phase offset to an oscilator node? |
Teleconference 5/30/2024: To continue with further standardization, the WG needs a prototype based on AudioWorkletNode. (hence |
Can we have an a-rate parameter on the OscillatorNode that allows modulation of the phase offset? This would allow:
The text was updated successfully, but these errors were encountered: