mirror of
https://github.com/Tonejs/Tone.js
synced 2024-12-29 04:53:10 +00:00
66 lines
No EOL
1.3 KiB
HTML
66 lines
No EOL
1.3 KiB
HTML
<html>
|
|
<head>
|
|
<title>AUTOPANNER</title>
|
|
|
|
<script src="http://code.jquery.com/jquery-2.1.0.min.js"></script>
|
|
<!--
|
|
<script type="text/javascript" src='../Tone.js'></script>
|
|
-->
|
|
<script type="text/javascript" src="../deps/require.js"></script>
|
|
</head>
|
|
<body>
|
|
<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", "effects/AutoPanner", "component/Meter"], function(Tone){
|
|
//panner
|
|
var pan = new Tone.AutoPanner();
|
|
|
|
//input signals
|
|
var sine = Tone.context.createOscillator();
|
|
// sine.start(0);
|
|
|
|
//connect it up
|
|
sine.connect(pan);
|
|
|
|
pan.toMaster();
|
|
|
|
//meters
|
|
var meter = new Tone.Meter(2);
|
|
|
|
//meter the outputs
|
|
pan.connect(meter);
|
|
pan.start();
|
|
|
|
|
|
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);
|
|
|
|
$("button").click(function(){
|
|
sine.start();
|
|
})
|
|
|
|
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;
|
|
});
|
|
|
|
</script>
|
|
</body>
|
|
</html> |