Tone.js/examples/dryWet.html

66 lines
1.5 KiB
HTML
Raw Normal View History

2014-04-04 18:36:01 +00:00
<html>
<head>
2014-04-06 00:47:59 +00:00
<title>DRY/WET</title>
2014-04-04 18:36:01 +00:00
<script src="http://code.jquery.com/jquery-2.1.0.min.js"></script>
2014-06-20 05:12:15 +00:00
<script type="text/javascript" src="../Tone.js"></script>
2014-06-20 15:04:32 +00:00
<link rel="stylesheet" type="text/css" href="exampleStyle.css">
2014-04-04 18:36:01 +00:00
</head>
<body>
<div>A sine wave is connected to the dry side and a square wave is connected to the wet side.</div>
<br>
2014-06-20 15:04:32 +00:00
<button>start</button><br>
2014-04-04 18:36:01 +00:00
<input type='range' value='50'>
<div id='dry'>0</div>
<div id='wet'>0</div>
<script type="text/javascript">
//dry wet knob
2014-06-20 05:46:10 +00:00
var dryWet = new Tone.DryWet(0.5);
2014-04-06 00:47:59 +00:00
//input signals
var sine = new Tone.Oscillator(440, "sine");
var square = new Tone.Oscillator(220, "square");
2014-04-04 18:36:01 +00:00
//connect it up
sine.connect(dryWet.dry);
square.connect(dryWet.wet);
dryWet.toMaster();
2014-04-04 18:36:01 +00:00
2014-06-21 17:04:32 +00:00
sine.setVolume(0.5);
square.setVolume(0.5);
//meters
var dryMeter = new Tone.Meter();
var wetMeter = new Tone.Meter();
2014-04-05 00:24:19 +00:00
//meter the outputs
dryWet.dry.connect(dryMeter);
dryWet.wet.connect(wetMeter);
2014-04-05 00:24:19 +00:00
//update the meters
setInterval(function(){
$("#dry").text("dry: " + dryMeter.getDb().toFixed(2) + " db");
$("#wet").text("wet: " + wetMeter.getDb().toFixed(2) + " db");
}, 100);
2014-04-04 18:36:01 +00:00
$("input").on("input", function(){
var val = $(this).val();
dryWet.setWet(val/100, 0);
});
2014-04-06 00:47:59 +00:00
$("button").click(function(){
2014-06-20 05:12:15 +00:00
if (sine.state !== "started"){
sine.start();
square.start();
$(this).text("stop");
} else {
sine.stop();
square.stop();
$(this).text("start");
2014-04-06 00:47:59 +00:00
}
});
2014-04-04 18:36:01 +00:00
</script>
</body>
</html>