Closed Bug 1118372 Opened 5 years ago Closed 5 years ago

[Web Audio API] WaveShaper input signal is forced normalization to range -1 - +1

Categories

(Core :: Web Audio, defect, P1)

37 Branch
x86_64
Windows 8.1
defect

Tracking

()

RESOLVED FIXED
mozilla41
Tracking Status
firefox41 --- fixed

People

(Reporter: gaito, Assigned: yanisellami)

References

Details

Attachments

(2 files)

User Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:37.0) Gecko/20100101 Firefox/37.0
Build ID: 20150106030201

Steps to reproduce:

WaveShaper input signal amplitude is forced normalization to range -1 to +1.

---
<script>
var actx=new AudioContext();
var osc=actx.createOscillator();
var gain=actx.createGain();
var shaper=actx.createWaveShaper();
gain.gain.value=0.1;
shaper.curve=new Float32Array([-0.5,-0.5,1,1]);

osc.connect(gain);
gain.connect(shaper);
shaper.connect(actx.destination);
osc.start(0);

function test(g){
	gain.gain.value=g;
}
</script>
<button onclick="test(0)">test(0)</button>
<button onclick="test(0.1)">test(0.1)</button>
<button onclick="test(1)">test(1)</button>
<button onclick="test(10)">test(10)</button>
---
1) access to
http://www.g200kg.com/demo/test/test-shaperinput.html
2) press test buttons



Actual results:

test(0.1)/test(1)/test(10) makes no differences in volume and distortion


Expected results:

test(0.1) : sound should not be distorted
test(1) : generates some distortion
test(10) : should makes more distortion
Component: Untriaged → Web Audio
Product: Firefox → Core
Priority: -- → P1
Hi, I would like to work on this bug
Assignee: nobody → yanisellami
Attached patch 118372.diffSplinter Review
This should do the trick, I added the rescale in the Node.
Attachment #8616602 - Flags: review?(padenot)
Comment on attachment 8616602 [details] [diff] [review]
118372.diff

Review of attachment 8616602 [details] [diff] [review]:
-----------------------------------------------------------------

Looks good, but we need a test for this ! This can be easily test by having a GainNode with the gain property set to zero, connected to a WaveShaper (that used to ignore the gain), and checking we have a non-silent output.
Attachment #8616602 - Flags: review?(padenot)
This test should do what we want. If the gain has been applied correctly, the output volume will not exceed 0.5.
Attachment #8620706 - Flags: review?(padenot)
Comment on attachment 8620706 [details] [diff] [review]
test case for the bug

Review of attachment 8620706 [details] [diff] [review]:
-----------------------------------------------------------------

Cool, thanks !
Attachment #8620706 - Flags: review?(padenot) → review+
Comment on attachment 8620706 [details] [diff] [review]
test case for the bug

Review of attachment 8620706 [details] [diff] [review]:
-----------------------------------------------------------------

Cool, thanks !
https://hg.mozilla.org/mozilla-central/rev/6ce98e37b52e
https://hg.mozilla.org/mozilla-central/rev/4a267ce23dff
Status: UNCONFIRMED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla41
Depends on: 1190215
Depends on: 1203616
You need to log in before you can comment on or make changes to this bug.