mirror of
https://github.com/Tonejs/Tone.js
synced 2024-11-16 16:48:00 +00:00
57 lines
1.2 KiB
HTML
57 lines
1.2 KiB
HTML
<html>
|
|
<head>
|
|
<title>PANNER</title>
|
|
|
|
<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">
|
|
</head>
|
|
<body>
|
|
<div>Pan a sine wave Left/Right</div>
|
|
<br>
|
|
<button type="button">start</button>
|
|
<input type='range' value='50'>
|
|
<div id='left'>0</div>
|
|
<div id='right'>0</div>
|
|
<script type="text/javascript">
|
|
|
|
var pan = new Tone.Panner();
|
|
var sine = new Tone.Oscillator();
|
|
|
|
//connect it up
|
|
sine.connect(pan);
|
|
pan.toMaster();
|
|
|
|
//meters
|
|
var outputMeter = new Tone.Meter(2);
|
|
pan.connect(outputMeter);
|
|
|
|
//INTERFACE//
|
|
|
|
var button = document.querySelector("button");
|
|
|
|
$("button").click(function(){
|
|
if (sine.state !== "started"){
|
|
sine.start();
|
|
$(this).text("stop");
|
|
} else {
|
|
sine.stop();
|
|
$(this).text("start");
|
|
}
|
|
});
|
|
|
|
//update the meters
|
|
setInterval(function(){
|
|
$("#left").text("left: " + outputMeter.getDb(0).toFixed(2) + " db");
|
|
$("#right").text("right: " + outputMeter.getDb(1).toFixed(2) + " db");
|
|
}, 100);
|
|
|
|
|
|
$("input").on("input", function(e){
|
|
var val = $(this).val();
|
|
pan.setPan(val/100, "0.1");
|
|
});
|
|
|
|
</script>
|
|
</body>
|
|
</html>
|