Tone.js/examples/pitchShift.html

62 lines
1.9 KiB
HTML
Raw Normal View History

2019-10-28 12:05:02 +00:00
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Pitch Shift</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">
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"/>
2019-10-28 12:05:02 +00:00
<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>
2019-10-28 12:05:02 +00:00
</head>
<body>
<style>
tone-slider {
width: 100%;
margin-top: 10px;
}
</style>
<tone-example label="Pitch Shift">
<div slot="explanation">
2019-10-28 12:05:02 +00:00
This example demonstrates the Pitch Shift effect.
<br><br>
<a href="https://tonejs.github.io/docs/PitchShift">Tone.Pitch Shift</a> docs.
</div>
<tone-loader></tone-loader>
<div id="content">
2019-10-28 12:05:02 +00:00
<tone-play-toggle></tone-play-toggle>
<tone-slider label="pitch" min="-12" max="12" value="0" units="hz"></tone-slider>
</div>
2019-10-28 12:05:02 +00:00
</tone-example>
<script type="text/javascript">
2020-07-19 00:20:19 +00:00
const pitchShift = new Tone.PitchShift().toDestination();
const player = new Tone.Player("https://tonejs.github.io/audio/berklee/groovin_analogsynth1.mp3").connect(pitchShift);
player.loop = true;
2019-10-28 12:05:02 +00:00
2020-07-19 00:20:19 +00:00
const toneFFT = new Tone.FFT();
pitchShift.connect(toneFFT);
fft({
2020-07-19 00:20:19 +00:00
parent: document.querySelector("#content"),
tone: toneFFT,
2020-07-19 00:20:19 +00:00
});
2019-10-28 12:05:02 +00:00
2020-07-19 00:20:19 +00:00
// bind the interface
document.querySelector("tone-play-toggle").addEventListener("start", () => player.start());
document.querySelector("tone-play-toggle").addEventListener("stop", () => player.stop());
// document.querySelector("tone-play-toggle").addEventListener('start', () => {
// debugger;
// });
2019-10-28 12:05:02 +00:00
document.querySelector("tone-slider").addEventListener("input", e => {
pitchShift.pitch = parseFloat(e.target.value);
2019-10-28 12:05:02 +00:00
});
</script>
</body>
</html>