Mercurial > hg > webaudioevaluationtool
comparison core.js @ 1413:568829c2b4a0
STASH: UNSTABLE. Implementing APE multiple sliders.
author | Nicholas Jillings <nickjillings@users.noreply.github.com> |
---|---|
date | Tue, 08 Dec 2015 12:01:48 +0000 |
parents | 28136e188d46 |
children | 3123565e0c49 |
comparison
equal
deleted
inserted
replaced
1412:28136e188d46 | 1413:568829c2b4a0 |
---|---|
647 } | 647 } |
648 }; | 648 }; |
649 | 649 |
650 this.testPageCompleted = function(store, testXML, testId) { | 650 this.testPageCompleted = function(store, testXML, testId) { |
651 // Function called each time a test page has been completed | 651 // Function called each time a test page has been completed |
652 // Can be used to over-rule default behaviour | |
653 var metric = document.createElement('metric'); | 652 var metric = document.createElement('metric'); |
654 if (audioEngineContext.metric.enableTestTimer) | 653 if (audioEngineContext.metric.enableTestTimer) |
655 { | 654 { |
656 var testTime = document.createElement('metricResult'); | 655 var testTime = document.createElement('metricResult'); |
657 testTime.id = 'testTime'; | 656 testTime.id = 'testTime'; |
658 testTime.textContent = audioEngineContext.timer.testDuration; | 657 testTime.textContent = audioEngineContext.timer.testDuration; |
659 metric.appendChild(testTime); | 658 metric.appendChild(testTime); |
660 } | 659 } |
661 testXML.appendChild(metric); | 660 store.appendChild(metric); |
662 var audioObjects = audioEngineContext.audioObjects; | 661 var audioObjects = audioEngineContext.audioObjects; |
663 for (var i=0; i<audioObjects.length; i++) | 662 for (var i=0; i<audioObjects.length; i++) |
664 { | 663 { |
665 var audioElement = audioEngineContext.audioObjects[i].exportXMLDOM(); | 664 var audioElement = audioEngineContext.audioObjects[i].exportXMLDOM(); |
666 audioElement.setAttribute('presentedId',i); | 665 audioElement.setAttribute('presentedId',i); |
667 testXML.appendChild(audioElement); | 666 store.appendChild(audioElement); |
668 } | 667 } |
669 $(interfaceContext.commentQuestions).each(function(index,element){ | 668 $(interfaceContext.commentQuestions).each(function(index,element){ |
670 var node = element.exportXMLDOM(); | 669 var node = element.exportXMLDOM(); |
671 testXML.appendChild(node); | 670 store.appendChild(node); |
672 }); | 671 }); |
673 pageXMLSave(store, testXML); | 672 pageXMLSave(store, testXML); |
674 }; | 673 }; |
675 | 674 |
676 this.initialiseInnerState = function(node) { | 675 this.initialiseInnerState = function(node) { |
912 var length = 0; | 911 var length = 0; |
913 var lens = []; | 912 var lens = []; |
914 var maxId; | 913 var maxId; |
915 for (var i=0; i<this.audioObjects.length; i++) | 914 for (var i=0; i<this.audioObjects.length; i++) |
916 { | 915 { |
917 lens.push(this.audioObjects[i].buffer.length); | 916 lens.push(this.audioObjects[i].buffer.buffer.length); |
918 if (length < this.audioObjects[i].buffer.length) | 917 if (length < this.audioObjects[i].buffer.buffer.length) |
919 { | 918 { |
920 length = this.audioObjects[i].buffer.length; | 919 length = this.audioObjects[i].buffer.buffer.length; |
921 maxId = i; | 920 maxId = i; |
922 } | 921 } |
923 } | 922 } |
924 // Perform difference | 923 // Perform difference |
925 for (var i=0; i<lens.length; i++) | 924 for (var i=0; i<lens.length; i++) |
927 lens[i] = length - lens[i]; | 926 lens[i] = length - lens[i]; |
928 } | 927 } |
929 // Extract the audio and zero-pad | 928 // Extract the audio and zero-pad |
930 for (var i=0; i<lens.length; i++) | 929 for (var i=0; i<lens.length; i++) |
931 { | 930 { |
932 var orig = this.audioObjects[i].buffer; | 931 var orig = this.audioObjects[i].buffer.buffer; |
933 var hold = audioContext.createBuffer(orig.numberOfChannels,length,orig.sampleRate); | 932 var hold = audioContext.createBuffer(orig.numberOfChannels,length,orig.sampleRate); |
934 for (var c=0; c<orig.numberOfChannels; c++) | 933 for (var c=0; c<orig.numberOfChannels; c++) |
935 { | 934 { |
936 var inData = hold.getChannelData(c); | 935 var inData = hold.getChannelData(c); |
937 var outData = orig.getChannelData(c); | 936 var outData = orig.getChannelData(c); |
938 for (var n=0; n<orig.length; n++) | 937 for (var n=0; n<orig.length; n++) |
939 {inData[n] = outData[n];} | 938 {inData[n] = outData[n];} |
940 } | 939 } |
941 this.audioObjects[i].buffer = hold; | 940 this.audioObjects[i].buffer.buffer = hold; |
942 delete orig; | 941 delete orig; |
943 } | 942 } |
944 }; | 943 }; |
945 | 944 |
946 } | 945 } |
1075 file.setAttribute('channels',this.buffer.numberOfChannels); | 1074 file.setAttribute('channels',this.buffer.numberOfChannels); |
1076 file.setAttribute('sampleCount',this.buffer.length); | 1075 file.setAttribute('sampleCount',this.buffer.length); |
1077 file.setAttribute('duration',this.buffer.duration); | 1076 file.setAttribute('duration',this.buffer.duration); |
1078 root.appendChild(file); | 1077 root.appendChild(file); |
1079 if (this.specification.type != 'outsidereference') { | 1078 if (this.specification.type != 'outsidereference') { |
1080 root.appendChild(this.interfaceDOM.exportXMLDOM(this)); | 1079 var interfaceXML = this.interfaceDOM.exportXMLDOM(this); |
1080 if (interfaceXML.length == undefined) { | |
1081 root.appendChild(); | |
1082 } else { | |
1083 for (var i=0; i<interfaceXML.length; i++) | |
1084 { | |
1085 root.appendChild(interfaceXML[i]); | |
1086 } | |
1087 } | |
1081 root.appendChild(this.commentDOM.exportXMLDOM(this)); | 1088 root.appendChild(this.commentDOM.exportXMLDOM(this)); |
1082 if(this.specification.type == 'anchor') { | 1089 if(this.specification.type == 'anchor') { |
1083 root.setAttribute('anchor',true); | 1090 root.setAttribute('anchor',true); |
1084 } else if(this.specification.type == 'reference') { | 1091 } else if(this.specification.type == 'reference') { |
1085 root.setAttribute('reference',true); | 1092 root.setAttribute('reference',true); |
1501 } else { | 1508 } else { |
1502 commonInterfaceNode = undefined; | 1509 commonInterfaceNode = undefined; |
1503 } | 1510 } |
1504 | 1511 |
1505 this.commonInterface = new function() { | 1512 this.commonInterface = new function() { |
1513 this.name = undefined; | |
1506 this.OptionNode = function(child) { | 1514 this.OptionNode = function(child) { |
1507 this.type = child.nodeName; | 1515 this.type = child.nodeName; |
1508 if (this.type == 'option') | 1516 if (this.type == 'option') |
1509 { | 1517 { |
1510 this.name = child.getAttribute('name'); | 1518 this.name = child.getAttribute('name'); |
1534 else {this.enforce = false;} | 1542 else {this.enforce = false;} |
1535 } | 1543 } |
1536 }; | 1544 }; |
1537 this.options = []; | 1545 this.options = []; |
1538 if (commonInterfaceNode != undefined) { | 1546 if (commonInterfaceNode != undefined) { |
1547 var name = commonInterfaceNode.getAttribute("name"); | |
1548 if (name != undefined) { | |
1549 this.name = name; | |
1550 } | |
1539 var child = commonInterfaceNode.firstElementChild; | 1551 var child = commonInterfaceNode.firstElementChild; |
1540 while (child != undefined) { | 1552 while (child != undefined) { |
1541 this.options.push(new this.OptionNode(child)); | 1553 this.options.push(new this.OptionNode(child)); |
1542 child = child.nextElementSibling; | 1554 child = child.nextElementSibling; |
1543 } | 1555 } |