Mercurial > hg > webaudioevaluationtool
comparison core.js @ 1577:f1cca540c09d
audioObjects.metric object export their XML rather than ape.js
author | Nicholas Jillings <nickjillings@users.noreply.github.com> |
---|---|
date | Thu, 04 Jun 2015 11:01:19 +0100 |
parents | 51bbd0fdf7b4 |
children | 40f9b1725279 |
comparison
equal
deleted
inserted
replaced
1576:51bbd0fdf7b4 | 1577:f1cca540c09d |
---|---|
592 this.id = id; | 592 this.id = id; |
593 this.state = 0; // 0 - no data, 1 - ready | 593 this.state = 0; // 0 - no data, 1 - ready |
594 this.url = null; // Hold the URL given for the output back to the results. | 594 this.url = null; // Hold the URL given for the output back to the results. |
595 this.metric = new metricTracker(this); | 595 this.metric = new metricTracker(this); |
596 | 596 |
597 // Bindings for GUI | |
598 this.sliderDOM = null; | |
599 this.commentDOM = null; | |
600 | |
597 // Create a buffer and external gain control to allow internal patching of effects and volume leveling. | 601 // Create a buffer and external gain control to allow internal patching of effects and volume leveling. |
598 this.bufferNode = undefined; | 602 this.bufferNode = undefined; |
599 this.outputGain = audioContext.createGain(); | 603 this.outputGain = audioContext.createGain(); |
600 | 604 |
601 // Default output gain to be zero | 605 // Default output gain to be zero |
609 this.buffer; | 613 this.buffer; |
610 | 614 |
611 this.loopStart = function() { | 615 this.loopStart = function() { |
612 this.outputGain.gain.value = 1.0; | 616 this.outputGain.gain.value = 1.0; |
613 this.metric.startListening(audioEngineContext.timer.getTestTime()); | 617 this.metric.startListening(audioEngineContext.timer.getTestTime()); |
614 } | 618 }; |
615 | 619 |
616 this.loopStop = function() { | 620 this.loopStop = function() { |
617 if (this.outputGain.gain.value != 0.0) { | 621 if (this.outputGain.gain.value != 0.0) { |
618 this.outputGain.gain.value = 0.0; | 622 this.outputGain.gain.value = 0.0; |
619 this.metric.stopListening(audioEngineContext.timer.getTestTime()); | 623 this.metric.stopListening(audioEngineContext.timer.getTestTime()); |
620 } | 624 } |
621 } | 625 }; |
622 | 626 |
623 this.play = function(startTime) { | 627 this.play = function(startTime) { |
624 this.bufferNode = audioContext.createBufferSource(); | 628 this.bufferNode = audioContext.createBufferSource(); |
625 this.bufferNode.owner = this; | 629 this.bufferNode.owner = this; |
626 this.bufferNode.connect(this.outputGain); | 630 this.bufferNode.connect(this.outputGain); |
815 var bufferTime = evnt.getElementsByTagName('bufferTime')[0]; | 819 var bufferTime = evnt.getElementsByTagName('bufferTime')[0]; |
816 testTime.setAttribute('stop',time); | 820 testTime.setAttribute('stop',time); |
817 bufferTime.setAttribute('stop',this.parent.getCurrentPosition()); | 821 bufferTime.setAttribute('stop',this.parent.getCurrentPosition()); |
818 console.log('slider ' + this.parent.id + ' played for (' + diff + ')'); // DEBUG/SAFETY: show played slider id | 822 console.log('slider ' + this.parent.id + ' played for (' + diff + ')'); // DEBUG/SAFETY: show played slider id |
819 } | 823 } |
824 }; | |
825 | |
826 this.exportXMLDOM = function() { | |
827 var root = document.createElement('metric'); | |
828 if (audioEngineContext.metric.enableElementTimer) { | |
829 var mElementTimer = document.createElement('metricresult'); | |
830 mElementTimer.setAttribute('name','enableElementTimer'); | |
831 mElementTimer.textContent = this.listenedTimer; | |
832 root.appendChild(mElementTimer); | |
833 } | |
834 if (audioEngineContext.metric.enableElementTracker) { | |
835 var elementTrackerFull = document.createElement('metricResult'); | |
836 elementTrackerFull.setAttribute('name','elementTrackerFull'); | |
837 for (var k=0; k<this.movementTracker.length; k++) | |
838 { | |
839 var timePos = document.createElement('timePos'); | |
840 timePos.id = k; | |
841 var time = document.createElement('time'); | |
842 time.textContent = this.movementTracker[k][0]; | |
843 var position = document.createElement('position'); | |
844 position.textContent = this.movementTracker[k][1]; | |
845 timePos.appendChild(time); | |
846 timePos.appendChild(position); | |
847 elementTrackerFull.appendChild(timePos); | |
848 } | |
849 root.appendChild(elementTrackerFull); | |
850 } | |
851 if (audioEngineContext.metric.enableElementListenTracker) { | |
852 var elementListenTracker = document.createElement('metricResult'); | |
853 elementListenTracker.setAttribute('name','elementListenTracker'); | |
854 for (var k=0; k<this.listenTracker.length; k++) { | |
855 elementListenTracker.appendChild(this.listenTracker[k]); | |
856 } | |
857 root.appendChild(elementListenTracker); | |
858 } | |
859 if (audioEngineContext.metric.enableElementInitialPosition) { | |
860 var elementInitial = document.createElement('metricResult'); | |
861 elementInitial.setAttribute('name','elementInitialPosition'); | |
862 elementInitial.textContent = this.initialPosition; | |
863 root.appendChild(elementInitial); | |
864 } | |
865 if (audioEngineContext.metric.enableFlagListenedTo) { | |
866 var flagListenedTo = document.createElement('metricResult'); | |
867 flagListenedTo.setAttribute('name','elementFlagListenedTo'); | |
868 flagListenedTo.textContent = this.wasListenedTo; | |
869 root.appendChild(flagListenedTo); | |
870 } | |
871 if (audioEngineContext.metric.enableFlagMoved) { | |
872 var flagMoved = document.createElement('metricResult'); | |
873 flagMoved.setAttribute('name','elementFlagMoved'); | |
874 flagMoved.textContent = this.wasMoved; | |
875 root.appendChild(flagMoved); | |
876 } | |
877 if (audioEngineContext.metric.enableFlagComments) { | |
878 var flagComments = document.createElement('metricResult'); | |
879 flagComments.setAttribute('name','elementFlagComments'); | |
880 if (this.parent.commentDOM == null) | |
881 {flag.textContent = 'false';} | |
882 else if (this.parent.commentDOM.textContent.length == 0) | |
883 {flag.textContent = 'false';} | |
884 else | |
885 {flag.textContet = 'true';} | |
886 root.appendChild(flagComments); | |
887 } | |
888 | |
889 return root; | |
820 }; | 890 }; |
821 } | 891 } |
822 | 892 |
823 function randomiseOrder(input) | 893 function randomiseOrder(input) |
824 { | 894 { |