Closed Bug 1106649 Opened 5 years ago Closed 5 years ago

Use band-limited wave tables for OscillatorNode

Categories

(Core :: Web Audio, defect)

x86_64
Linux
defect
Not set

Tracking

()

RESOLVED FIXED
mozilla37

People

(Reporter: padenot, Assigned: padenot)

References

Details

Attachments

(2 files, 1 obsolete file)

The BLIT code has some issues:
- DC offset, so we need to DC block, and that has impact on the timbre
- ugly waveforms at low frequencies

Now that we have PeriodicWave implemented, we can just use it for the basic waveforms as well.
I had to fix the triangle in Blink's code because the initial phase was wrong.
Attachment #8530995 - Flags: review?(karlt)
Assignee: nobody → padenot
Status: NEW → ASSIGNED
Comment on attachment 8530995 [details] [diff] [review]
Use band-limited wave tables to implement basic waveforms. r=

>           case OscillatorType::Sine:
>-            mPhase = 0.0;
>             break;

mPhase means something quite different when using mPeriodicWave, so it's
probably better to leave the 0.0 here until some kind conversion is performed.

>+            if (n & 1) {
>+              b = 2 * (2 / (n * piFloat) * 2 / (n * piFloat)) * ((((n - 1) >> 1) & 1) ? -1 : 1);

This can be simplified somewhat.
If (n&1), then ((n-1)>>1) == (n>>1).
((n>>1)&1) is true iff (n&2).
Attachment #8530995 - Flags: review?(karlt) → review+
Is mSignalPeriod unused outside of UpdateParametersIfNeeded() now?
Can it be made a local variable or removed?
(In reply to Karl Tomlinson (back Dec 22 :karlt) from comment #3)
> Is mSignalPeriod unused outside of UpdateParametersIfNeeded() now?
> Can it be made a local variable or removed?

Yes.
Uploading last version (the triangle formula is not fixed yet).
Attachment #8535568 - Attachment is obsolete: true
https://hg.mozilla.org/mozilla-central/rev/ffab1d2bd4ce
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla37
Depends on: 1172181
You need to log in before you can comment on or make changes to this bug.