Tone.js/examples/buses.html

85 lines
2.8 KiB
HTML
Raw 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
2019-01-09 01:21:29 +00:00
<script src="https://unpkg.com/@webcomponents/webcomponentsjs@^2/webcomponents-bundle.js"></script>
<script src="../build/Tone.js"></script>
<script src="./js/tonejs-ui.js"></script>
<style>
tone-content tone-slider {
display: block;
margin-top: 10px;
}
</style>
2014-09-04 04:32:54 +00:00
</head>
<body>
2019-01-09 01:21:29 +00:00
<tone-example>
<tone-explanation label="Buses">
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>
2019-01-09 01:21:29 +00:00
Docs on <a href="https://tonejs.github.io/docs/Tone.send">send</a> and
<a href="https://tonejs.github.io/docs/Tone.receive">receive</a>.
</tone-explanation>
<tone-content>
<tone-piano></tone-piano>
<tone-slider label="Chorus Send" min="-100" max="0" value="-100" units="db"></tone-slider>
<tone-slider label="Chebyshev Send" min="-100" max="0" value="-100" units="db"></tone-slider>
<tone-slider label="Freeverb Send" min="-100" max="0" value="-100" units="db"></tone-slider>
</tone-content>
<tone-drawer collapsed>
<tone-chorus collapsed></tone-chorus>
<tone-chebyshev collapsed></tone-chebyshev>
<tone-freeverb collapsed></tone-freeverb>
<tone-synth collapsed></tone-synth>
</tone-drawer>
</tone-example>
<script type="text/javascript">
2015-02-12 03:39:28 +00:00
//the synth
2019-01-09 01:21:29 +00:00
var synth = new Tone.Synth().toMaster().set("envelope.attack", 0.04);
2014-09-04 04:32:54 +00:00
2015-06-26 05:23:05 +00:00
//send audio to each of the effect channels
var chorusSend = synth.send("chorus", -Infinity);
var chebySend = synth.send("cheby", -Infinity);
var reverbSend = synth.send("reverb", -Infinity);
2014-09-04 04:32:54 +00:00
//make some effects
2015-02-12 03:39:28 +00:00
var chorus = new Tone.Chorus()
.receive("chorus")
.toMaster();
2015-06-26 05:23:05 +00:00
2015-02-12 03:39:28 +00:00
var cheby = new Tone.Chebyshev(50)
.receive("cheby")
.toMaster();
2015-06-26 05:23:05 +00:00
var reverb = new Tone.Freeverb(0.8, 4000)
2015-06-26 05:23:05 +00:00
.receive("reverb")
.toMaster();
2019-01-09 01:21:29 +00:00
//bind the interface
document.querySelector("tone-chorus").bind(chorus);
document.querySelector("tone-chebyshev").bind(cheby);
document.querySelector("tone-freeverb").bind(reverb);
document.querySelector("tone-synth").bind(synth);
document.querySelector("tone-piano").bind(synth);
document.querySelector("[label=\"Chorus Send\"]").addEventListener("change", e => {
chorusSend.gain.value = e.detail;
2014-09-04 04:32:54 +00:00
});
2019-01-09 01:21:29 +00:00
document.querySelector("[label=\"Chebyshev Send\"]").addEventListener("change", e => {
chebySend.gain.value = e.detail;
2017-03-26 20:39:19 +00:00
});
2019-01-09 01:21:29 +00:00
document.querySelector("[label=\"Freeverb Send\"]").addEventListener("change", e => {
reverbSend.gain.value = e.detail;
2017-03-26 20:39:19 +00:00
});
2014-09-04 04:32:54 +00:00
</script>
</body>
</html>