mirror of
https://github.com/Tonejs/Tone.js
synced 2024-12-27 03:53:07 +00:00
93 lines
2.1 KiB
HTML
93 lines
2.1 KiB
HTML
<!doctype html>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<title>Analyser</title>
|
|
|
|
<meta
|
|
name="viewport"
|
|
content="width=device-width, initial-scale=1, maximum-scale=1"
|
|
/>
|
|
<link
|
|
rel="icon"
|
|
type="image/png"
|
|
sizes="174x174"
|
|
href="./favicon.png"
|
|
/>
|
|
|
|
<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>
|
|
<script src="./js/tone-ui.js"></script>
|
|
<script src="./js/components.js"></script>
|
|
</head>
|
|
<body>
|
|
<tone-example label="Analyser">
|
|
<tone-loader></tone-loader>
|
|
|
|
<div slot="explanation">
|
|
<a
|
|
href="https://tonejs.github.io/docs/latest/classes/FFT"
|
|
target="_blank"
|
|
>Tone.FFT</a
|
|
>
|
|
returns the amplitude of the incoming signal at different
|
|
frequencies.
|
|
<a
|
|
href="https://tonejs.github.io/docs/latest/classes/Waveform"
|
|
target="_blank"
|
|
>Tone.Waveform</a
|
|
>
|
|
returns the signal value between 0-1.
|
|
</div>
|
|
|
|
<div id="content">
|
|
<tone-play-toggle></tone-play-toggle>
|
|
</div>
|
|
</tone-example>
|
|
|
|
<script type="text/javascript">
|
|
const player = new Tone.Player({
|
|
url: "https://tonejs.github.io/audio/berklee/arpeggio2.mp3",
|
|
loop: true,
|
|
}).toDestination();
|
|
|
|
const toneMeter = new Tone.Meter();
|
|
player.connect(toneMeter);
|
|
|
|
const toneFFT = new Tone.FFT();
|
|
player.connect(toneFFT);
|
|
|
|
const toneWaveform = new Tone.Waveform();
|
|
player.connect(toneWaveform);
|
|
|
|
// bind the GUI
|
|
drawer().add({
|
|
tone: player,
|
|
title: "Player",
|
|
});
|
|
meter({
|
|
tone: toneMeter,
|
|
parent: document.querySelector("#content"),
|
|
});
|
|
fft({
|
|
tone: toneFFT,
|
|
parent: document.querySelector("#content"),
|
|
});
|
|
waveform({
|
|
tone: toneWaveform,
|
|
parent: document.querySelector("#content"),
|
|
});
|
|
|
|
document
|
|
.querySelector("tone-play-toggle")
|
|
.addEventListener("start", () => player.start());
|
|
document
|
|
.querySelector("tone-play-toggle")
|
|
.addEventListener("stop", () => player.stop());
|
|
</script>
|
|
</body>
|
|
</html>
|