Diff
Modified: trunk/LayoutTests/ChangeLog (92703 => 92704)
--- trunk/LayoutTests/ChangeLog 2011-08-09 20:18:05 UTC (rev 92703)
+++ trunk/LayoutTests/ChangeLog 2011-08-09 20:26:15 UTC (rev 92704)
@@ -1,3 +1,22 @@
+2011-08-09 Chris Rogers <[email protected]>
+
+ Add more Web Audio layout tests
+ https://bugs.webkit.org/show_bug.cgi?id=65786
+
+ Reviewed by Kenneth Russell.
+
+ * webaudio/audiobuffersource-expected.wav: Added.
+ * webaudio/audiobuffersource-playbackrate-expected.wav: Added.
+ * webaudio/audiobuffersource-playbackrate.html: Added.
+ * webaudio/audiobuffersource.html: Added.
+ * webaudio/mixing-expected.wav: Added.
+ * webaudio/mixing.html: Added.
+ * webaudio/resources/hyper-reality: Added.
+ * webaudio/resources/hyper-reality/br-jam-loop.wav: Added.
+ * webaudio/resources/hyper-reality/laughter.wav: Added.
+ * webaudio/sample-accurate-scheduling-expected.txt: Added.
+ * webaudio/sample-accurate-scheduling.html: Added.
+
2011-08-09 Anders Carlsson <[email protected]>
More Lion skipped list goodness.
Added: trunk/LayoutTests/webaudio/audiobuffersource-expected.wav
(Binary files differ)
Property changes on: trunk/LayoutTests/webaudio/audiobuffersource-expected.wav
___________________________________________________________________
Added: svn:mime-type
Added: trunk/LayoutTests/webaudio/audiobuffersource-playbackrate-expected.wav
(Binary files differ)
Property changes on: trunk/LayoutTests/webaudio/audiobuffersource-playbackrate-expected.wav
___________________________________________________________________
Added: svn:mime-type
Added: trunk/LayoutTests/webaudio/audiobuffersource-playbackrate.html (0 => 92704)
--- trunk/LayoutTests/webaudio/audiobuffersource-playbackrate.html (rev 0)
+++ trunk/LayoutTests/webaudio/audiobuffersource-playbackrate.html 2011-08-09 20:26:15 UTC (rev 92704)
@@ -0,0 +1,101 @@
+<!DOCTYPE html>
+
+<!--
+Tests that AudioBufferSourceNode can playback at different rates properly.
+Render 72 notes over a 6 octave range.
+-->
+
+<html>
+<head>
+<script type="text/_javascript_" src=""
+<script type="text/_javascript_" src=""
+
+</head>
+<body>
+
+<script>
+
+window._onload_ = init;
+
+var sampleRate = 44100.0;
+var numberOfNotes = 72; // play over a 6 octave range
+var noteDuration = 0.050;
+var noteSpacing = noteDuration + 0.005; // leave 5ms of silence between each "note"
+var lengthInSeconds = numberOfNotes * noteSpacing;
+
+var context = 0;
+var sinWaveBuffer = 0;
+
+function createOneCycleSinWaveBuffer(frequency, sampleRate) {
+ var duration = 1 / frequency;
+ var sampleFrameLength = duration * sampleRate;
+
+ var audioBuffer = context.createBuffer(2, sampleFrameLength, sampleRate);
+
+ var n = audioBuffer.length;
+ var channelL = audioBuffer.getChannelData(0);
+ var channelR = audioBuffer.getChannelData(1);
+
+ for (var i = 0; i < n; ++i) {
+ channelL[i] = Math.sin(frequency * 2.0*Math.PI * i / sampleRate);
+ channelR[i] = channelL[i];
+ }
+
+ return audioBuffer;
+}
+
+function playNote(time, duration, playbackRate) {
+ var source = context.createBufferSource();
+ source.buffer = sinWaveBuffer;
+ source.playbackRate.value = playbackRate;
+
+ var gainNode = context.createGainNode();
+ source.connect(gainNode);
+ gainNode.connect(context.destination);
+
+ // Loop and play for the given duration.
+ source.loop = true;
+ source.noteOn(time);
+ source.noteOff(time + duration);
+
+ // Apply quick fade-in and fade-out to avoid clicks.
+ gainNode.gain.value = 0;
+ gainNode.gain.setValueAtTime(0, time);
+ gainNode.gain.linearRampToValueAtTime(1, time + 0.005);
+ gainNode.gain.setValueAtTime(1, time + duration - 0.005);
+ gainNode.gain.linearRampToValueAtTime(0, time + duration);
+}
+
+function init() {
+ if (!window.layoutTestController)
+ return;
+
+ // Create offline audio context.
+ context = new webkitAudioContext(2, sampleRate * lengthInSeconds, sampleRate);
+
+ // Create a single cycle of a sine wave.
+ // We'll loop this to play notes of a given duration, at a given playback rate.
+ sinWaveBuffer = createOneCycleSinWaveBuffer(440.0, sampleRate);
+
+ // Play 48 notes over a 4 octave range.
+ for (var i = 0; i < numberOfNotes; ++i) {
+ var time = i * noteSpacing;
+
+ var semitone = i - numberOfNotes/2; // start three octaves down
+
+ // Convert from semitone to rate.
+ var playbackRate = Math.pow(2, semitone / 12);
+
+ playNote(time, noteDuration, playbackRate);
+ }
+
+ context._oncomplete_ = finishAudioTest;
+ context.startRendering();
+
+ layoutTestController.waitUntilDone();
+}
+
+</script>
+
+</body>
+</html>
Added: trunk/LayoutTests/webaudio/audiobuffersource.html (0 => 92704)
--- trunk/LayoutTests/webaudio/audiobuffersource.html (rev 0)
+++ trunk/LayoutTests/webaudio/audiobuffersource.html 2011-08-09 20:26:15 UTC (rev 92704)
@@ -0,0 +1,56 @@
+<!DOCTYPE html>
+
+<!--
+See if we can load an AudioBuffer, create an AudioBufferSourceNode, attach the buffer to it, then play it.
+-->
+
+<html>
+<head>
+<script type="text/_javascript_" src=""
+<script type="text/_javascript_" src=""
+
+<script>
+
+window._onload_ = init;
+
+var sampleRate = 44100.0;
+var lengthInSeconds = 2;
+
+var context = 0;
+var bufferLoader = 0;
+
+function init() {
+ if (!window.layoutTestController)
+ return;
+
+ // Create offline audio context.
+ context = new webkitAudioContext(2, sampleRate * lengthInSeconds, sampleRate);
+
+ bufferLoader = new BufferLoader(
+ context,
+ [
+ "resources/hyper-reality/br-jam-loop.wav",
+ ],
+ finishedLoading
+ );
+
+ bufferLoader.load();
+ layoutTestController.waitUntilDone();
+}
+
+function finishedLoading(bufferList) {
+ var bufferSource = context.createBufferSource();
+ bufferSource.buffer = bufferList[0];
+
+ bufferSource.connect(context.destination);
+ bufferSource.noteOn(0);
+
+ context._oncomplete_ = finishAudioTest;
+ context.startRendering();
+}
+
+</script>
+</head>
+<body>
+</body>
+</html>
Added: trunk/LayoutTests/webaudio/mixing-expected.wav
(Binary files differ)
Property changes on: trunk/LayoutTests/webaudio/mixing-expected.wav
___________________________________________________________________
Added: svn:mime-type
Added: trunk/LayoutTests/webaudio/mixing.html (0 => 92704)
--- trunk/LayoutTests/webaudio/mixing.html (rev 0)
+++ trunk/LayoutTests/webaudio/mixing.html 2011-08-09 20:26:15 UTC (rev 92704)
@@ -0,0 +1,65 @@
+<!DOCTYPE html>
+
+<!--
+Create two sources and play them simultaneously. This tests unity-gain summing of AudioNode inputs.
+The result should be some laughing playing at the same time as the drumming.
+-->
+
+<html>
+<head>
+<script type="text/_javascript_" src=""
+<script type="text/_javascript_" src=""
+
+</head>
+<body>
+
+<script>
+
+window._onload_ = init;
+
+var sampleRate = 44100.0;
+var lengthInSeconds = 2;
+
+var context = 0;
+var bufferLoader = 0;
+
+function init() {
+ if (!window.layoutTestController)
+ return;
+
+ // Create offline audio context.
+ context = new webkitAudioContext(2, sampleRate * lengthInSeconds, sampleRate);
+
+ bufferLoader = new BufferLoader(
+ context,
+ [
+ "resources/hyper-reality/br-jam-loop.wav",
+ "resources/hyper-reality/laughter.wav",
+ ],
+ finishedLoading
+ );
+
+ bufferLoader.load();
+ layoutTestController.waitUntilDone();
+}
+
+function finishedLoading(bufferList) {
+ // Create two sources and play them at the same time.
+ var source1 = context.createBufferSource();
+ var source2 = context.createBufferSource();
+ source1.buffer = bufferList[0];
+ source2.buffer = bufferList[1];
+
+ source1.connect(context.destination);
+ source2.connect(context.destination);
+ source1.noteOn(0);
+ source2.noteOn(0);
+
+ context._oncomplete_ = finishAudioTest;
+ context.startRendering();
+}
+
+</script>
+
+</body>
+</html>
Added: trunk/LayoutTests/webaudio/resources/hyper-reality/br-jam-loop.wav
(Binary files differ)
Property changes on: trunk/LayoutTests/webaudio/resources/hyper-reality/br-jam-loop.wav
___________________________________________________________________
Added: svn:mime-type
Added: trunk/LayoutTests/webaudio/resources/hyper-reality/laughter.wav
(Binary files differ)
Property changes on: trunk/LayoutTests/webaudio/resources/hyper-reality/laughter.wav
___________________________________________________________________
Added: svn:mime-type
Added: trunk/LayoutTests/webaudio/sample-accurate-scheduling-expected.txt (0 => 92704)
--- trunk/LayoutTests/webaudio/sample-accurate-scheduling-expected.txt (rev 0)
+++ trunk/LayoutTests/webaudio/sample-accurate-scheduling-expected.txt 2011-08-09 20:26:15 UTC (rev 92704)
@@ -0,0 +1,9 @@
+Tests sample-accurate scheduling.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+PASS All events rendered with sample-accuracy.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/webaudio/sample-accurate-scheduling.html (0 => 92704)
--- trunk/LayoutTests/webaudio/sample-accurate-scheduling.html (rev 0)
+++ trunk/LayoutTests/webaudio/sample-accurate-scheduling.html 2011-08-09 20:26:15 UTC (rev 92704)
@@ -0,0 +1,122 @@
+<!DOCTYPE html>
+
+<!--
+Tests that we are able to schedule a series of notes to playback with sample-accuracy.
+We use an impulse so we can tell exactly where the rendering is happening.
+-->
+
+<html>
+<head>
+<link rel="stylesheet" href=""
+<script src=""
+<script type="text/_javascript_" src=""
+<script type="text/_javascript_" src=""
+</head>
+
+<body>
+
+<div id="description"></div>
+<div id="console"></div>
+
+<script>
+description("Tests sample-accurate scheduling.");
+
+var sampleRate = 44100.0;
+var lengthInSeconds = 4;
+
+var context = 0;
+var bufferLoader = 0;
+var impulse;
+
+// See if we can render at exactly these sample offsets.
+var sampleOffsets = [0, 3, 512, 517, 1000, 1005, 20000, 21234, 37590];
+
+function createImpulse() {
+ // An impulse has a value of 1 at time 0, and is otherwise 0.
+ impulse = context.createBuffer(2, 512, sampleRate);
+ var sampleDataL = impulse.getChannelData(0);
+ var sampleDataR = impulse.getChannelData(1);
+ sampleDataL[0] = 1.0;
+ sampleDataR[0] = 1.0;
+}
+
+function playNote(time) {
+ var bufferSource = context.createBufferSource();
+ bufferSource.buffer = impulse;
+ bufferSource.connect(context.destination);
+ bufferSource.noteOn(time);
+}
+
+function checkSampleAccuracy(event) {
+ var buffer = event.renderedBuffer;
+
+ var bufferDataL = buffer.getChannelData(0);
+ var bufferDataR = buffer.getChannelData(1);
+
+ var success = true;
+
+ // Go through every sample and make sure it's 0, except at positions in sampleOffsets.
+ for (var i = 0; i < buffer.length; ++i) {
+ // Make sure left == right
+ if (bufferDataL[i] != bufferDataR[i]) {
+ testFailed("Rendered buffer left and right channels are not identical.");
+ success = false;
+ break;
+ }
+
+ if (bufferDataL[i] != 0) {
+ // Make sure this index is in sampleOffsets
+ var found = false;
+ for (var j = 0; j < sampleOffsets.length; ++j) {
+ if (sampleOffsets[j] == i) {
+ found = true;
+ break;
+ }
+ }
+
+ if (!found) {
+ testFailed("Non-zero sample found at wrong sample offset.");
+ success = false;
+ break;
+ }
+ }
+ }
+
+ if (success) {
+ testPassed("All events rendered with sample-accuracy.");
+ } else {
+ testFailed("Events NOT rendered with sample-accuracy.");
+ }
+
+ finishJSTest();
+}
+
+function runTest() {
+ if (window.layoutTestController) {
+ layoutTestController.dumpAsText();
+ layoutTestController.waitUntilDone();
+ }
+
+ window.jsTestIsAsync = true;
+
+ // Create offline audio context.
+ context = new webkitAudioContext(2, sampleRate * lengthInSeconds, sampleRate);
+ createImpulse();
+
+ for (var i = 0; i < sampleOffsets.length; ++i) {
+ var timeInSeconds = sampleOffsets[i] * sampleRate;
+ playNote(timeInSeconds);
+ }
+
+ context._oncomplete_ = checkSampleAccuracy;
+ context.startRendering();
+}
+
+runTest();
+successfullyParsed = true;
+
+</script>
+
+<script src=""
+</body>
+</html>