Tone.js/examples/buses.html
2017-03-26 16:39:19 -04:00

111 lines
2.6 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Buses</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<link rel="icon" type="image/png" sizes="174x174" href="./style/favicon.png">
<script src="../build/Tone.js"></script>
<script src="./scripts/jquery.min.js"></script>
<script src="./scripts/draggabilly.js"></script>
<script src="./scripts/StartAudioContext.js"></script>
<script src="./scripts/Interface.js"></script>
<script src="https://tonejs.github.io/Logo/build/Logo.js"></script>
<script src="./scripts/Keyboard.js"></script>
<link rel="stylesheet" type="text/css" href="./style/examples.css">
<script>
// jshint ignore: start
</script>
</head>
<body>
<div id="Content">
<div id="Title">Buses</div>
<div id="Explanation">
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
channel on your effect. The gain values are all in decibels.
<br><br>
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>.
</div>
<div id="Sliders"></div>
<div id="Keyboard"></div>
</div>
<script>
//the synth
var synth = new Tone.Synth().toMaster()
.set("envelope.attack", 0.04);
//send audio to each of the effect channels
var chorusSend = synth.send("chorus", -Infinity);
var chebySend = synth.send("cheby", -Infinity);
var autowahSend = synth.send("autowah", -Infinity);
var reverbSend = synth.send("reverb", -Infinity);
//make some effects
var chorus = new Tone.Chorus()
.receive("chorus")
.toMaster();
var cheby = new Tone.Chebyshev(50)
.receive("cheby")
.toMaster();
var reverb = new Tone.Freeverb(0.8, 4000)
.receive("reverb")
.toMaster();
// GUI //
Interface.Slider({
name : "Chebyshev",
parent : $("#Sliders"),
min : -100,
max : 0,
drag : function(val){
chebySend.gain.value = val;
}
});
Interface.Slider({
name : "Chorus",
parent : $("#Sliders"),
min : -100,
max : 0,
drag : function(val){
chorusSend.gain.value = val;
}
});
Interface.Slider({
name : "Freeverb",
parent : $("#Sliders"),
min : -100,
max : 0,
drag : function(val){
reverbSend.gain.value = val;
}
});
/**
* the keyboard
*/
var keyboard = Interface.Keyboard();
keyboard.keyDown = function (note) {
synth.triggerAttack(note);
};
keyboard.keyUp = function () {
synth.triggerRelease();
};
</script>
</body>
</html>