| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 | 2 |
| 3 <!-- | 3 <!-- |
| 4 Tests that GainNode is properly scaling the gain. | 4 Tests that GainNode is properly scaling the gain. |
| 5 We'll render 11 notes, starting at a gain of 1.0, decreasing in gain by 0.1. | 5 We'll render 11 notes, starting at a gain of 1.0, decreasing in gain by 0.1. |
| 6 The 11th note will be of gain 0.0, so it should be silent (at the end in the ren
dered output). | 6 The 11th note will be of gain 0.0, so it should be silent (at the end in the ren
dered output). |
| 7 --> | 7 --> |
| 8 | 8 |
| 9 <html> | 9 <html> |
| 10 <head> | 10 <head> |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 | 52 |
| 53 let gainNode = context.createGain(); | 53 let gainNode = context.createGain(); |
| 54 gainNode.gain.value = gain; | 54 gainNode.gain.value = gain; |
| 55 | 55 |
| 56 source.connect(gainNode); | 56 source.connect(gainNode); |
| 57 gainNode.connect(context.destination); | 57 gainNode.connect(context.destination); |
| 58 | 58 |
| 59 source.start(time); | 59 source.start(time); |
| 60 } | 60 } |
| 61 | 61 |
| 62 audit.define('create context', function(task, should) { | 62 audit.define({ |
| 63 task.describe('Create context for test'); | 63 label: 'create context', |
| 64 description: 'Create context for test' |
| 65 }, function(task, should) { |
| 64 // Create offline audio context. | 66 // Create offline audio context. |
| 65 context = | 67 context = |
| 66 new OfflineAudioContext(2, sampleRate * lengthInSeconds, sampleRate); | 68 new OfflineAudioContext(2, sampleRate * lengthInSeconds, sampleRate); |
| 67 task.done(); | 69 task.done(); |
| 68 }); | 70 }); |
| 69 | 71 |
| 70 audit.define('load-ref', function(task, should) { | 72 audit.define({ |
| 71 task.describe('Load reference audio file'); | 73 label: 'load-ref', |
| 74 description: 'Load reference audio file' |
| 75 }, function(task, should) { |
| 72 let bufferLoader = | 76 let bufferLoader = |
| 73 new BufferLoader(context, ['gain-expected.wav'], bufferList => { | 77 new BufferLoader(context, ['gain-expected.wav'], bufferList => { |
| 74 reference = bufferList[0].getChannelData(0); | 78 reference = bufferList[0].getChannelData(0); |
| 75 task.done(); | 79 task.done(); |
| 76 }); | 80 }); |
| 77 | 81 |
| 78 bufferLoader.load(); | 82 bufferLoader.load(); |
| 79 }); | 83 }); |
| 80 | 84 |
| 81 audit.define('test', function(task, should) { | 85 audit.define({ |
| 82 task.describe('GainNode functionality'); | 86 label: 'test', |
| 87 description: 'GainNode functionality' |
| 88 }, function(task, should) { |
| 83 | 89 |
| 84 // Create a buffer for a short "note". | 90 // Create a buffer for a short "note". |
| 85 sinWaveBuffer = createSinWaveBuffer(bufferDurationSeconds, 880.0); | 91 sinWaveBuffer = createSinWaveBuffer(bufferDurationSeconds, 880.0); |
| 86 | 92 |
| 87 // Render 11 notes, starting at a gain of 1.0, decreasing in gain by 0.1. | 93 // Render 11 notes, starting at a gain of 1.0, decreasing in gain by 0.1. |
| 88 // The last note will be of gain 0.0, so shouldn't be perceptible in the | 94 // The last note will be of gain 0.0, so shouldn't be perceptible in the |
| 89 // rendered output. | 95 // rendered output. |
| 90 for (let i = 0; i < numberOfNotes; ++i) { | 96 for (let i = 0; i < numberOfNotes; ++i) { |
| 91 let time = i * noteSpacing; | 97 let time = i * noteSpacing; |
| 92 let gain = 1.0 - i / (numberOfNotes - 1); | 98 let gain = 1.0 - i / (numberOfNotes - 1); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 104 }) | 110 }) |
| 105 .then(() => task.done()); | 111 .then(() => task.done()); |
| 106 ; | 112 ; |
| 107 }); | 113 }); |
| 108 | 114 |
| 109 audit.run(); | 115 audit.run(); |
| 110 </script> | 116 </script> |
| 111 | 117 |
| 112 </body> | 118 </body> |
| 113 </html> | 119 </html> |
| OLD | NEW |