WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-74273-20120109140300.patch (text/plain), 17.57 KB, created by
Raymond Toy
on 2012-01-09 14:03:01 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Raymond Toy
Created:
2012-01-09 14:03:01 PST
Size:
17.57 KB
patch
obsolete
>Subversion Revision: 104038 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index a2b91e27e140588e13b6ffa0d66a88cdfd6e1fd6..004308c9c2862af06a7c2d2e8ad4011f105db68c 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,19 @@ >+2012-01-09 Raymond Toy <rtoy@google.com> >+ >+ Constant values to set "distanceModel" are undefined >+ https://bugs.webkit.org/show_bug.cgi?id=74273 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Tests: webaudio/distance-exponential.html >+ webaudio/distance-inverse.html >+ webaudio/distance-linear.html >+ >+ * webaudio/AudioPannerNode.h: Define enum for the new constants >+ for the distance models. >+ * webaudio/AudioPannerNode.idl: Define matching constants for the >+ distance models. >+ > 2012-01-04 Adam Roben <aroben@apple.com> > > Use one big printf command instead of many chained echo commands to generate idl_files.tmp >diff --git a/Source/WebCore/webaudio/AudioPannerNode.h b/Source/WebCore/webaudio/AudioPannerNode.h >index 6ecebeaae31ca7dac38579f1d5a035de3722cf11..40be717028681e7887a948d8dbdecd3e2d9b426f 100644 >--- a/Source/WebCore/webaudio/AudioPannerNode.h >+++ b/Source/WebCore/webaudio/AudioPannerNode.h >@@ -53,6 +53,14 @@ public: > SOUNDFIELD = 2, > }; > >+ // These must be defined as in the .idl file and must match those >+ // in the DistanceEffect class. >+ enum { >+ LINEAR_DISTANCE = 0, >+ INVERSE_DISTANCE = 1, >+ EXPONENTIAL_DISTANCE = 2, >+ }; >+ > static PassRefPtr<AudioPannerNode> create(AudioContext* context, float sampleRate) > { > return adoptRef(new AudioPannerNode(context, sampleRate)); >diff --git a/Source/WebCore/webaudio/AudioPannerNode.idl b/Source/WebCore/webaudio/AudioPannerNode.idl >index 2db093d7b503aa1e9cc45f64a717a0c1844badd7..597a3eadfbac9e76ba9da74233be15b9d74254ee 100644 >--- a/Source/WebCore/webaudio/AudioPannerNode.idl >+++ b/Source/WebCore/webaudio/AudioPannerNode.idl >@@ -33,6 +33,11 @@ module audio { > const unsigned short HRTF = 1; > const unsigned short SOUNDFIELD = 2; > >+ // Distance model >+ const unsigned short LINEAR_DISTANCE = 0; >+ const unsigned short INVERSE_DISTANCE = 1; >+ const unsigned short EXPONENTIAL_DISTANCE = 2; >+ > // Default model for stereo is HRTF > attribute unsigned long panningModel; // FIXME: use unsigned short when glue generation supports it > >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index 6a289204ddb96e793a6536fce5e9809e2a50f7f3..b70b54c82a011eebe7436916a25e8a766cfcb849 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,27 @@ >+2012-01-09 Raymond Toy <rtoy@google.com> >+ >+ Constant values to set "distanceModel" are undefined >+ https://bugs.webkit.org/show_bug.cgi?id=74273 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * webaudio/distance-exponential-expected.txt: Added. >+ * webaudio/distance-exponential.html: Added. >+ * webaudio/distance-inverse-expected.txt: Added. >+ * webaudio/distance-inverse.html: Added. >+ * webaudio/distance-linear-expected.txt: Added. >+ * webaudio/distance-linear.html: Added. >+ * webaudio/resources/distance-model-testing.js: Added. >+ (createImpulseBuffer): >+ (linearDistance): >+ (exponentialDistance): >+ (inverseDistance): >+ (createGraph): >+ (startSources): >+ (equalPowerGain): >+ (checkDistanceResult.return.renderedBuffer): >+ (checkDistanceResult): >+ > 2012-01-04 Alpha Lam <hclam@chromium.org> > > Not reviewed. Update Chromium port test expectations after Skia roll. >diff --git a/LayoutTests/webaudio/distance-exponential-expected.txt b/LayoutTests/webaudio/distance-exponential-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..2575c32c1618eeb37d1a28fd43c9f7d669b297a3 >--- /dev/null >+++ b/LayoutTests/webaudio/distance-exponential-expected.txt >@@ -0,0 +1,11 @@ >+Test exponential distance model of AudioPannerNode. >+ >+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". >+ >+PASS Number of nodes is correct. >+PASS Distance gains are correct. >+PASS Distance test passed for distance model 2 >+PASS successfullyParsed is true >+ >+TEST COMPLETE >+ >diff --git a/LayoutTests/webaudio/distance-exponential.html b/LayoutTests/webaudio/distance-exponential.html >new file mode 100644 >index 0000000000000000000000000000000000000000..1f2bd0dbaa05007fac12bf6ab138bd797bb05401 >--- /dev/null >+++ b/LayoutTests/webaudio/distance-exponential.html >@@ -0,0 +1,64 @@ >+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> >+<html> >+ <head> >+ <link rel="stylesheet" href="../fast/js/resources/js-test-style.css"/> >+ <script src="../fast/js/resources/js-test-pre.js"></script> >+ <script src="resources/distance-model-testing.js"></script> >+ </head> >+ >+ <body> >+ <div id="description"></div> >+ <div id="console"></div> >+ >+ <script> >+ description("Test exponential distance model of AudioPannerNode."); >+ >+ var sampleRate = 44100.0; >+ >+ var renderLengthSeconds = 8; >+ var pulseLengthSeconds = 1; >+ var pulseLengthFrames = pulseLengthSeconds * sampleRate; >+ >+ // How many panner nodes to create for the test >+ var nodesToCreate = 100; >+ >+ // Time step when each panner node starts. >+ var timeStep = 0.05; >+ >+ var context; >+ var impulse; >+ var bufferSource; >+ var panner; >+ var position; >+ var time; >+ >+ function runTest() { >+ if (window.layoutTestController) { >+ layoutTestController.dumpAsText(); >+ layoutTestController.waitUntilDone(); >+ } >+ >+ window.jsTestIsAsync = true; >+ >+ // Create offline audio context. >+ context = new webkitAudioContext(2, sampleRate * renderLengthSeconds, sampleRate); >+ >+ // Temp panner node so we can get the EXPONENTIAL_DISTANCE value. >+ var tempPanner = context.createPanner(); >+ createGraph(context, tempPanner.EXPONENTIAL_DISTANCE, nodesToCreate); >+ startSources(); >+ >+ // Threshold experimentally determined. >+ var threshold = 1.3e-7; >+ context.oncomplete = checkDistanceResult(tempPanner.EXPONENTIAL_DISTANCE, threshold, false); >+ context.startRendering(); >+ } >+ >+ runTest(); >+ successfullyParsed = true; >+ >+ </script> >+ >+<script src="../fast/js/resources/js-test-post.js"></script> >+ </body> >+</html> >diff --git a/LayoutTests/webaudio/distance-inverse-expected.txt b/LayoutTests/webaudio/distance-inverse-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..aae9ca0a3eb10626c50a3b167646a7b509509aba >--- /dev/null >+++ b/LayoutTests/webaudio/distance-inverse-expected.txt >@@ -0,0 +1,11 @@ >+Test inverse distance model of AudioPannerNode. >+ >+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". >+ >+PASS Number of nodes is correct. >+PASS Distance gains are correct. >+PASS Distance test passed for distance model 1 >+PASS successfullyParsed is true >+ >+TEST COMPLETE >+ >diff --git a/LayoutTests/webaudio/distance-inverse.html b/LayoutTests/webaudio/distance-inverse.html >new file mode 100644 >index 0000000000000000000000000000000000000000..6327eb552d80a8df2eef863443f02ed8ff35ba86 >--- /dev/null >+++ b/LayoutTests/webaudio/distance-inverse.html >@@ -0,0 +1,64 @@ >+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> >+<html> >+ <head> >+ <link rel="stylesheet" href="../fast/js/resources/js-test-style.css"/> >+ <script src="../fast/js/resources/js-test-pre.js"></script> >+ <script src="resources/distance-model-testing.js"></script> >+ </head> >+ >+ <body> >+ <div id="description"></div> >+ <div id="console"></div> >+ >+ <script> >+ description("Test inverse distance model of AudioPannerNode."); >+ >+ var sampleRate = 44100.0; >+ >+ var renderLengthSeconds = 8; >+ var pulseLengthSeconds = 1; >+ var pulseLengthFrames = pulseLengthSeconds * sampleRate; >+ >+ // How many panner nodes to create for the test >+ var nodesToCreate = 100; >+ >+ // Time step when each panner node starts. >+ var timeStep = 0.05; >+ >+ var context; >+ var impulse; >+ var bufferSource; >+ var panner; >+ var position; >+ var time; >+ >+ function runTest() { >+ if (window.layoutTestController) { >+ layoutTestController.dumpAsText(); >+ layoutTestController.waitUntilDone(); >+ } >+ >+ window.jsTestIsAsync = true; >+ >+ // Create offline audio context. >+ context = new webkitAudioContext(2, sampleRate * renderLengthSeconds, sampleRate); >+ >+ // Temp panner node so we can get the INVERSE_DISTANCE value. >+ var tempPanner = context.createPanner(); >+ createGraph(context, tempPanner.INVERSE_DISTANCE, nodesToCreate); >+ startSources(); >+ >+ // Threshold experimentally determined. >+ var threshold = 1.3e-7; >+ context.oncomplete = checkDistanceResult(tempPanner.INVERSE_DISTANCE, threshold, false); >+ context.startRendering(); >+ } >+ >+ runTest(); >+ successfullyParsed = true; >+ >+ </script> >+ >+<script src="../fast/js/resources/js-test-post.js"></script> >+ </body> >+</html> >diff --git a/LayoutTests/webaudio/distance-linear-expected.txt b/LayoutTests/webaudio/distance-linear-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..9fcf4b732f40c20d98f49fcdc95ef7e79b3aa623 >--- /dev/null >+++ b/LayoutTests/webaudio/distance-linear-expected.txt >@@ -0,0 +1,11 @@ >+Test linear distance model of AudioPannerNode. >+ >+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". >+ >+PASS Number of nodes is correct. >+PASS Distance gains are correct. >+PASS Distance test passed for distance model 0 >+PASS successfullyParsed is true >+ >+TEST COMPLETE >+ >diff --git a/LayoutTests/webaudio/distance-linear.html b/LayoutTests/webaudio/distance-linear.html >new file mode 100644 >index 0000000000000000000000000000000000000000..d59a1a5947ffdc15a8fb8b2bfb1c0d9d47caf12a >--- /dev/null >+++ b/LayoutTests/webaudio/distance-linear.html >@@ -0,0 +1,64 @@ >+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> >+<html> >+ <head> >+ <link rel="stylesheet" href="../fast/js/resources/js-test-style.css"/> >+ <script src="../fast/js/resources/js-test-pre.js"></script> >+ <script src="resources/distance-model-testing.js"></script> >+ </head> >+ >+ <body> >+ <div id="description"></div> >+ <div id="console"></div> >+ >+ <script> >+ description("Test linear distance model of AudioPannerNode."); >+ >+ var sampleRate = 44100.0; >+ >+ var renderLengthSeconds = 8; >+ var pulseLengthSeconds = 1; >+ var pulseLengthFrames = pulseLengthSeconds * sampleRate; >+ >+ // How many panner nodes to create for the test >+ var nodesToCreate = 100; >+ >+ // Time step when each panner node starts. >+ var timeStep = 0.05; >+ >+ var context; >+ var impulse; >+ var bufferSource; >+ var panner; >+ var position; >+ var time; >+ >+ function runTest() { >+ if (window.layoutTestController) { >+ layoutTestController.dumpAsText(); >+ layoutTestController.waitUntilDone(); >+ } >+ >+ window.jsTestIsAsync = true; >+ >+ // Create offline audio context. >+ context = new webkitAudioContext(2, sampleRate * renderLengthSeconds, sampleRate); >+ >+ // Temp panner node so we can get the LINEAR_DISTANCE value. >+ var tempPanner = context.createPanner(); >+ createGraph(context, tempPanner.LINEAR_DISTANCE, nodesToCreate); >+ startSources(); >+ >+ // Threshold experimentally determined. >+ var threshold = 2.3e-6; >+ context.oncomplete = checkDistanceResult(tempPanner.LINEAR_DISTANCE, threshold, false); >+ context.startRendering(); >+ } >+ >+ runTest(); >+ successfullyParsed = true; >+ >+ </script> >+ >+<script src="../fast/js/resources/js-test-post.js"></script> >+ </body> >+</html> >diff --git a/LayoutTests/webaudio/resources/distance-model-testing.js b/LayoutTests/webaudio/resources/distance-model-testing.js >new file mode 100644 >index 0000000000000000000000000000000000000000..664a9e9ccbe78d807ba16b35ff63fe7c0e7d459f >--- /dev/null >+++ b/LayoutTests/webaudio/resources/distance-model-testing.js >@@ -0,0 +1,161 @@ >+function createImpulseBuffer(context, sampleFrameLength) { >+ var audioBuffer = context.createBuffer(1, 1000, context.sampleRate); >+ var n = audioBuffer.length; >+ var data = audioBuffer.getChannelData(0); >+ >+ for (var k = 0; k < n; ++k) { >+ data[k] = 0; >+ } >+ data[0] = 1; >+ >+ return audioBuffer; >+} >+ >+// For the record, these distance formulas were taken from the OpenAL >+// spec, not the code. >+function linearDistance(panner, x, y, z) { >+ >+ var distance = Math.sqrt(x*x + y*y + z*z); >+ distance = Math.min(distance, panner.maxDistance); >+ var rolloff = panner.rolloffFactor; >+ var gain = (1 - rolloff*(distance - panner.refDistance)/(panner.maxDistance - panner.refDistance)); >+ >+ return gain; >+} >+ >+function exponentialDistance(panner, x, y, z) { >+ var distance = Math.sqrt(x*x + y*y + z*z); >+ distance = Math.min(distance, panner.maxDistance); >+ var rolloff = panner.rolloffFactor; >+ var gain = Math.pow(distance/panner.refDistance, -rolloff); >+ >+ return gain; >+} >+ >+function inverseDistance(panner, x, y, z) { >+ var distance = Math.sqrt(x*x + y*y + z*z); >+ distance = Math.min(distance, panner.maxDistance); >+ var rolloff = panner.rolloffFactor; >+ var gain = panner.refDistance/(panner.refDistance + rolloff * (distance - panner.refDistance)); >+ >+ return gain; >+} >+ >+// This array must be arranged in the numeric order of the distance >+// model values. >+var distanceModelFunction = [linearDistance, inverseDistance, exponentialDistance]; >+ >+function createGraph(context, distanceModel, nodeCount) { >+ // Create all the sources, which are impulses. >+ bufferSource = new Array(nodeCount); >+ for (var k = 0; k < nodeCount; ++k) { >+ bufferSource[k] = context.createBufferSource(); >+ impulse = createImpulseBuffer(context, pulseLengthFrames); >+ bufferSource[k].buffer = impulse; >+ } >+ >+ // Create all the panners. >+ // >+ // We MUST use the EQUALPOWER panning model so that we can easily >+ // figure out the gain introduced by the panner. >+ // >+ // We want to stay in the middle of the panning range, which means >+ // we want to stay on the z-axis. If we don't, then the effect of >+ // panning model will be much more complicated. We're not testing >+ // the panner, but the distance model, so we want the panner effect >+ // to be simple. >+ panner = new Array(nodeCount); >+ position = new Array(nodeCount); >+ for (var k = 0; k < nodeCount; ++k) { >+ panner[k] = context.createPanner(); >+ panner[k].panningModel = panner.EQUALPOWER; >+ panner[k].distanceModel = distanceModel; >+ // The distance is uniform spacing between the max and ref >+ // distance. >+ var distanceStep = (panner[k].maxDistance - panner[k].refDistance) / nodeCount; >+ position[k] = distanceStep * k + panner[k].refDistance; >+ panner[k].setPosition(0, 0, position[k]); >+ } >+ >+ // Connect the sources and panners. >+ for (var k = 0; k < nodeCount; ++k) { >+ bufferSource[k].connect(panner[k]); >+ panner[k].connect(context.destination); >+ } >+} >+ >+function startSources() { >+ // Turn on each source at uniform intervals. >+ time = new Array(nodesToCreate); >+ for (var k = 0; k < nodesToCreate; ++k) { >+ time[k] = k * timeStep; >+ bufferSource[k].noteOn(time[k]); >+ } >+} >+ >+// The gain caused by the EQUALPOWER panning model, if we stay on the >+// z axis, with the default orientations. >+function equalPowerGain() { >+ return Math.SQRT1_2; >+} >+ >+function checkDistanceResult(model, threshold, debug) { >+ return function(event) { >+ renderedBuffer = event.renderedBuffer; >+ renderedData = renderedBuffer.getChannelData(0); >+ var success = true; >+ var count = 0; >+ var timeCount = 0; >+ var maxError = 0; >+ var timeErrors = new Array(); >+ >+ // Step through the rendered data to find all the non-zero points >+ // so we can find where our impulses are. >+ for (var k = 0; k < renderedData.length; ++k) { >+ if (renderedData[k] != 0) { >+ var expected = distanceModelFunction[panner[count].distanceModel](panner[count], 0, 0, position[count]); >+ expected *= equalPowerGain(); >+ >+ var error = Math.abs(renderedData[k] - expected)/Math.abs(expected); >+ if (debug) { >+ console.log(k + ": " + renderedData[k] + " (expected " + expected + ", rel = ", error + ")"); >+ } >+ maxError = Math.max(maxError, Math.abs(error)); >+ if (k != Math.round(sampleRate * time[count])) { >+ timeErrors[timeCount] = { actual : k, expected : Math.round(sampleRate * time[count])}; >+ ++timeCount; >+ } >+ ++count; >+ } >+ } >+ >+ if (count == nodesToCreate) { >+ testPassed("Number of nodes is correct."); >+ } else { >+ testFailed("Number of nodes is incorrect. (Found " + count + " but expected " + nodesToCreate + ")"); >+ success = false; >+ } >+ >+ if (maxError <= threshold) { >+ testPassed("Distance gains are correct."); >+ } else { >+ testFailed("Distance gains are incorrect. Max rel error = " + maxError + " (threshold = " + threshold + ")"); >+ success = false; >+ } >+ >+ if (debug && timeErrors.length > 0) { >+ console.log(timeErrors.length + " timing errors found"); >+ for (var k = 0; k < timeErrors.length; ++k) { >+ console.log("Sample " + timeErrors[k].actual + " but expected " + timeErrors[k].expected); >+ } >+ } >+ >+ if (success) { >+ testPassed("Distance test passed for distance model " + model); >+ } else { >+ testFailed("Distance test failed for distance model " + model); >+ } >+ >+ finishJSTest(); >+ } >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 74273
:
118890
|
119037
|
121724
|
121867
|
122089
|
122818
|
124760
|
124763
|
124774
|
124778
|
125020
|
125038