Tone.js/examples/noises.html

64 lines
1.7 KiB
HTML
Raw Normal View History

<!DOCTYPE html>
2014-06-20 04:25:00 +00:00
<html>
<head>
<meta charset="utf-8">
2019-01-09 01:21:29 +00:00
<title>Noise</title>
2014-06-20 04:25:00 +00:00
2019-01-09 01:21:29 +00:00
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="icon" type="image/png" sizes="174x174" href="./favicon.png">
2014-09-06 19:35:31 +00:00
2020-07-18 00:58:09 +00:00
<script src="https://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/2.4.3/webcomponents-bundle.js"></script>
<link href="https://fonts.googleapis.com/css?family=Material+Icons&display=block" rel="stylesheet"/>
<script src="../build/Tone.js"></script>
2020-07-18 00:58:09 +00:00
<script src="./js/tone-ui.js"></script>
<script src="./js/components.js"></script>
2015-02-12 03:39:28 +00:00
</head>
<body>
2019-01-09 01:21:29 +00:00
<style>
tone-trigger, tone-oscilloscope {
margin-bottom: 10px;
}
tone-oscilloscope {
background-color: black;
height: 60px;
width: 100%;
2015-06-07 18:05:59 +00:00
}
</style>
<tone-example label="Noise">
<div slot="explanation">
2019-01-09 01:21:29 +00:00
<a href="https://tonejs.github.io/docs/Noise">Tone.Noise</a>
2015-06-27 22:02:55 +00:00
has 3 different types of noise. Careful, it's loud!
</div>
2019-01-09 01:21:29 +00:00
<div id="content">
<tone-momentary-button></tone-momentary-button>
</div>
2019-01-09 01:21:29 +00:00
</tone-example>
<script type="text/javascript">
2020-07-19 00:20:19 +00:00
// make the noise and connect it to the output
const noise = new Tone.Noise({
2020-07-19 00:20:19 +00:00
volume: -10,
type: "brown"
}).toDestination();
2020-07-19 00:20:19 +00:00
const toneWaveform = new Tone.Waveform();
noise.connect(toneWaveform);
waveform({
2020-07-19 00:20:19 +00:00
parent: document.querySelector("#content"),
tone: toneWaveform,
2020-07-19 00:20:19 +00:00
});
ui({
2020-07-19 00:20:19 +00:00
parent: document.querySelector("#content"),
tone: noise,
2020-07-19 00:20:19 +00:00
});
2015-02-12 03:39:28 +00:00
2020-07-19 00:20:19 +00:00
// bind the inteface
document.querySelector("tone-momentary-button").addEventListener("down", () => noise.start());
document.querySelector("tone-momentary-button").addEventListener("up", () => noise.stop());
2015-02-12 03:39:28 +00:00
</script>
2014-06-20 04:25:00 +00:00
</body>
</html>