2014-04-05 00:24:19 +00:00
|
|
|
<html>
|
|
|
|
<head>
|
2014-04-05 22:05:42 +00:00
|
|
|
<title>PANNER</title>
|
2014-04-05 00:24:19 +00:00
|
|
|
|
2014-06-23 17:29:22 +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-05 00:24:19 +00:00
|
|
|
</head>
|
|
|
|
<body>
|
2014-06-23 17:29:22 +00:00
|
|
|
<div>Pan a sine wave Left/Right</div>
|
|
|
|
<br>
|
2014-04-06 00:47:59 +00:00
|
|
|
<button type="button">start</button>
|
2014-04-05 00:24:19 +00:00
|
|
|
<input type='range' value='50'>
|
|
|
|
<div id='left'>0</div>
|
|
|
|
<div id='right'>0</div>
|
|
|
|
<script type="text/javascript">
|
|
|
|
|
2014-04-16 00:05:11 +00:00
|
|
|
var pan = new Tone.Panner();
|
|
|
|
var sine = new Tone.Oscillator();
|
2014-04-05 00:24:19 +00:00
|
|
|
|
2014-04-16 00:05:11 +00:00
|
|
|
//connect it up
|
|
|
|
sine.connect(pan);
|
|
|
|
pan.toMaster();
|
2014-04-05 00:24:19 +00:00
|
|
|
|
2014-04-16 00:05:11 +00:00
|
|
|
//meters
|
|
|
|
var outputMeter = new Tone.Meter(2);
|
|
|
|
pan.connect(outputMeter);
|
2014-04-05 00:24:19 +00:00
|
|
|
|
2014-04-16 00:05:11 +00:00
|
|
|
//INTERFACE//
|
2014-04-05 00:24:19 +00:00
|
|
|
|
2014-04-16 00:05:11 +00:00
|
|
|
var button = document.querySelector("button");
|
2014-04-05 00:24:19 +00:00
|
|
|
|
2014-06-23 17:29:22 +00:00
|
|
|
$("button").click(function(){
|
|
|
|
if (sine.state !== "started"){
|
2014-04-16 00:05:11 +00:00
|
|
|
sine.start();
|
2014-06-23 17:29:22 +00:00
|
|
|
$(this).text("stop");
|
2014-04-16 00:05:11 +00:00
|
|
|
} else {
|
|
|
|
sine.stop();
|
2014-06-23 17:29:22 +00:00
|
|
|
$(this).text("start");
|
2014-04-05 22:05:42 +00:00
|
|
|
}
|
2014-06-23 17:29:22 +00:00
|
|
|
});
|
2014-04-06 00:47:59 +00:00
|
|
|
|
2014-06-23 17:29:22 +00:00
|
|
|
//update the meters
|
2014-04-16 00:05:11 +00:00
|
|
|
setInterval(function(){
|
2014-06-23 17:29:22 +00:00
|
|
|
$("#left").text("left: " + outputMeter.getDb(0).toFixed(2) + " db");
|
|
|
|
$("#right").text("right: " + outputMeter.getDb(1).toFixed(2) + " db");
|
2014-04-16 00:05:11 +00:00
|
|
|
}, 100);
|
|
|
|
|
|
|
|
|
2014-06-23 17:29:22 +00:00
|
|
|
$("input").on("input", function(e){
|
|
|
|
var val = $(this).val();
|
|
|
|
pan.setPan(val/100, "0.1");
|
|
|
|
});
|
2014-06-15 20:40:41 +00:00
|
|
|
|
2014-04-05 00:24:19 +00:00
|
|
|
</script>
|
|
|
|
</body>
|
2014-06-15 20:40:41 +00:00
|
|
|
</html>
|