xxxxxxxxxx
120
// var plucky1 = new Tone.MonoSynth().toMaster();
// var plucky2 = new Tone.MonoSynth().toMaster();
// function draw() {
// if (keyIsPressed && key == 'a') {
// plucky1.triggerAttackRelease("C4");
// }
// if (keyIsPressed && key == 'b') {
// plucky2.triggerAttackRelease("G4");
// }
// }
// function keyPressed(){
// if(key == 'a'){
// plucky1.triggerAttackRelease("C4");
// }
// if(key =='b'){
// plucky2.triggerAttackRelease("G4");
// }
// }
// var pingPong2 = new Tone.PingPongDelay("4n", 0.7).toMaster();
// var pingPong = new Tone.PingPongDelay("8t", 0.7).connect(pingPong2);
// var synth = new Tone.MonoSynth().connect(pingPong);
// synth.triggerAttackRelease("C4", "32n");
// var autoWah = new Tone.AutoWah(50, 6, 0).toMaster();
//initialize the synth and connect to autowah
// var synth = new Tone.MonoSynth();
// // synth.connect(autoWah);
// //Q value influences the effect of the wah - default is 2
// // autoWah.Q.value = 6;
// //more audible on higher notes
// var cheby = new Tone.Chebyshev(50);
// //create a monosynth connected to our cheby
// synth = new Tone.MonoSynth().connect(cheby);
// synth.triggerAttackRelease("C4", "8n")
// var synth = new Tone.MetalSynth().toMaster;
// synth.triggerAttackRelease("C4");
var fmSynth = new Tone.FMSynth({
"harmonicity": 5,
"modulationIndex": 10,
"detune": 0, //alter, 100 per half step
"oscillator": {
"type": "sine"
},
"envelope": {
"attack": 0.1,
"decay": 5,
"sustain": 100,
"release": 1
},
"modulation": {
"type": "square"
},
"modulationEnvelope": {
"attack": 0.5,
"decay": 1,
"sustain": 0.5,
"release": 0.5
}
});
// var waveform = new Tone.Waveform(1024);
// // waveform.connect(fmSynth);
// var waveValue = waveform.getValue();
// console.log(waveValue);
fmSynth.toMaster();
function setup() {
createCanvas(400, 400);
phase = 0;
}
function draw() {
background(0);
value = fmSynth.envelope.value
// console.log(value)
for ( i = 0; i < width; i++) {
//scaling kickEnvelope value by 200
//since default is 0-1
//multiplying this value to scale the sine wave
//depending on x position
stroke(255);
strokeWeight(2);
var yDot = sin((i / 60) + phase) * value*50;
point(i, height/2 + yDot);
phase += 1;
}
// background(255);
// beginShape();
// strokeWeight(5);
// for (var i = 0; i < waveValue.length; i++){
// var x = map(i, 0, waveValue.length, 0, width);
// var y = map(waveform[i], -1, 1, height, 0);
// vertex(x, y);
// }
// endShape();
}
function keyPressed(){
if(keyCode == 65){
fmSynth.triggerAttackRelease("D1", "4n");
}
}