-
Notifications
You must be signed in to change notification settings - Fork 69
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
Rename Oscillator waveTable to match updated periodicWave API #180
Comments
LabSound has been around for a while. AFAIK PeriodicWave wasn't in WebKit at the time the original fork was made. I think, but am not sure, that PeriodicWave and WaveTable share an underlying basic concept. here's an example of a wavetable synth. https://github.com/cwilso/web-audio-samples/blob/master/samples/audio/wavetable-synth.html (also https://github.com/GoogleChromeLabs/web-audio-samples/tree/main/src/demos/wavetable-synth) I haven't attempted porting it. So we should do the same change as indicated in https://dvcs.w3.org/hg/audio/rev/7c4a40a9bb57 to modernize the implementation. That seems straight forward. |
I renamed the issue to reflect the work that needs to be done. |
The rename is complete. However, the CUSTOM oscillator type is meant to be used with PeriodicWave. The implementation of this oscillator type needs to be created. From this code here https://github.com/WebKit/WebKit/blob/main/Source/WebCore/Modules/webaudio/OscillatorNode.cpp we can see how the PeriodicWave is meant to generate samples according to if (!hasSampleAccurateValues) {
frequency = m_frequency->finalValue();
float detune = m_detune->finalValue();
float detuneScale = detuneToFrequencyMultiplier(detune);
frequency *= detuneScale;
clampFrequency(&frequency, 1, context().sampleRate() / 2);
m_periodicWave->waveDataForFundamentalFrequency(frequency, lowerWaveData, higherWaveData, tableInterpolationFactor);
} so implementing this missing feature should be straight forward. |
Here is an example of modulating a periodicWave to create a siren effect. we should add it to the test-examples. |
I tried implementing oscillatorNode.setPeriodicWave(pwave) but its a bit too much for me especially the labsound vs webkit plumbing. I have #define METHODB and regular waveforms still work with the webkit method. But setPeriodicWave bombs and the call stack is weird, seeming to cycle back through .setType -- what seems to b |
I can have a look in the next few days, thanks for having a go. |
Web3d.org v4 standard was designed around web audio standard.
https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/sound.html#PeriodicWave
Web Audio shows context has a createPeriodicWave function taking 2 float arrays (imag, real) and generates a 'wave' which can then be set in Oscillator for type CUSTOM.
https://developer.mozilla.org/en-US/docs/Web/API/OscillatorNode/setPeriodicWave
I don't see that in LabSound.
I see something in LabSound called WaveTable, but I don't see an example of it being used.
Is there a way to apply WaveTable to Oscillator that is equivalent to web audio createPeriodicWave /setPeriodicWave?
Thanks
The text was updated successfully, but these errors were encountered: