comparison core.js @ 538:6d652a6c80ed Dev_main

Merge into dev_main
author Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk>
date Mon, 22 Feb 2016 12:33:56 +0000
parents a95d323a911e df8df0f47b34
children 4a69b3ba474d
comparison
equal deleted inserted replaced
537:2a723261ee3e 538:6d652a6c80ed
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
1057 return; 1059 return;
1058 } else { 1060 } else {
1059 interfaceContext.playhead.setTimePerPixel(this.audioObjects[id]); 1061 interfaceContext.playhead.setTimePerPixel(this.audioObjects[id]);
1060 } 1062 }
1061 if (this.loopPlayback) { 1063 if (this.loopPlayback) {
1062 var setTime = audioContext.currentTime+2; 1064 var setTime = audioContext.currentTime;
1063 for (var i=0; i<this.audioObjects.length; i++) 1065 for (var i=0; i<this.audioObjects.length; i++)
1064 { 1066 {
1065 this.audioObjects[i].play(setTime-2); 1067 this.audioObjects[i].play(setTime);
1066 if (id == i) { 1068 if (id == i) {
1067 this.audioObjects[i].loopStart(setTime); 1069 this.audioObjects[i].loopStart(setTime);
1068 } else { 1070 } else {
1069 this.audioObjects[i].loopStop(setTime); 1071 this.audioObjects[i].loopStop(setTime);
1070 } 1072 }
1319 this.interfaceDOM.startPlayback(); 1321 this.interfaceDOM.startPlayback();
1320 } else { 1322 } else {
1321 this.outputGain.gain.setValueAtTime(0.0,startTime); 1323 this.outputGain.gain.setValueAtTime(0.0,startTime);
1322 } 1324 }
1323 this.bufferNode.start(startTime); 1325 this.bufferNode.start(startTime);
1326 this.bufferNode.playbackStartTime = startTime;
1324 } 1327 }
1325 }; 1328 };
1326 1329
1327 this.stop = function(stopTime) { 1330 this.stop = function(stopTime) {
1328 this.outputGain.gain.cancelScheduledValues(audioContext.currentTime); 1331 this.outputGain.gain.cancelScheduledValues(audioContext.currentTime);
1337 }; 1340 };
1338 1341
1339 this.getCurrentPosition = function() { 1342 this.getCurrentPosition = function() {
1340 var time = audioEngineContext.timer.getTestTime(); 1343 var time = audioEngineContext.timer.getTestTime();
1341 if (this.bufferNode != undefined) { 1344 if (this.bufferNode != undefined) {
1342 if (this.bufferNode.loop == true) { 1345 return (time - this.bufferNode.playbackStartTime)%this.buffer.buffer.duration;
1343 if (audioEngineContext.status == 1) {
1344 return (time-this.metric.listenStart)%this.buffer.buffer.duration;
1345 } else {
1346 return 0;
1347 }
1348 } else {
1349 if (this.metric.listenHold) {
1350 return time - this.metric.listenStart;
1351 } else {
1352 return 0;
1353 }
1354 }
1355 } else { 1346 } else {
1356 return 0; 1347 return 0;
1357 } 1348 }
1358 }; 1349 };
1359 1350
2394 this.trackComment.appendChild(br); 2385 this.trackComment.appendChild(br);
2395 this.trackComment.appendChild(this.trackCommentBox); 2386 this.trackComment.appendChild(this.trackCommentBox);
2396 2387
2397 this.exportXMLDOM = function() { 2388 this.exportXMLDOM = function() {
2398 var root = document.createElement('comment'); 2389 var root = document.createElement('comment');
2399 if (this.audioObject.specification.parent.elementComments) { 2390 var question = document.createElement('question');
2400 var question = document.createElement('question'); 2391 question.textContent = this.trackString.textContent;
2401 question.textContent = this.trackString.textContent; 2392 var response = document.createElement('response');
2402 var response = document.createElement('response'); 2393 response.textContent = this.trackCommentBox.value;
2403 response.textContent = this.trackCommentBox.value; 2394 console.log("Comment frag-"+this.id+": "+response.textContent);
2404 console.log("Comment frag-"+this.id+": "+response.textContent); 2395 root.appendChild(question);
2405 root.appendChild(question); 2396 root.appendChild(response);
2406 root.appendChild(response);
2407 }
2408 return root; 2397 return root;
2409 }; 2398 };
2410 this.resize = function() 2399 this.resize = function()
2411 { 2400 {
2412 var boxwidth = (window.innerWidth-100)/2; 2401 var boxwidth = (window.innerWidth-100)/2;
2443 // Add to the holder. 2432 // Add to the holder.
2444 this.holder.appendChild(this.string); 2433 this.holder.appendChild(this.string);
2445 this.holder.appendChild(br); 2434 this.holder.appendChild(br);
2446 this.holder.appendChild(this.textArea); 2435 this.holder.appendChild(this.textArea);
2447 2436
2448 this.exportXMLDOM = function() { 2437 this.exportXMLDOM = function(storePoint) {
2449 var root = document.createElement('comment'); 2438 var root = storePoint.parent.document.createElement('comment');
2450 root.id = this.specification.id; 2439 root.id = this.specification.id;
2451 root.setAttribute('type',this.specification.type); 2440 root.setAttribute('type',this.specification.type);
2452 root.textContent = this.textArea.value;
2453 console.log("Question: "+this.string.textContent); 2441 console.log("Question: "+this.string.textContent);
2454 console.log("Response: "+root.textContent); 2442 console.log("Response: "+root.textContent);
2443 var question = storePoint.parent.document.createElement('question');
2444 question.textContent = this.string.textContent;
2445 var response = storePoint.parent.document.createElement('response');
2446 response.textContent = this.textArea.value;
2447 root.appendChild(question);
2448 root.appendChild(response);
2449 storePoint.XMLDOM.appendChild(root);
2455 return root; 2450 return root;
2456 }; 2451 };
2457 this.resize = function() 2452 this.resize = function()
2458 { 2453 {
2459 var boxwidth = (window.innerWidth-100)/2; 2454 var boxwidth = (window.innerWidth-100)/2;
2519 this.options.push(input); 2514 this.options.push(input);
2520 } 2515 }
2521 this.holder.appendChild(this.span); 2516 this.holder.appendChild(this.span);
2522 this.holder.appendChild(this.inputs); 2517 this.holder.appendChild(this.inputs);
2523 2518
2524 this.exportXMLDOM = function() { 2519 this.exportXMLDOM = function(storePoint) {
2525 var root = document.createElement('comment'); 2520 var root = storePoint.parent.document.createElement('comment');
2526 root.id = this.specification.id; 2521 root.id = this.specification.id;
2527 root.setAttribute('type',this.specification.type); 2522 root.setAttribute('type',this.specification.type);
2528 var question = document.createElement('question'); 2523 var question = document.createElement('question');
2529 question.textContent = this.string.textContent; 2524 question.textContent = this.string.textContent;
2530 var response = document.createElement('response'); 2525 var response = document.createElement('response');
2543 } 2538 }
2544 console.log('Comment: '+question.textContent); 2539 console.log('Comment: '+question.textContent);
2545 console.log('Response: '+response.textContent); 2540 console.log('Response: '+response.textContent);
2546 root.appendChild(question); 2541 root.appendChild(question);
2547 root.appendChild(response); 2542 root.appendChild(response);
2543 storePoint.XMLDOM.appendChild(root);
2548 return root; 2544 return root;
2549 }; 2545 };
2550 this.resize = function() 2546 this.resize = function()
2551 { 2547 {
2552 var boxwidth = (window.innerWidth-100)/2; 2548 var boxwidth = (window.innerWidth-100)/2;
2630 this.options.push(input); 2626 this.options.push(input);
2631 } 2627 }
2632 this.holder.appendChild(this.span); 2628 this.holder.appendChild(this.span);
2633 this.holder.appendChild(this.inputs); 2629 this.holder.appendChild(this.inputs);
2634 2630
2635 this.exportXMLDOM = function() { 2631 this.exportXMLDOM = function(storePoint) {
2636 var root = document.createElement('comment'); 2632 var root = storePoint.parent.document.createElement('comment');
2637 root.id = this.specification.id; 2633 root.id = this.specification.id;
2638 root.setAttribute('type',this.specification.type); 2634 root.setAttribute('type',this.specification.type);
2639 var question = document.createElement('question'); 2635 var question = document.createElement('question');
2640 question.textContent = this.string.textContent; 2636 question.textContent = this.string.textContent;
2641 root.appendChild(question); 2637 root.appendChild(question);
2645 response.textContent = this.options[i].checked; 2641 response.textContent = this.options[i].checked;
2646 response.setAttribute('name',this.options[i].getAttribute('setvalue')); 2642 response.setAttribute('name',this.options[i].getAttribute('setvalue'));
2647 root.appendChild(response); 2643 root.appendChild(response);
2648 console.log('Response '+response.getAttribute('name') +': '+response.textContent); 2644 console.log('Response '+response.getAttribute('name') +': '+response.textContent);
2649 } 2645 }
2646 storePoint.XMLDOM.appendChild(root);
2650 return root; 2647 return root;
2651 }; 2648 };
2652 this.resize = function() 2649 this.resize = function()
2653 { 2650 {
2654 var boxwidth = (window.innerWidth-100)/2; 2651 var boxwidth = (window.innerWidth-100)/2;
2803 } 2800 }
2804 }; 2801 };
2805 this.stop = function() { 2802 this.stop = function() {
2806 clearInterval(this.interval); 2803 clearInterval(this.interval);
2807 this.interval = undefined; 2804 this.interval = undefined;
2805 this.scrubberHead.style.left = '0px';
2808 if (this.maxTime < 60) { 2806 if (this.maxTime < 60) {
2809 this.curTimeSpan.textContent = '0.00'; 2807 this.curTimeSpan.textContent = '0.00';
2810 } else { 2808 } else {
2811 this.curTimeSpan.textContent = '00:00'; 2809 this.curTimeSpan.textContent = '00:00';
2812 } 2810 }
2840 interfaceContext.volume.valueText.textContent = interfaceContext.volume.valueDB+'dB'; 2838 interfaceContext.volume.valueText.textContent = interfaceContext.volume.valueDB+'dB';
2841 audioEngineContext.outputGain.gain.value = interfaceContext.volume.valueLin; 2839 audioEngineContext.outputGain.gain.value = interfaceContext.volume.valueLin;
2842 } 2840 }
2843 this.slider.onmouseup = function(event) 2841 this.slider.onmouseup = function(event)
2844 { 2842 {
2845 var storePoint = testState.currentStore.XMLDOM.children[0].getAllElementsByName('volumeTracker'); 2843 var storePoint = testState.currentStore.XMLDOM.getElementsByTagName('metric')[0].getAllElementsByName('volumeTracker');
2846 if (storePoint.length == 0) 2844 if (storePoint.length == 0)
2847 { 2845 {
2848 storePoint = storage.document.createElement('metricresult'); 2846 storePoint = storage.document.createElement('metricresult');
2849 storePoint.setAttribute('name','volumeTracker'); 2847 storePoint.setAttribute('name','volumeTracker');
2850 testState.currentStore.XMLDOM.children[0].appendChild(storePoint); 2848 testState.currentStore.XMLDOM.getElementsByTagName('metric')[0].appendChild(storePoint);
2851 } 2849 }
2852 else { 2850 else {
2853 storePoint = storePoint[0]; 2851 storePoint = storePoint[0];
2854 } 2852 }
2855 var node = storage.document.createElement('movement'); 2853 var node = storage.document.createElement('movement');
3140 var ae_metric = this.parent.document.createElement('metric'); 3138 var ae_metric = this.parent.document.createElement('metric');
3141 aeNode.appendChild(ae_metric); 3139 aeNode.appendChild(ae_metric);
3142 this.XMLDOM.appendChild(aeNode); 3140 this.XMLDOM.appendChild(aeNode);
3143 } 3141 }
3144 3142
3145 // Add any commentQuestions
3146 for (var element of this.specification.commentQuestions)
3147 {
3148 var cqNode = this.parent.document.createElement('commentquestion');
3149 cqNode.id = element.id;
3150 cqNode.setAttribute('type',element.type);
3151 var statement = this.parent.document.createElement('statement');
3152 statement.textContent = cqNode.statement;
3153 cqNode.appendChild(statement);
3154 var response = this.parent.document.createElement('response');
3155 cqNode.appendChild(response);
3156 this.XMLDOM.appendChild(cqNode);
3157 }
3158
3159 this.parent.root.appendChild(this.XMLDOM); 3143 this.parent.root.appendChild(this.XMLDOM);
3160 }; 3144 };
3161 this.finish = function() 3145 this.finish = function()
3162 { 3146 {
3163 if (this.state == 0) 3147 if (this.state == 0)