xxxxxxxxxx
30
const panner = new Tone.Panner3D().toDestination()
panner.panningModel = 'HRTF'
panner.distanceModel = 'exponential'
const synth = new Tone.Synth({
oscillator : {
type : 'square'
},
envelope : {
attack : 0.01,
decay : 0.1,
sustain : 0
}
}).connect(panner)
setInterval(() => {
synth.triggerAttack('C4')
}, 200)
function setup() {
createCanvas(400, 400);
}
function draw() {
background(220);
const x = Math.sin(frameCount / 100)
const y = Math.cos(frameCount / 100)
circle(x*width/2 + width/2, y*height/2 + height/2, 10)
panner.setPosition(x * 5, y * 5, 3)
}