OLD | NEW |
1 function createTestBuffer(context, sampleFrameLength) { | 1 function createTestBuffer(context, sampleFrameLength) { |
2 var audioBuffer = context.createBuffer(1, sampleFrameLength, context.sampleR
ate); | 2 var audioBuffer = context.createBuffer(1, sampleFrameLength, context.sampleR
ate); |
3 var channelData = audioBuffer.getChannelData(0); | 3 var channelData = audioBuffer.getChannelData(0); |
4 | 4 |
5 // Create a simple linear ramp starting at zero, with each value in the buff
er equal to its index position. | 5 // Create a simple linear ramp starting at zero, with each value in the buff
er equal to its index position. |
6 for (var i = 0; i < sampleFrameLength; ++i) | 6 for (var i = 0; i < sampleFrameLength; ++i) |
7 channelData[i] = i; | 7 channelData[i] = i; |
8 | 8 |
9 return audioBuffer; | 9 return audioBuffer; |
10 } | 10 } |
(...skipping 27 matching lines...) Expand all Loading... |
38 | 38 |
39 // Verify that the output matches | 39 // Verify that the output matches |
40 for (var j = 0; j < framesToTest; ++j) { | 40 for (var j = 0; j < framesToTest; ++j) { |
41 if (expected[j] != renderedData[offsetFrame + j]) { | 41 if (expected[j] != renderedData[offsetFrame + j]) { |
42 // Copy from Float32Array to regular JavaScript array for error mess
age. | 42 // Copy from Float32Array to regular JavaScript array for error mess
age. |
43 var renderedArray = new Array(); | 43 var renderedArray = new Array(); |
44 for (var j = 0; j < test.renderFrames; ++j) | 44 for (var j = 0; j < test.renderFrames; ++j) |
45 renderedArray[j] = renderedData[offsetFrame + j]; | 45 renderedArray[j] = renderedData[offsetFrame + j]; |
46 | 46 |
47 var s = description + ": expected: " + expected + " actual: " + rend
eredArray; | 47 var s = description + ": expected: " + expected + " actual: " + rend
eredArray; |
48 testFailed(s); | |
49 success = false; | 48 success = false; |
| 49 Should(s, success).beEqualTo(true); |
50 break; | 50 break; |
51 } | 51 } |
52 } | 52 } |
53 | 53 |
54 // Verify that we get all zeroes after the buffer (or duration) has passed. | 54 // Verify that we get all zeroes after the buffer (or duration) has passed. |
55 for (var j = framesToTest; j < testSpacingFrames; ++j) { | 55 for (var j = framesToTest; j < testSpacingFrames; ++j) { |
56 if (renderedData[offsetFrame + j]) { | 56 if (renderedData[offsetFrame + j]) { |
57 // Copy from Float32Array to regular JavaScript array for error mess
age. | 57 // Copy from Float32Array to regular JavaScript array for error mess
age. |
58 var renderedArray = new Array(); | 58 var renderedArray = new Array(); |
59 for (var j = framesToTest; j < testSpacingFrames; ++j) | 59 for (var j = framesToTest; j < testSpacingFrames; ++j) |
60 renderedArray[j - framesToTest] = renderedData[offsetFrame + j]; | 60 renderedArray[j - framesToTest] = renderedData[offsetFrame + j]; |
61 | 61 |
62 var s = description + ": expected: all zeroes actual: " + renderedAr
ray; | 62 var s = description + ": expected: all zeroes actual: " + renderedAr
ray; |
63 testFailed(s); | |
64 success = false; | 63 success = false; |
| 64 Should(s, success).beEqualTo(true); |
65 break; | 65 break; |
66 } | 66 } |
67 } | 67 } |
68 | 68 |
69 if (success) | 69 Should("", success) |
70 testPassed(description); | 70 .summarize(description, description); |
71 | 71 |
72 return success; | 72 return success; |
73 } | 73 } |
74 | 74 |
75 function checkAllTests(event) { | 75 function checkAllTests(event) { |
76 var renderedBuffer = event.renderedBuffer; | 76 var renderedBuffer = event.renderedBuffer; |
77 for (var i = 0; i < tests.length; ++i) | 77 for (var i = 0; i < tests.length; ++i) |
78 checkSingleTest(renderedBuffer, i); | 78 checkSingleTest(renderedBuffer, i); |
79 | 79 |
80 finishJSTest(); | 80 finishJSTest(); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 | 113 |
114 // The oscillator output should be amplified accordingly to drive the | 114 // The oscillator output should be amplified accordingly to drive the |
115 // modulation within the desired range. | 115 // modulation within the desired range. |
116 lfo.connect(amp); | 116 lfo.connect(amp); |
117 amp.connect(phasor[modTarget]); | 117 amp.connect(phasor[modTarget]); |
118 | 118 |
119 phasor.connect(context.destination); | 119 phasor.connect(context.destination); |
120 | 120 |
121 lfo.start(); | 121 lfo.start(); |
122 phasor.start(); | 122 phasor.start(); |
123 } | 123 } |
OLD | NEW |