mirror of
https://github.com/Tonejs/Tone.js
synced 2024-11-16 08:38:00 +00:00
73 lines
No EOL
1.5 KiB
HTML
73 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>
|
|
</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>
|
|
<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();
|
|
|
|
//meters
|
|
var dryMeter = new Tone.Meter();
|
|
var wetMeter = new Tone.Meter();
|
|
|
|
//meter the outputs
|
|
dryWet.dry.connect(dryMeter);
|
|
dryWet.wet.connect(wetMeter);
|
|
|
|
|
|
//INTERFACE//
|
|
|
|
var dry = document.querySelector("#dry");
|
|
var wet = document.querySelector("#wet");
|
|
var output = document.querySelector("#mix");
|
|
|
|
setInterval(function(){
|
|
dry.textContent = "dry: " + dryMeter.getDb().toFixed(2) + " db";
|
|
wet.textContent = "wet: " + wetMeter.getDb().toFixed(2) + " db";
|
|
}, 100);
|
|
|
|
var range = document.querySelector("input");
|
|
range.oninput = function(){
|
|
var val = range.value;
|
|
dryWet.setWet(val/100, 0);
|
|
}
|
|
|
|
var button = document.querySelector("button");
|
|
|
|
button.onclick = function(){
|
|
if (sine.state !== "started"){
|
|
sine.start();
|
|
square.start();
|
|
button.textContent = "stop";
|
|
} else {
|
|
sine.stop();
|
|
square.stop();
|
|
button.textContent = "start";
|
|
}
|
|
}
|
|
|
|
</script>
|
|
</body>
|
|
</html> |