mirror of
https://github.com/Tonejs/Tone.js
synced 2024-12-29 04:53:10 +00:00
37 lines
No EOL
650 B
HTML
37 lines
No EOL
650 B
HTML
<html>
|
|
<head>
|
|
<title>Bit Crush</title>
|
|
|
|
<script type="text/javascript" src='../Tone.js'></script>
|
|
|
|
</head>
|
|
<body>
|
|
<button>start</button>
|
|
<script type="text/javascript">
|
|
|
|
//components
|
|
var sine = new Tone.Oscillator();
|
|
var crusher = new Tone.BitCrusher(5);
|
|
|
|
//connections
|
|
sine.connect(crusher);
|
|
crusher.toMaster();
|
|
|
|
//INTERFACE//
|
|
|
|
var button = document.querySelector("button");
|
|
|
|
//called when the start button is clicked
|
|
button.onclick = function(){
|
|
if (!sine.started){
|
|
sine.start();
|
|
button.textContent = "stop";
|
|
} else {
|
|
sine.stop();
|
|
button.textContent = "start";
|
|
}
|
|
}
|
|
|
|
</script>
|
|
</body>
|
|
</html> |