Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: third_party/WebKit/LayoutTests/webaudio/resources/stereopanner-testing.js

Issue 1803153002: Add min/max values for AudioParams (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 var StereoPannerTest = (function () { 1 var StereoPannerTest = (function () {
2 2
3 // Constants 3 // Constants
4 var PI_OVER_TWO = Math.PI * 0.5; 4 var PI_OVER_TWO = Math.PI * 0.5;
5 5
6 var gSampleRate = 44100; 6 var gSampleRate = 44100;
7 7
8 // Time step when each panner node starts. 8 // Time step when each panner node starts.
9 var gTimeStep = 0.001; 9 var gTimeStep = 0.001;
10 10
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 // to 0 to make the test fail to see what the actual error is. 81 // to 0 to make the test fail to see what the actual error is.
82 this.maxAllowedError = 1.3e-6; 82 this.maxAllowedError = 1.3e-6;
83 83
84 // Max (absolute) error and the index of the maxima for the left 84 // Max (absolute) error and the index of the maxima for the left
85 // and right channels. 85 // and right channels.
86 this.maxErrorL = 0; 86 this.maxErrorL = 0;
87 this.maxErrorR = 0; 87 this.maxErrorR = 0;
88 this.maxErrorIndexL = 0; 88 this.maxErrorIndexL = 0;
89 this.maxErrorIndexR = 0; 89 this.maxErrorIndexR = 0;
90 90
91 // The maximum value to use for panner pan value. The value will range from -panLimit to
92 // +panLimit.
93 this.panLimit = 1.0625;
91 } 94 }
92 95
93 96
94 Test.prototype.init = function () { 97 Test.prototype.init = function () {
95 this.context = new OfflineAudioContext(2, gRenderLength, gSampleRate); 98 this.context = new OfflineAudioContext(2, gRenderLength, gSampleRate);
96 }; 99 };
97 100
98 // Prepare an audio graph for testing. Create multiple impulse generators and 101 // Prepare an audio graph for testing. Create multiple impulse generators and
99 // panner nodes, then play them sequentially while varying the pan position. 102 // panner nodes, then play them sequentially while varying the pan position.
100 Test.prototype.prepare = function () { 103 Test.prototype.prepare = function () {
101 var impulse; 104 var impulse;
102 var impulseLength = Math.round(gTimeStep * gSampleRate); 105 var impulseLength = Math.round(gTimeStep * gSampleRate);
103 var sources = []; 106 var sources = [];
104 var panners = []; 107 var panners = [];
105 108
106 // Moves the pan value for each panner by pan step unit from -2 to 2. 109 // Moves the pan value for each panner by pan step unit from -2 to 2.
107 // This is to check if the internal panning value is clipped properly. 110 // This is to check if the internal panning value is clipped properly.
108 var panStep = 4 / (gNodesToCreate - 1); 111 var panStep = (2 * this.panLimit) / (gNodesToCreate - 1);
109 112
110 if (this.numberOfInputChannels === 1) { 113 if (this.numberOfInputChannels === 1) {
111 impulse = createImpulseBuffer(this.context, impulseLength); 114 impulse = createImpulseBuffer(this.context, impulseLength);
112 } else { 115 } else {
113 impulse = createStereoImpulseBuffer(this.context, impulseLength); 116 impulse = createStereoImpulseBuffer(this.context, impulseLength);
114 } 117 }
115 118
116 for (var i = 0; i < gNodesToCreate; i++) { 119 for (var i = 0; i < gNodesToCreate; i++) {
117 sources[i] = this.context.createBufferSource(); 120 sources[i] = this.context.createBufferSource();
118 panners[i] = this.context.createStereoPanner(); 121 panners[i] = this.context.createStereoPanner();
119 sources[i].connect(panners[i]); 122 sources[i].connect(panners[i]);
120 panners[i].connect(this.context.destination); 123 panners[i].connect(this.context.destination);
121 sources[i].buffer = impulse; 124 sources[i].buffer = impulse;
122 panners[i].pan.value = this.panPositions[i] = panStep * i - 2; 125 panners[i].pan.value = this.panPositions[i] = panStep * i - this.panLimit;
123 126
124 // Store the onset time position of impulse. 127 // Store the onset time position of impulse.
125 this.onsets[i] = gTimeStep * i; 128 this.onsets[i] = gTimeStep * i;
126 129
127 sources[i].start(this.onsets[i]); 130 sources[i].start(this.onsets[i]);
128 } 131 }
129 }; 132 };
130 133
131 134
132 Test.prototype.verify = function () { 135 Test.prototype.verify = function () {
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 250
248 251
249 return { 252 return {
250 create: function (options) { 253 create: function (options) {
251 return new Test(options); 254 return new Test(options);
252 } 255 }
253 }; 256 };
254 257
255 })(); 258 })();
256 259
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698