diff 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
line wrap: on
line diff
--- a/loudness.js	Wed Jan 13 09:34:46 2016 +0000
+++ b/loudness.js	Wed Jan 13 10:31:31 2016 +0000
@@ -34,7 +34,7 @@
 	}
 	if (offlineContext == undefined)
 	{
-		offlineContext = new OfflineAudioContext(buffer.numberOfChannels, buffer.length, buffer.sampleRate);
+		offlineContext = new OfflineAudioContext(buffer.buffer.numberOfChannels, buffer.buffer.length, buffer.buffer.sampleRate);
 	}
 	// Create the required filters
 	var KFilter = offlineContext.createBiquadFilter();
@@ -48,7 +48,7 @@
 	HPFilter.frequency.value = 60;
 	// copy Data into the process buffer
 	var processSource = offlineContext.createBufferSource();
-	processSource.buffer = buffer;
+	processSource.buffer = buffer.buffer;
 	
 	processSource.connect(KFilter);
 	KFilter.connect(HPFilter);
@@ -100,7 +100,8 @@
 				}
 			}
 			var overallRelLoudness = calculateOverallLoudnessFromChannelBlocks(relgateEnergy);
-			buffer.lufs =  overallRelLoudness;
+			buffer.buffer.lufs =  overallRelLoudness;
+			buffer.ready();
 		}
 	};
 	offlineContext.startRendering();