Tone.js/examples/signalMath.html
2015-02-13 15:23:30 -05:00

81 lines
No EOL
2.5 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>SIGNAL PROCESSING</title>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<script type="text/javascript" src="./deps/jquery.min.js"></script>
<script type="text/javascript" src="../build/Tone.js"></script>
<script type="text/javascript" src="./deps/nexusUI.js"></script>
<script type="text/javascript" src="./deps/prism.js"></script>
<script type="text/javascript" src="./scripts/Interface.js"></script>
<link rel="stylesheet" type="text/css" href="./style/examples.css">
<link rel="stylesheet" type="text/css" href="./style/prism.css">
<script type="text/javascript">
// jshint ignore: start
</script>
</head>
<body>
<div id="Explanation">
Audio-Rate Math
<br>
<br>
One of the most powerful features of Tone.js is the ability to
perform math and logic on audio-rate signal. Signals
can be ramped and scheduled to control Audio Parameters and
other Signals making it simple to create elaborate,
interconnected automations. Additionally, Signals and Signal maths use no
ScriptProcessorNodes which make them very efficient.
</div>
<div id="Content">
<div id='Rack'></div>
<div id='CodeRack'></div>
</div>
<script id="ToneCode" type="text/javascript">
//the driving signal
var signal = new Tone.Signal(0);
//take the absolute value of the signal
var abs = new Tone.Abs();
//add a constant value to the dry signal
var adder = new Tone.Add(100);
//normalize the added value between 0 to 1
var norm = new Tone.Normalize(100, 101);
//scale the normalized value between 5 and 10
var scaler = new Tone.Scale(5, 10);
//multiply the output by 10
var mult = new Tone.Multiply(10);
//clip the results between 70 and 80
var clip = new Tone.Clip(70, 80);
//chain the components together
signal.chain(abs, adder, norm, scaler, mult, clip);
</script>
<script id="ToneCode" type="text/javascript">
Interface.Rack("Rack", "Signals");
var signalSlider = Interface.Slider("Rack", signal, "value", -1, 1);
signalSlider.label = ""
signalSlider.draw();
Interface.Meter("Rack", signal, "Tone.Signal");
Interface.Meter("Rack", abs, "Tone.Abs()");
Interface.Meter("Rack", adder, "Tone.Add(100)");
Interface.Meter("Rack", norm, "Tone.Normalize(100, 101)");
Interface.Meter("Rack", scaler, "Tone.Scale(5, 10)");
Interface.Meter("Rack", mult, "Tone.Multiply(10)");
Interface.Meter("Rack", clip, "Tone.Clip(70, 80)");
Interface.Code("CodeRack", "ToneCode");
</script>
</body>
</html>