Tone.js/examples/buses.html
2015-07-04 14:43:17 -04:00

145 lines
No EOL
3.4 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">
<script type="text/javascript" src="../build/Tone.js"></script>
<script type="text/javascript" src="./scripts/jquery.min.js"></script>
<script type="text/javascript" src="./scripts/Notone.GUI.js"></script>
<script type="text/javascript" src="./scripts/Interface.js"></script>
<script type="text/javascript" src="./scripts/qwerty-hancock.js"></script>
<link rel="stylesheet" type="text/css" href="./style/examples.css">
<script type="text/javascript">
// 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.
<br><br>
Docs on <a href="http://tonejs.org/docs/#Tone.send">send</a> and
<a href="http://tonejs.org/docs/#Tone.receive">receive</a>.
</div>
<div id="Sliders"></div>
<div id="Keyboard"></div>
</div>
<script type="text/javascript">
//the synth
var synth = new Tone.SimpleSynth().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.9, 4000)
.receive("reverb")
.toMaster();
var autoWah = new Tone.AutoWah()
.receive("autowah")
.toMaster()
.set({
"baseFrequency" : 100,
"octaves" : 4,
"sensitivity" : 0,
"Q" : 2,
"gain" : 10,
"follower" : {
"attack" : 0.05,
"release" : 0.2
}
});
</script>
<script id="GUI" type="text/javascript">
$(function(){
Notone.config({
"search" : false,
"expandInDrawer" : true,
"hideDrawer" : Interface.isMobile,
"drawer" : true,
"container" : "body"
});
Notone.add(synth);
new Interface.Slider({
name : "Chebyshev",
parent : $("#Sliders"),
drag : function(val){
chebySend.gain.value = val;
}
});
new Interface.Slider({
name : "Chorus",
parent : $("#Sliders"),
drag : function(val){
chorusSend.gain.value = val;
}
});
new Interface.Slider({
name : "Freeverb",
parent : $("#Sliders"),
drag : function(val){
reverbSend.gain.value = val;
}
});
new Interface.Slider({
name : "AutoWah",
parent : $("#Sliders"),
drag : function(val){
autowahSend.gain.value = val;
}
});
/**
* the keyboard
*/
var keyboard = new QwertyHancock({
id: "Keyboard",
width: $("#Content").width(),
height: 150,
octaves: Interface.isMobile ? 1.26 : 3,
startNote: "C3",
whiteKeyColour: "white",
blackKeyColour: "#f5871f",
activeColour : "#1EDF3E"
});
keyboard.keyDown = function (note, frequency) {
synth.triggerAttack(frequency);
};
keyboard.keyUp = function () {
synth.triggerRelease();
};
});
</script>
</body>
</html>