This commit is contained in:
Yotam Mann 2020-07-19 10:18:33 -07:00
parent f6d6e310dd
commit bdbc6dfccd

View file

@ -33,53 +33,52 @@
<script type="text/javascript"> <script type="text/javascript">
// the source // the source
const player = new Tone.Player({ const player = new Tone.Player({
url: "https://tonejs.github.io/audio/berklee/femalevoice_oo_A4.mp3", url: "https://tonejs.github.io/audio/berklee/femalevoice_oo_A4.mp3",
loop: true, loop: true,
}); });
// make some effects // make some effects
const chorus = new Tone.Chorus({ const chorus = new Tone.Chorus({
wet: 1, wet: 1,
}).toDestination().start(); }).toDestination().start();
const chorusChannel = new Tone.Channel({ volume: -60 }).connect(chorus); const chorusChannel = new Tone.Channel({ volume: -60 }).connect(chorus);
chorusChannel.receive("chorus"); chorusChannel.receive("chorus");
const cheby = new Tone.Chebyshev(50).toDestination(); const cheby = new Tone.Chebyshev(50).toDestination();
const chebyChannel = new Tone.Channel({ volume: -60 }).connect(cheby); const chebyChannel = new Tone.Channel({ volume: -60 }).connect(cheby);
chebyChannel.receive("cheby"); chebyChannel.receive("cheby");
const reverb = new Tone.Reverb(3).toDestination(); const reverb = new Tone.Reverb(3).toDestination();
const reverbChannel = new Tone.Channel({ volume: -60 }).connect(reverb); const reverbChannel = new Tone.Channel({ volume: -60 }).connect(reverb);
reverbChannel.receive("reverb"); reverbChannel.receive("reverb");
// send the player to all of the channels // send the player to all of the channels
const playerChannel = new Tone.Channel().toDestination(); const playerChannel = new Tone.Channel().toDestination();
playerChannel.send("chorus"); playerChannel.send("chorus");
playerChannel.send("cheby"); playerChannel.send("cheby");
playerChannel.send("reverb"); playerChannel.send("reverb");
player.connect(playerChannel); player.connect(playerChannel);
drawer().add({ drawer().add({
tone: chorus, tone: chorus,
}).add({ }).add({
tone: reverb, tone: reverb,
}).add({ }).add({
tone: cheby, tone: cheby,
}); });
document.querySelector("tone-play-toggle").addEventListener("start", () => player.start()); document.querySelector("tone-play-toggle").addEventListener("start", () => player.start());
document.querySelector("tone-play-toggle").addEventListener("stop", () => player.stop()); document.querySelector("tone-play-toggle").addEventListener("stop", () => player.stop());
// bind the interface // bind the interface
document.querySelector("[label=\"Chorus Send\"]").addEventListener("input", e => { document.querySelector("[label=\"Chorus Send\"]").addEventListener("input", e => {
chorusChannel.volume.value = parseFloat(e.target.value); chorusChannel.volume.value = parseFloat(e.target.value);
}); });
document.querySelector("[label=\"Chebyshev Send\"]").addEventListener("input", e => { document.querySelector("[label=\"Chebyshev Send\"]").addEventListener("input", e => {
chebyChannel.volume.value = parseFloat(e.target.value); chebyChannel.volume.value = parseFloat(e.target.value);
}); });
document.querySelector("[label=\"Reverb Send\"]").addEventListener("input", e => { document.querySelector("[label=\"Reverb Send\"]").addEventListener("input", e => {
reverbChannel.volume.value = parseFloat(e.target.value); reverbChannel.volume.value = parseFloat(e.target.value);
}); });
</script> </script>
</body> </body>
</html> </html>