Mercurial > hg > webaudioevaluationtool
comparison loudness.js @ 471:3a9b869ba7f8 Dev_main
Better loudness calculation. Buffer ready not called until after loudness calculation to avoid NaNs on gain. <survey> nodes do not need to be present, no survey then no node. Added example boilerplate interface with all required functions and brief descriptions.
author | Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk> |
---|---|
date | Wed, 13 Jan 2016 10:31:31 +0000 |
parents | dbd3e7f52766 |
children | d39c99d83891 |
comparison
equal
deleted
inserted
replaced
470:1330c77d212c | 471:3a9b869ba7f8 |
---|---|
32 { | 32 { |
33 target = -23; | 33 target = -23; |
34 } | 34 } |
35 if (offlineContext == undefined) | 35 if (offlineContext == undefined) |
36 { | 36 { |
37 offlineContext = new OfflineAudioContext(buffer.numberOfChannels, buffer.length, buffer.sampleRate); | 37 offlineContext = new OfflineAudioContext(buffer.buffer.numberOfChannels, buffer.buffer.length, buffer.buffer.sampleRate); |
38 } | 38 } |
39 // Create the required filters | 39 // Create the required filters |
40 var KFilter = offlineContext.createBiquadFilter(); | 40 var KFilter = offlineContext.createBiquadFilter(); |
41 KFilter.type = "highshelf"; | 41 KFilter.type = "highshelf"; |
42 KFilter.gain.value = 4; | 42 KFilter.gain.value = 4; |
46 HPFilter.type = "highpass"; | 46 HPFilter.type = "highpass"; |
47 HPFilter.Q.value = 0.707; | 47 HPFilter.Q.value = 0.707; |
48 HPFilter.frequency.value = 60; | 48 HPFilter.frequency.value = 60; |
49 // copy Data into the process buffer | 49 // copy Data into the process buffer |
50 var processSource = offlineContext.createBufferSource(); | 50 var processSource = offlineContext.createBufferSource(); |
51 processSource.buffer = buffer; | 51 processSource.buffer = buffer.buffer; |
52 | 52 |
53 processSource.connect(KFilter); | 53 processSource.connect(KFilter); |
54 KFilter.connect(HPFilter); | 54 KFilter.connect(HPFilter); |
55 HPFilter.connect(offlineContext.destination); | 55 HPFilter.connect(offlineContext.destination); |
56 processSource.start(); | 56 processSource.start(); |
98 relgateEnergy[c].push(blockEnergy[c][i]); | 98 relgateEnergy[c].push(blockEnergy[c][i]); |
99 } | 99 } |
100 } | 100 } |
101 } | 101 } |
102 var overallRelLoudness = calculateOverallLoudnessFromChannelBlocks(relgateEnergy); | 102 var overallRelLoudness = calculateOverallLoudnessFromChannelBlocks(relgateEnergy); |
103 buffer.lufs = overallRelLoudness; | 103 buffer.buffer.lufs = overallRelLoudness; |
104 buffer.ready(); | |
104 } | 105 } |
105 }; | 106 }; |
106 offlineContext.startRendering(); | 107 offlineContext.startRendering(); |
107 } | 108 } |
108 | 109 |