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

Side by Side Diff: LayoutTests/webaudio/resources/oscillator-testing.js

Issue 18182009: WaveTable name has changed to PeriodicWave (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: fix global constructors test Created 7 years, 5 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 | Annotate | Revision Log
OLDNEW
1 // Notes about generated waveforms: 1 // Notes about generated waveforms:
2 // 2 //
3 // QUESTION: Why does the wave shape not look like the exact shape (sharp edges) ? 3 // QUESTION: Why does the wave shape not look like the exact shape (sharp edges) ?
4 // ANSWER: Because a shape with sharp edges has infinitely high frequency conten t. 4 // ANSWER: Because a shape with sharp edges has infinitely high frequency conten t.
5 // Since a digital audio signal must be band-limited based on the nyquist freque ncy (half the sample-rate) 5 // Since a digital audio signal must be band-limited based on the nyquist freque ncy (half the sample-rate)
6 // in order to avoid aliasing, this creates more rounded edges and "ringing" in the 6 // in order to avoid aliasing, this creates more rounded edges and "ringing" in the
7 // appearance of the waveform. See Nyquist-Shannon sampling theorem: 7 // appearance of the waveform. See Nyquist-Shannon sampling theorem:
8 // http://en.wikipedia.org/wiki/Nyquist%E2%80%93Shannon_sampling_theorem 8 // http://en.wikipedia.org/wiki/Nyquist%E2%80%93Shannon_sampling_theorem
9 // 9 //
10 // QUESTION: Why does the very end of the generated signal appear to get slightl y weaker? 10 // QUESTION: Why does the very end of the generated signal appear to get slightl y weaker?
(...skipping 17 matching lines...) Expand all
28 function generateExponentialOscillatorSweep(oscillatorType) { 28 function generateExponentialOscillatorSweep(oscillatorType) {
29 // Create offline audio context. 29 // Create offline audio context.
30 context = new webkitOfflineAudioContext(1, sampleRate * lengthInSeconds, sam pleRate); 30 context = new webkitOfflineAudioContext(1, sampleRate * lengthInSeconds, sam pleRate);
31 31
32 var osc = context.createOscillator(); 32 var osc = context.createOscillator();
33 if (oscillatorType == OSC.CUSTOM) { 33 if (oscillatorType == OSC.CUSTOM) {
34 // Create a simple waveform with three Fourier coefficients. 34 // Create a simple waveform with three Fourier coefficients.
35 // Note the first values are expected to be zero (DC for coeffA and Nyqu ist for coeffB). 35 // Note the first values are expected to be zero (DC for coeffA and Nyqu ist for coeffB).
36 var coeffA = new Float32Array([0, 1, 0.5]); 36 var coeffA = new Float32Array([0, 1, 0.5]);
37 var coeffB = new Float32Array([0, 0, 0]); 37 var coeffB = new Float32Array([0, 0, 0]);
38 var wavetable = context.createWaveTable(coeffA, coeffB); 38 var wave = context.createPeriodicWave(coeffA, coeffB);
39 osc.setWaveTable(wavetable); 39 osc.setPeriodicWave(wave);
40 } else { 40 } else {
41 osc.type = oscillatorType; 41 osc.type = oscillatorType;
42 } 42 }
43 43
44 // Scale by 1/2 to better visualize the waveform and to avoid clipping past full scale. 44 // Scale by 1/2 to better visualize the waveform and to avoid clipping past full scale.
45 var gainNode = context.createGainNode(); 45 var gainNode = context.createGainNode();
46 gainNode.gain.value = 0.5; 46 gainNode.gain.value = 0.5;
47 osc.connect(gainNode); 47 osc.connect(gainNode);
48 gainNode.connect(context.destination); 48 gainNode.connect(context.destination);
49 49
50 osc.start(0); 50 osc.start(0);
51 51
52 var nyquist = 0.5 * sampleRate; 52 var nyquist = 0.5 * sampleRate;
53 osc.frequency.setValueAtTime(10, 0); 53 osc.frequency.setValueAtTime(10, 0);
54 osc.frequency.exponentialRampToValueAtTime(highFrequency, lengthInSeconds); 54 osc.frequency.exponentialRampToValueAtTime(highFrequency, lengthInSeconds);
55 55
56 context.oncomplete = finishAudioTest; 56 context.oncomplete = finishAudioTest;
57 context.startRendering(); 57 context.startRendering();
58 58
59 testRunner.waitUntilDone(); 59 testRunner.waitUntilDone();
60 } 60 }
OLDNEW
« no previous file with comments | « LayoutTests/webaudio/oscillator-custom.html ('k') | LayoutTests/webexposed/global-constructors-listing-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698