// EXPLANATION FROM WEBSITE: The carrier is typically set at an audible frequency (i.e. 440 Hz) and connected to master output by default. The carrier.amp is set to zero because we will have the modulator control its amplitude.
varrandomnumb=getRandomArbitrary(0,20);
console.log(randomnumb);
carrier=newp5.Oscillator();// connects to master output by default
carrier.freq(200+randomnumb);// it sets the frequency of the carrier. AN AUDIBLE ONE.
carrier.amp(1);
// carrier's amp is 0 by default, giving our modulator total control
carrier.start();
// create an fft to analyze the audio
//an FFT (fast Fourier transform) converts a signal from its original domain (often time or space) to a representation in the frequency domain and vice versa
fft=newp5.FFT();
}
functiondraw(){
varmodAmp=1;
// si el mouseY és igual o el mateix que la meitat de l'altura, fes aixo. ((DEFINEIX LA AMPLITUD.))
/*if(mouseY<=height){
varmodAmp=map(mouseY,0,height,0.01,2.02);
}else{
varmodAmp=map(mouseY,height,0,0.01,2.02);
}
*/
carrier.amp(modAmp,0.01);// fade time of 0.1 for smooth fading