Tone.js/examples/autoPanner.html

67 lines
1.3 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>
2014-04-06 00:47:59 +00:00
<!--
<script type="text/javascript" src='../build/Tone.js'></script>
2014-04-06 00:47:59 +00:00
-->
<script type="text/javascript" src="../deps/require.js"></script>
2014-04-03 21:13:13 +00:00
</head>
<body>
2014-04-06 00:47:59 +00:00
<button>start</button>
<input type='range' value='50'>
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">
2014-04-06 00:47:59 +00:00
require.config({
2014-04-06 20:51:30 +00:00
baseUrl : "../"
2014-04-06 00:47:59 +00:00
});
2014-04-03 21:13:13 +00:00
2014-04-06 20:51:30 +00:00
require(["Tone/core/Tone", "Tone/core/Master", "Tone/effects/AutoPanner", "Tone/component/Meter"],
function(Tone){
2014-04-06 00:47:59 +00:00
//panner
var pan = new Tone.AutoPanner();
2014-04-03 21:13:13 +00:00
2014-04-06 00:47:59 +00:00
//input signals
var sine = Tone.context.createOscillator();
// sine.start(0);
2014-04-03 21:13:13 +00:00
2014-04-06 00:47:59 +00:00
//connect it up
sine.connect(pan);
2014-04-05 00:24:19 +00:00
2014-04-06 00:47:59 +00:00
pan.toMaster();
2014-04-05 00:24:19 +00:00
2014-04-06 00:47:59 +00:00
//meters
var meter = new Tone.Meter(2);
2014-04-05 00:24:19 +00:00
2014-04-06 00:47:59 +00:00
//meter the outputs
pan.connect(meter);
pan.start();
2014-04-05 00:24:19 +00:00
2014-04-06 00:47:59 +00:00
var $left = $("#left");
var $right = $("#right");
setInterval(function(){
$left.html("left: " + meter.getDb(0).toFixed(2) + " db");
$right.html("right: " + meter.getDb(1).toFixed(2) + " db");
}, 100);
2014-04-03 21:13:13 +00:00
2014-04-06 00:47:59 +00:00
$("button").click(function(){
sine.start();
})
2014-04-03 21:13:13 +00:00
2014-04-06 00:47:59 +00:00
var range = $("input")[0];
range.onchange = function(){
var val = range.value;
var now = pan.now();
pan.setDry(val / 50 - 1, now + .1);
}
window.pan = pan;
});
2014-04-03 21:13:13 +00:00
</script>
</body>
</html>