Mercurial > hg > webaudioevaluationtool
comparison js/core.js @ 2500:32366178b6a8
Fix for #147 and #13
author | Nicholas Jillings <nicholas.jillings@mail.bcu.ac.uk> |
---|---|
date | Tue, 20 Sep 2016 17:55:56 +0100 |
parents | 54782e20bc62 |
children | 6b3d98260a88 |
comparison
equal
deleted
inserted
replaced
2499:54782e20bc62 | 2500:32366178b6a8 |
---|---|
1698 } | 1698 } |
1699 } | 1699 } |
1700 // Extract the audio and zero-pad | 1700 // Extract the audio and zero-pad |
1701 for (var ao of this.audioObjects) { | 1701 for (var ao of this.audioObjects) { |
1702 var lengthDiff = length - ao.buffer.buffer.length; | 1702 var lengthDiff = length - ao.buffer.buffer.length; |
1703 ao.buffer = ao.buffer.copyBuffer(0, samplesToSeconds(lengthDiff, ao.buffer.buffer.sampleRate)); | 1703 if (lengthDiff > 0) { |
1704 ao.buffer.buffer = ao.buffer.copyBuffer(0, samplesToSeconds(lengthDiff, ao.buffer.buffer.sampleRate)); | |
1705 } | |
1704 } | 1706 } |
1705 }; | 1707 }; |
1706 | 1708 |
1707 this.bufferReady = function (id) { | 1709 this.bufferReady = function (id) { |
1708 if (this.checkAllReady()) { | 1710 if (this.checkAllReady()) { |
1764 var preSilenceTime = this.specification.preSilence || this.specification.parent.preSilence || specification.preSilence || 0.0; | 1766 var preSilenceTime = this.specification.preSilence || this.specification.parent.preSilence || specification.preSilence || 0.0; |
1765 var postSilenceTime = this.specification.postSilence || this.specification.parent.postSilence || specification.postSilence || 0.0; | 1767 var postSilenceTime = this.specification.postSilence || this.specification.parent.postSilence || specification.postSilence || 0.0; |
1766 var startTime = this.specification.startTime; | 1768 var startTime = this.specification.startTime; |
1767 var stopTime = this.specification.stopTime; | 1769 var stopTime = this.specification.stopTime; |
1768 var copybuffer = new callee.constructor(); | 1770 var copybuffer = new callee.constructor(); |
1769 if (isFinite(startTime) || isFinite(stopTime)) { | 1771 |
1770 copybuffer.buffer = callee.cropBuffer(startTime, stopTime); | 1772 copybuffer.buffer = callee.cropBuffer(startTime || 0, stopTime || callee.buffer.duration); |
1771 } | |
1772 if (preSilenceTime != 0 || postSilenceTime != 0) { | 1773 if (preSilenceTime != 0 || postSilenceTime != 0) { |
1773 if (copybuffer.buffer == undefined) { | 1774 copybuffer.buffer = copybuffer.copyBuffer(preSilenceTime, postSilenceTime); |
1774 copybuffer.buffer = callee.copyBuffer(preSilenceTime, postSilenceTime); | 1775 } |
1775 } else { | 1776 |
1776 copybuffer.buffer = copybuffer.copyBuffer(preSilenceTime, postSilenceTime); | 1777 copybuffer.lufs = callee.buffer.lufs; |
1777 } | 1778 this.buffer = copybuffer; |
1778 } | |
1779 | 1779 |
1780 var targetLUFS = this.specification.parent.loudness || specification.loudness; | 1780 var targetLUFS = this.specification.parent.loudness || specification.loudness; |
1781 if (typeof targetLUFS === "number" && isFinite(targetLUFS)) { | 1781 if (typeof targetLUFS === "number" && isFinite(targetLUFS)) { |
1782 this.buffer.buffer.playbackGain = decibelToLinear(targetLUFS - this.buffer.buffer.lufs); | 1782 this.buffer.buffer.playbackGain = decibelToLinear(targetLUFS - this.buffer.buffer.lufs); |
1783 } else { | 1783 } else { |