changeset 2925:21d548eb40f1

Fix for #226
author Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk>
date Wed, 06 Sep 2017 14:07:14 +0100
parents 4ae62d4c5c6d
children 151fae569ce9
files js/loudness.js
diffstat 1 files changed, 2 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/js/loudness.js	Wed Sep 06 13:40:23 2017 +0100
+++ b/js/loudness.js	Wed Sep 06 14:07:14 2017 +0100
@@ -31,7 +31,7 @@
         target = -23;
     }
     if (offlineContext === undefined) {
-        offlineContext = new OfflineAudioContext(audioContext.destination.channelCount, buffer.buffer.duration * audioContext.sampleRate, audioContext.sampleRate);
+        offlineContext = new OfflineAudioContext(audioContext.destination.channelCount, Math.max(0.4, buffer.buffer.duration) * audioContext.sampleRate, audioContext.sampleRate);
     }
     // Create the required filters
     var KFilter = offlineContext.createBiquadFilter();
@@ -80,7 +80,7 @@
     var frame_size = Math.floor(buffer.sampleRate * frame_dur);
     var step_size = Math.floor(frame_size * (1.0 - frame_overlap));
     var num_frames = Math.floor((buffer.length - frame_size) / step_size);
-    num_frames = Math.max(num_frames, 0);
+    num_frames = Math.max(num_frames, 1);
 
     var MS = Array(buffer.numberOfChannels);
     for (var c = 0; c < buffer.numberOfChannels; c++) {