/*Copyright 2015, Pall Thayer (http://pallthayer.dyndns.org)*/
/*These program are free software: you can redistribute them and/or modify
them under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will rock your world,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .*/
/*Ce Ne Sont Pas les Citrons - 2015-09-19 19:27:04*/
var lemon = function() {
var started = false;
var i=0;
var seed = new AudioContext();
var fruit = seed.createOscillator();
var tree = seed.createOscillator();
fruit.type = 'square';
tree.type = 'square';
tree.detune.value = 2;
var color = seed.createGain();
fruit.connect(color);
tree.connect(color);
var squeeze = seed.createDelay();
squeeze.delayTime.value = 0.5;
var juice = seed.createGain();
juice.gain.value = 0.5;
squeeze.connect(juice);
juice.connect(squeeze);
color.connect(juice);
color.connect(seed.destination);
juice.connect(seed.destination);
var howLong;
var fvalue;
var buttonUp = function() {
var bod = document.getElementsByTagName('body');
var makeButtons = '';
for(var i=1;i<100;i++) {
makeButtons += '';
}
bod[0].innerHTML = makeButtons;
};
this.pucker = function(freek) {
fvalue = freek;
window.clearInterval(howLong);
fruit.frequency.value = fvalue;
tree.frequency.value = fvalue;
color.gain.value = 0.7;
if(!started) {
startFruitTree();
}
howLong = setInterval(sing, 50);
};
var sing = function() {
color.gain.value -= 0.05;
fvalue -= 100;
fruit.frequency.setValueAtTime(fvalue, seed.currentTime);
tree.frequency.setValueAtTime(fvalue, seed.currentTime);
if(color.gain.value < 0) {
window.clearInterval(howLong);
}
};
var startFruitTree = function() {
fruit.start();
tree.start();
started = true;
};
buttonUp();
}