Tone.js/examples/autoPanner.html

55 lines
1 KiB
HTML
Raw Normal View History

2014-04-03 21:13:13 +00:00
<html>
<head>
2014-04-06 00:47:59 +00:00
<title>AUTOPANNER</title>
2014-04-05 00:24:19 +00:00
<script src="http://code.jquery.com/jquery-2.1.0.min.js"></script>
<script type="text/javascript" src="../Tone.js"></script>
<link rel="stylesheet" type="text/css" href="exampleStyle.css">
2014-04-03 21:13:13 +00:00
</head>
<body>
<div>Auto Panner</div>
<br>
2014-04-06 00:47:59 +00:00
<button>start</button>
2014-04-05 00:24:19 +00:00
<div id='left'>0</div>
<div id='right'>0</div>
2014-04-03 21:13:13 +00:00
<script type="text/javascript">
//panner
var pan = new Tone.AutoPanner();
2014-04-03 21:13:13 +00:00
//input signals
var sine = new Tone.Oscillator();
2014-04-03 21:13:13 +00:00
//connect it up
sine.connect(pan);
pan.toMaster();
2014-04-03 21:13:13 +00:00
//meter
var meter = new Tone.Meter(2);
pan.connect(meter);
2014-04-05 00:24:19 +00:00
//star the panner lfo
pan.start();
pan.setDry(0);
2014-04-05 00:24:19 +00:00
//update the meters
setInterval(function(){
$("#left").text("left: " + meter.getDb(0).toFixed(2) + " db");
$("#right").text("right: " + meter.getDb(1).toFixed(2) + " db");
}, 100);
2014-04-05 00:24:19 +00:00
$("button").click(function(){
if (sine.state !== "started"){
2014-04-06 00:47:59 +00:00
sine.start();
$(this).text("stop");
} else {
sine.stop();
$(this).text("stop");
2014-04-06 00:47:59 +00:00
}
});
2014-04-06 00:47:59 +00:00
2014-04-03 21:13:13 +00:00
</script>
</body>
</html>