type:"sine",// Also try "triangle", "sawtooth", "square"
frequency:pitchToFrequency(pitch)
});
}
attackTime=0.01
decayTime=0.3
functionmakeEnvelope(startTime){
constpeak=startTime+attackTime;
constend=peak+decayTime;
constenv=newGainNode(ctx,{gain:0});
env.gain.linearRampToValueAtTime(maxGain,peak);
env.gain.linearRampToValueAtTime(0,end);
returnenv;
}
functionplay(pitch){
consttone=makeTone(pitch);
constenv=makeEnvelope(ctx.currentTime);
tone.connect(env);
env.connect(ctx.destination);
tone.start();
return;
}
{
if(buttonClicks==0)return;
play(midiNote);
}
Purpose-built for displays of data
Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.