comparison core.js @ 527:df8df0f47b34

Playback now tracks for looped playback exactly.
author Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk>
date Fri, 19 Feb 2016 11:22:47 +0000
parents 97b84a942aff
children 6d652a6c80ed
comparison
equal deleted inserted replaced
526:97b84a942aff 527:df8df0f47b34
19 var projectReturn; // Hold the URL for the return 19 var projectReturn; // Hold the URL for the return
20 20
21 21
22 // Add a prototype to the bufferSourceNode to reference to the audioObject holding it 22 // Add a prototype to the bufferSourceNode to reference to the audioObject holding it
23 AudioBufferSourceNode.prototype.owner = undefined; 23 AudioBufferSourceNode.prototype.owner = undefined;
24 // Add a prototype to the bufferSourceNode to hold when the object was given a play command
25 AudioBufferSourceNode.prototype.playbackStartTime = undefined;
24 // Add a prototype to the bufferNode to hold the desired LINEAR gain 26 // Add a prototype to the bufferNode to hold the desired LINEAR gain
25 AudioBuffer.prototype.playbackGain = undefined; 27 AudioBuffer.prototype.playbackGain = undefined;
26 // Add a prototype to the bufferNode to hold the computed LUFS loudness 28 // Add a prototype to the bufferNode to hold the computed LUFS loudness
27 AudioBuffer.prototype.lufs = undefined; 29 AudioBuffer.prototype.lufs = undefined;
28 30
1317 this.interfaceDOM.startPlayback(); 1319 this.interfaceDOM.startPlayback();
1318 } else { 1320 } else {
1319 this.outputGain.gain.setValueAtTime(0.0,startTime); 1321 this.outputGain.gain.setValueAtTime(0.0,startTime);
1320 } 1322 }
1321 this.bufferNode.start(startTime); 1323 this.bufferNode.start(startTime);
1324 this.bufferNode.playbackStartTime = startTime;
1322 } 1325 }
1323 }; 1326 };
1324 1327
1325 this.stop = function(stopTime) { 1328 this.stop = function(stopTime) {
1326 this.outputGain.gain.cancelScheduledValues(audioContext.currentTime); 1329 this.outputGain.gain.cancelScheduledValues(audioContext.currentTime);
1335 }; 1338 };
1336 1339
1337 this.getCurrentPosition = function() { 1340 this.getCurrentPosition = function() {
1338 var time = audioEngineContext.timer.getTestTime(); 1341 var time = audioEngineContext.timer.getTestTime();
1339 if (this.bufferNode != undefined) { 1342 if (this.bufferNode != undefined) {
1340 if (this.bufferNode.loop == true) { 1343 return (time - this.bufferNode.playbackStartTime)%this.buffer.buffer.duration;
1341 if (audioEngineContext.status == 1) {
1342 return (time-this.metric.listenStart)%this.buffer.buffer.duration;
1343 } else {
1344 return 0;
1345 }
1346 } else {
1347 if (this.metric.listenHold) {
1348 return time - this.metric.listenStart;
1349 } else {
1350 return 0;
1351 }
1352 }
1353 } else { 1344 } else {
1354 return 0; 1345 return 0;
1355 } 1346 }
1356 }; 1347 };
1357 1348
2807 } 2798 }
2808 }; 2799 };
2809 this.stop = function() { 2800 this.stop = function() {
2810 clearInterval(this.interval); 2801 clearInterval(this.interval);
2811 this.interval = undefined; 2802 this.interval = undefined;
2803 this.scrubberHead.style.left = '0px';
2812 if (this.maxTime < 60) { 2804 if (this.maxTime < 60) {
2813 this.curTimeSpan.textContent = '0.00'; 2805 this.curTimeSpan.textContent = '0.00';
2814 } else { 2806 } else {
2815 this.curTimeSpan.textContent = '00:00'; 2807 this.curTimeSpan.textContent = '00:00';
2816 } 2808 }