# HG changeset patch # User Nicholas Jillings # Date 1442226158 -3600 # Node ID be9e15805532962e75d908517d73460d92ae3fab # Parent 36a0054a0ee0348e054d3876196ce281379a8308 Bug #1391: Fixed for non-looped playback diff -r 36a0054a0ee0 -r be9e15805532 ape.js --- a/ape.js Mon Sep 14 09:23:49 2015 +0100 +++ b/ape.js Mon Sep 14 11:22:38 2015 +0100 @@ -467,31 +467,27 @@ // Onclick, switch playback to that track this.trackSliderObj.onclick = function(event) { - // Start the test on first click, that way timings are more accurate. - audioEngineContext.play(); - if (audioEngineContext.audioObjectsReady) { - // Cannot continue to issue play command until audioObjects reported as ready! - // Get the track ID from the object ID - var element; - if (event.currentTarget.nodeName == "SPAN") { - element = event.currentTarget.parentNode; - } else { - element = event.currentTarget; - } - var id = Number(element.attributes['trackIndex'].value); - //audioEngineContext.metric.sliderPlayed(id); - audioEngineContext.play(id); - // Currently playing track red, rest green - - //document.getElementById('track-slider-'+index).style.backgroundColor = "#FF0000"; - $('.track-slider').removeClass('track-slider-playing'); - $(element).addClass('track-slider-playing'); - $('.comment-div').removeClass('comment-box-playing'); - $('#comment-div-'+id).addClass('comment-box-playing'); - var outsideReference = document.getElementById('outside-reference'); - if (outsideReference != undefined) - $(outsideReference).removeClass('track-slider-playing'); + // Cannot continue to issue play command until audioObjects reported as ready! + // Get the track ID from the object ID + var element; + if (event.currentTarget.nodeName == "SPAN") { + element = event.currentTarget.parentNode; + } else { + element = event.currentTarget; } + var id = Number(element.attributes['trackIndex'].value); + //audioEngineContext.metric.sliderPlayed(id); + audioEngineContext.play(id); + // Currently playing track red, rest green + + //document.getElementById('track-slider-'+index).style.backgroundColor = "#FF0000"; + $('.track-slider').removeClass('track-slider-playing'); + $(element).addClass('track-slider-playing'); + $('.comment-div').removeClass('comment-box-playing'); + $('#comment-div-'+id).addClass('comment-box-playing'); + var outsideReference = document.getElementById('outside-reference'); + if (outsideReference != undefined) + $(outsideReference).removeClass('track-slider-playing'); }; this.enable = function() { diff -r 36a0054a0ee0 -r be9e15805532 core.js --- a/core.js Mon Sep 14 09:23:49 2015 +0100 +++ b/core.js Mon Sep 14 11:22:38 2015 +0100 @@ -714,7 +714,6 @@ // Use this to detect playback state: 0 - stopped, 1 - playing this.status = 0; - this.audioObjectsReady = false; // Connect both gains to output this.outputGain.connect(audioContext.destination); @@ -732,21 +731,24 @@ this.play = function(id) { // Start the timer and set the audioEngine state to playing (1) - if (this.status == 0) { + if (this.status == 0 && this.loopPlayback) { // Check if all audioObjects are ready - if (this.audioObjectsReady == false) { - this.audioObjectsReady = this.checkAllReady(); - } - if (this.audioObjectsReady == true) { - this.timer.startTest(); - if (this.loopPlayback) - {this.setSynchronousLoop();} + if(this.checkAllReady()) + { this.status = 1; + this.setSynchronousLoop(); } } + else + { + this.status = 1; + } if (this.status== 1) { + this.timer.startTest(); if (id == undefined) { id = -1; + console.log('FATAL - Passed id was undefined - AudioEngineContext.play(id)'); + return; } else { interfaceContext.playhead.setTimePerPixel(this.audioObjects[id]); } @@ -833,40 +835,37 @@ this.setSynchronousLoop = function() { // Pads the signals so they are all exactly the same length - if (this.audioObjectsReady) + var length = 0; + var lens = []; + var maxId; + for (var i=0; i