Tone.js/examples/dryWet.html
2014-04-06 16:51:30 -04:00

76 lines
No EOL
1.6 KiB
HTML

<html>
<head>
<title>DRY/WET</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>start</button>
<input type='range' value='50'>
<div id='dry'>0</div>
<div id='wet'>0</div>
<div id='mix'>0</div>
<script type="text/javascript">
require.config({
baseUrl : "../"
});
require(["Tone/core/Tone", "Tone/component/DryWet", "Tone/component/Meter"], function(Tone){
//dry wet knob
var dryWet = new Tone.DryWet();
//input signals
var sine = Tone.context.createOscillator();
var square = Tone.context.createOscillator();
square.type = "square";
square.frequency.value = 220;
//connect it up
sine.connect(dryWet.dry);
square.connect(dryWet.wet);
dryWet.toMaster();
//meters
var dryMeter = new Tone.Meter();
var wetMeter = new Tone.Meter();
var output = new Tone.Meter();
//meter the outputs
dryWet.dry.connect(dryMeter);
dryWet.wet.connect(wetMeter);
dryWet.connect(output);
var $dry = $("#dry");
var $wet = $("#wet");
var $output = $("#mix");
setInterval(function(){
$dry.html("dry: " + dryMeter.getDb().toFixed(2) + " db");
$wet.html("wet: " + wetMeter.getDb().toFixed(2) + " db");
$output.html("mix: " + output.getDb().toFixed(2) + " db");
}, 100);
var range = $("input")[0];
range.onchange = function(){
var val = range.value;
var now = dryWet.now();
dryWet.setWet(val/50 - 1);
}
$("button").click(function(){
sine.start(0);
square.start(0);
});
});
</script>
</body>
</html>