Tone.js/examples/dryWet.html

66 lines
No EOL
1.5 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="../Tone.js"></script>
<link rel="stylesheet" type="text/css" href="exampleStyle.css">
</head>
<body>
<div>A sine wave is connected to the dry side and a square wave is connected to the wet side.</div>
<br>
<button>start</button><br>
<input type='range' value='50'>
<div id='dry'>0</div>
<div id='wet'>0</div>
<script type="text/javascript">
//dry wet knob
var dryWet = new Tone.DryWet(0.5);
//input signals
var sine = new Tone.Oscillator(440, "sine");
var square = new Tone.Oscillator(220, "square");
//connect it up
sine.connect(dryWet.dry);
square.connect(dryWet.wet);
dryWet.toMaster();
sine.setVolume(0.5);
square.setVolume(0.5);
//meters
var dryMeter = new Tone.Meter();
var wetMeter = new Tone.Meter();
//meter the outputs
dryWet.dry.connect(dryMeter);
dryWet.wet.connect(wetMeter);
//update the meters
setInterval(function(){
$("#dry").text("dry: " + dryMeter.getDb().toFixed(2) + " db");
$("#wet").text("wet: " + wetMeter.getDb().toFixed(2) + " db");
}, 100);
$("input").on("input", function(){
var val = $(this).val();
dryWet.setWet(val/100, 0);
});
$("button").click(function(){
if (sine.state !== "started"){
sine.start();
square.start();
$(this).text("stop");
} else {
sine.stop();
square.stop();
$(this).text("start");
}
});
</script>
</body>
</html>