| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 | 2 |
| 3 <!-- | 3 <!-- |
| 4 Tests that AudioBufferSourceNode can playback at different rates properly. | 4 Tests that AudioBufferSourceNode can playback at different rates properly. |
| 5 Render 60 notes over a 5 octave range. | 5 Render 60 notes over a 5 octave range. |
| 6 --> | 6 --> |
| 7 | 7 |
| 8 <html> | 8 <html> |
| 9 <head> | 9 <head> |
| 10 <script type="text/javascript" src="resources/audio-testing.js"></script> | 10 <script type="text/javascript" src="resources/audio-testing.js"></script> |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 gainNode.gain.linearRampToValueAtTime(1, time + 0.005); | 64 gainNode.gain.linearRampToValueAtTime(1, time + 0.005); |
| 65 gainNode.gain.setValueAtTime(1, time + duration - 0.005); | 65 gainNode.gain.setValueAtTime(1, time + duration - 0.005); |
| 66 gainNode.gain.linearRampToValueAtTime(0, time + duration); | 66 gainNode.gain.linearRampToValueAtTime(0, time + duration); |
| 67 } | 67 } |
| 68 | 68 |
| 69 function init() { | 69 function init() { |
| 70 if (!window.testRunner) | 70 if (!window.testRunner) |
| 71 return; | 71 return; |
| 72 | 72 |
| 73 // Create offline audio context. | 73 // Create offline audio context. |
| 74 context = new webkitOfflineAudioContext(2, sampleRate * lengthInSeconds, sam
pleRate); | 74 context = new OfflineAudioContext(2, sampleRate * lengthInSeconds, sampleRat
e); |
| 75 | 75 |
| 76 // Create a single cycle of a sine wave. | 76 // Create a single cycle of a sine wave. |
| 77 // We'll loop this to play notes of a given duration, at a given playback ra
te. | 77 // We'll loop this to play notes of a given duration, at a given playback ra
te. |
| 78 sinWaveBuffer = createOneCycleSinWaveBuffer(440.0, sampleRate); | 78 sinWaveBuffer = createOneCycleSinWaveBuffer(440.0, sampleRate); |
| 79 | 79 |
| 80 // Play 60 notes over a 5 octave range. | 80 // Play 60 notes over a 5 octave range. |
| 81 for (var i = 0; i < numberOfNotes; ++i) { | 81 for (var i = 0; i < numberOfNotes; ++i) { |
| 82 var time = i * noteSpacing; | 82 var time = i * noteSpacing; |
| 83 | 83 |
| 84 var semitone = i - numberOfNotes/2; // start three octaves down | 84 var semitone = i - numberOfNotes/2; // start three octaves down |
| 85 | 85 |
| 86 // Convert from semitone to rate. | 86 // Convert from semitone to rate. |
| 87 var playbackRate = Math.pow(2, semitone / 12); | 87 var playbackRate = Math.pow(2, semitone / 12); |
| 88 | 88 |
| 89 playNote(time, noteDuration, playbackRate); | 89 playNote(time, noteDuration, playbackRate); |
| 90 } | 90 } |
| 91 | 91 |
| 92 context.oncomplete = finishAudioTest; | 92 context.oncomplete = finishAudioTest; |
| 93 context.startRendering(); | 93 context.startRendering(); |
| 94 | 94 |
| 95 testRunner.waitUntilDone(); | 95 testRunner.waitUntilDone(); |
| 96 } | 96 } |
| 97 | 97 |
| 98 </script> | 98 </script> |
| 99 | 99 |
| 100 </body> | 100 </body> |
| 101 </html> | 101 </html> |
| OLD | NEW |