Tone.js/examples/buses.html

85 lines
3.1 KiB
HTML
Raw Permalink Normal View History

<!DOCTYPE html>
2014-09-04 04:32:54 +00:00
<html>
<head>
<meta charset="utf-8">
2015-06-26 05:23:05 +00:00
<title>Buses</title>
2014-09-06 19:35:31 +00:00
2019-01-09 01:21:29 +00:00
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="icon" type="image/png" sizes="174x174" href="./favicon.png">
2014-09-04 04:32:54 +00:00
2020-07-18 00:58:09 +00:00
<script src="https://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/2.4.3/webcomponents-bundle.js"></script>
<link href="https://fonts.googleapis.com/css?family=Material+Icons&display=block" rel="stylesheet"/>
2019-01-09 01:21:29 +00:00
<script src="../build/Tone.js"></script>
2020-07-18 00:58:09 +00:00
<script src="./js/tone-ui.js"></script>
<script src="./js/components.js"></script>
2014-09-04 04:32:54 +00:00
</head>
<body>
<tone-example label="Buses">
<div slot="explanation">
2015-06-26 05:23:05 +00:00
Buses make it easy to share effects across many instruments. <code>send</code>
audio to a named bus from an instrument and then <code>receive</code> that
2016-10-05 14:24:07 +00:00
channel on your effect. The gain values are all in decibels.
2015-06-27 22:02:55 +00:00
<br><br>
Docs on <a href="https://tonejs.github.io/docs/Channel.html#send">send</a> and
<a href="https://tonejs.github.io/docs/Channel.html#receive">receive</a>.
</div>
<div id="content">
<tone-play-toggle></tone-play-toggle>
<tone-slider label="Chorus Send" min="-60" max="6" value="-60" units="db"></tone-slider>
<tone-slider label="Chebyshev Send" min="-60" max="6" value="-60" units="db"></tone-slider>
<tone-slider label="Reverb Send" min="-60" max="6" value="-60" units="db"></tone-slider>
</div>
2019-01-09 01:21:29 +00:00
</tone-example>
<script type="text/javascript">
2020-07-19 17:18:33 +00:00
// the source
const player = new Tone.Player({
url: "https://tonejs.github.io/audio/berklee/femalevoice_oo_A4.mp3",
loop: true,
});
2014-09-04 04:32:54 +00:00
2020-07-19 17:18:33 +00:00
// make some effects
const chorus = new Tone.Chorus({
wet: 1,
}).toDestination().start();
const chorusChannel = new Tone.Channel({ volume: -60 }).connect(chorus);
chorusChannel.receive("chorus");
2014-09-04 04:32:54 +00:00
2020-07-19 17:18:33 +00:00
const cheby = new Tone.Chebyshev(50).toDestination();
const chebyChannel = new Tone.Channel({ volume: -60 }).connect(cheby);
chebyChannel.receive("cheby");
2015-06-26 05:23:05 +00:00
2020-07-19 17:18:33 +00:00
const reverb = new Tone.Reverb(3).toDestination();
const reverbChannel = new Tone.Channel({ volume: -60 }).connect(reverb);
reverbChannel.receive("reverb");
2015-06-26 05:23:05 +00:00
2020-07-19 17:18:33 +00:00
// send the player to all of the channels
const playerChannel = new Tone.Channel().toDestination();
playerChannel.send("chorus");
playerChannel.send("cheby");
playerChannel.send("reverb");
player.connect(playerChannel);
2020-07-19 17:18:33 +00:00
drawer().add({
tone: chorus,
}).add({
tone: reverb,
}).add({
tone: cheby,
});
document.querySelector("tone-play-toggle").addEventListener("start", () => player.start());
document.querySelector("tone-play-toggle").addEventListener("stop", () => player.stop());
// bind the interface
document.querySelector("[label=\"Chorus Send\"]").addEventListener("input", e => {
chorusChannel.volume.value = parseFloat(e.target.value);
});
document.querySelector("[label=\"Chebyshev Send\"]").addEventListener("input", e => {
chebyChannel.volume.value = parseFloat(e.target.value);
});
document.querySelector("[label=\"Reverb Send\"]").addEventListener("input", e => {
reverbChannel.volume.value = parseFloat(e.target.value);
});
2014-09-04 04:32:54 +00:00
</script>
</body>
</html>