mirror of
https://github.com/Tonejs/Tone.js
synced 2024-11-16 08:38:00 +00:00
45 lines
No EOL
1 KiB
HTML
45 lines
No EOL
1 KiB
HTML
<html>
|
|
<head>
|
|
<title>NOISES</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>Change switch to random noise type every quarter-second for 8 seconds</div>
|
|
<br>
|
|
<button>start</button>
|
|
<div id='noise'></div>
|
|
<script type="text/javascript">
|
|
var noise = new Tone.Noise();
|
|
noise.toMaster();
|
|
|
|
var noiseTypes = ["white", "brown", "pink"];
|
|
|
|
Tone.Transport.setInterval(function(time){
|
|
//set a random noise type
|
|
var randomIndex = Math.floor(Math.random()* noiseTypes.length);
|
|
var randomNoise = noiseTypes[randomIndex];
|
|
noise.setType(randomNoise, time);
|
|
|
|
$("#noise").text(randomNoise);
|
|
}, 0.25);
|
|
|
|
Tone.Transport.setTimeout(function(time){
|
|
noise.stop(time);
|
|
Tone.Transport.stop();
|
|
$("#noise").text("");
|
|
}, 8);
|
|
|
|
$("button").click(function(){
|
|
Tone.Transport.start();
|
|
noise.start();
|
|
$(this).remove();
|
|
});
|
|
|
|
</script>
|
|
</body>
|
|
</html> |