comparison core.js @ 1320:dd7f5b4d3b4e

Changed AudioBuffer.gain to be AudioBuffer.playbackGain to bypass Safari not using up-to-date Web Audio API Specification.
author Nicholas Jillings <nickjillings@users.noreply.github.com>
date Wed, 23 Dec 2015 18:19:39 +0000
parents 64541cd9265d
children 0f161e776cb4
comparison
equal deleted inserted replaced
1319:86f371ddcb87 1320:dd7f5b4d3b4e
18 18
19 19
20 // Add a prototype to the bufferSourceNode to reference to the audioObject holding it 20 // Add a prototype to the bufferSourceNode to reference to the audioObject holding it
21 AudioBufferSourceNode.prototype.owner = undefined; 21 AudioBufferSourceNode.prototype.owner = undefined;
22 // Add a prototype to the bufferNode to hold the desired LINEAR gain 22 // Add a prototype to the bufferNode to hold the desired LINEAR gain
23 AudioBuffer.prototype.gain = undefined; 23 AudioBuffer.prototype.playbackGain = undefined;
24 // Add a prototype to the bufferNode to hold the computed LUFS loudness 24 // Add a prototype to the bufferNode to hold the computed LUFS loudness
25 AudioBuffer.prototype.lufs = undefined; 25 AudioBuffer.prototype.lufs = undefined;
26 26
27 window.onload = function() { 27 window.onload = function() {
28 // Function called once the browser has loaded all files. 28 // Function called once the browser has loaded all files.
398 this.popupTitle.textContent = node.statement; 398 this.popupTitle.textContent = node.statement;
399 var optHold = this.popupResponse; 399 var optHold = this.popupResponse;
400 for (var i=0; i<node.options.length; i++) { 400 for (var i=0; i<node.options.length; i++) {
401 var option = node.options[i]; 401 var option = node.options[i];
402 var input = document.createElement('input'); 402 var input = document.createElement('input');
403 input.id = option.id; 403 input.id = option.name;
404 input.type = 'checkbox'; 404 input.type = 'checkbox';
405 var span = document.createElement('span'); 405 var span = document.createElement('span');
406 span.textContent = option.text; 406 span.textContent = option.text;
407 var hold = document.createElement('div'); 407 var hold = document.createElement('div');
408 hold.setAttribute('name','option'); 408 hold.setAttribute('name','option');
889 { 889 {
890 if (i != id) { 890 if (i != id) {
891 this.audioObjects[i].outputGain.gain.value = 0.0; 891 this.audioObjects[i].outputGain.gain.value = 0.0;
892 this.audioObjects[i].stop(); 892 this.audioObjects[i].stop();
893 } else if (i == id) { 893 } else if (i == id) {
894 this.audioObjects[id].outputGain.gain.value = this.audioObjects[id].specification.gain*this.audioObjects[id].buffer.buffer.gain; 894 this.audioObjects[id].outputGain.gain.value = this.audioObjects[id].specification.gain*this.audioObjects[id].buffer.buffer.playbackGain;
895 this.audioObjects[id].play(audioContext.currentTime+0.01); 895 this.audioObjects[id].play(audioContext.currentTime+0.01);
896 } 896 }
897 } 897 }
898 } 898 }
899 interfaceContext.playhead.start(); 899 interfaceContext.playhead.start();
1003 var inData = hold.getChannelData(c); 1003 var inData = hold.getChannelData(c);
1004 var outData = orig.getChannelData(c); 1004 var outData = orig.getChannelData(c);
1005 for (var n=0; n<orig.length; n++) 1005 for (var n=0; n<orig.length; n++)
1006 {inData[n] = outData[n];} 1006 {inData[n] = outData[n];}
1007 } 1007 }
1008 hold.gain = orig.gain; 1008 hold.playbackGain = orig.playbackGain;
1009 hold.lufs = orig.lufs; 1009 hold.lufs = orig.lufs;
1010 this.audioObjects[i].buffer.buffer = hold; 1010 this.audioObjects[i].buffer.buffer = hold;
1011 } 1011 }
1012 }; 1012 };
1013 1013
1060 } 1060 }
1061 } else { 1061 } else {
1062 this.buffer = callee; 1062 this.buffer = callee;
1063 } 1063 }
1064 this.state = 1; 1064 this.state = 1;
1065 this.buffer.buffer.gain = callee.buffer.gain; 1065 this.buffer.buffer.playbackGain = callee.buffer.playbackGain;
1066 this.buffer.buffer.lufs = callee.buffer.lufs; 1066 this.buffer.buffer.lufs = callee.buffer.lufs;
1067 var targetLUFS = this.specification.parent.loudness; 1067 var targetLUFS = this.specification.parent.loudness;
1068 if (typeof targetLUFS === "number") 1068 if (typeof targetLUFS === "number")
1069 { 1069 {
1070 this.buffer.buffer.gain = decibelToLinear(targetLUFS - this.buffer.buffer.lufs); 1070 this.buffer.buffer.playbackGain = decibelToLinear(targetLUFS - this.buffer.buffer.lufs);
1071 } else { 1071 } else {
1072 this.buffer.buffer.gain = 1.0; 1072 this.buffer.buffer.playbackGain = 1.0;
1073 } 1073 }
1074 if (this.interfaceDOM != null) { 1074 if (this.interfaceDOM != null) {
1075 this.interfaceDOM.enable(); 1075 this.interfaceDOM.enable();
1076 } 1076 }
1077 }; 1077 };
1078 1078
1079 this.loopStart = function() { 1079 this.loopStart = function() {
1080 this.outputGain.gain.value = this.specification.gain*this.buffer.buffer.gain; 1080 this.outputGain.gain.value = this.specification.gain*this.buffer.buffer.playbackGain;
1081 this.metric.startListening(audioEngineContext.timer.getTestTime()); 1081 this.metric.startListening(audioEngineContext.timer.getTestTime());
1082 }; 1082 };
1083 1083
1084 this.loopStop = function() { 1084 this.loopStop = function() {
1085 if (this.outputGain.gain.value != 0.0) { 1085 if (this.outputGain.gain.value != 0.0) {
1776 while (element != null) { 1776 while (element != null) {
1777 if (element.nodeName == 'statement' && this.statement == undefined){ 1777 if (element.nodeName == 'statement' && this.statement == undefined){
1778 this.statement = element.textContent; 1778 this.statement = element.textContent;
1779 } else if (element.nodeName == 'option') { 1779 } else if (element.nodeName == 'option') {
1780 var node = new this.childOption(); 1780 var node = new this.childOption();
1781 node.id = element.id; 1781 if(element.getAttribute('id') != null) {
1782 console.log(child.nodeName + ' node attribute id is deprecated, use name instead');
1783 node.name = element.id;
1784 }
1782 node.name = element.getAttribute('name'); 1785 node.name = element.getAttribute('name');
1783 node.text = element.textContent; 1786 node.text = element.textContent;
1784 this.options.push(node); 1787 this.options.push(node);
1785 } 1788 }
1786 element = element.nextElementSibling; 1789 element = element.nextElementSibling;