function playFreqs(
freqs,
duration = 0.25,
playDescending = false,
arpeggiate = true
) {
const synth = new Tone.PolySynth(Tone.Synth).toDestination();
const now = Tone.now();
const n = freqs.length;
if (arpeggiate) {
freqs.forEach((f, i) => {
const dDown = (2 * duration) / 3;
synth.triggerAttackRelease(f, dDown, now + i * duration);
if (playDescending && i !== n - 1) {
let j = 2 * (n - 1) - i;
synth.triggerAttackRelease(f, dDown, now + j * duration);
}
});
} else {
freqs.forEach((f, i) => {
if (i !== freqs.length - 1) {
synth.triggerAttackRelease(f, duration, now);
}
});
}
}