Tone.js/examples/panner.html
2014-04-05 20:47:59 -04:00

63 lines
No EOL
1.3 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="../deps/require.js"></script>
</head>
<body>
<style type="text/css">
</style>
<button type="button">start</button>
<input type='range' value='50'>
<div id='left'>0</div>
<div id='right'>0</div>
<script type="text/javascript">
require.config({
baseUrl : "../src"
});
require(["core/Tone", "core/Master", "component/Panner", "component/Meter"],
function(Tone){
//panner
var pan = new Tone.Panner();
//input signals
var sine = Tone.context.createOscillator();
// var sine = new Tone.Signal(100);
//connect it up
sine.connect(pan);
pan.toMaster();
//meters
var output = new Tone.Meter(2);
//meter the outputs
pan.connect(output);
var $left = $("#left");
var $right = $("#right");
setInterval(function(){
$left.html("left: " + output.getDb(0).toFixed(2) + " db");
$right.html("right: " + output.getDb(1).toFixed(2) + " db");
}, 100);
var range = $("input")[0];
range.onchange = function(){
var val = range.value;
var now = pan.now();
pan.setPan(val/50 - 1, now+.1);
}
$("button").click(function(){
sine.start(0);
})
});
</script>
</body>
</html>