mirror of
https://github.com/Tonejs/Tone.js
synced 2024-12-27 03:53:07 +00:00
49 lines
1.3 KiB
HTML
49 lines
1.3 KiB
HTML
<!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">
|
|
|
|
<script src="https://unpkg.com/@webcomponents/webcomponentsjs@^2/webcomponents-bundle.js"></script>
|
|
<script src="../build/Tone.js"></script>
|
|
<script src="./js/tonejs-ui.js"></script>
|
|
</head>
|
|
<body>
|
|
<style>
|
|
tone-slider {
|
|
width: 100%;
|
|
margin-top: 10px;
|
|
}
|
|
</style>
|
|
<tone-example>
|
|
<tone-explanation label="Pitch Shift">
|
|
This example demonstrates the Pitch Shift effect.
|
|
<br><br>
|
|
<a href="https://tonejs.github.io/docs/PitchShift">Tone.Pitch Shift</a> docs.
|
|
</tone-explanation>
|
|
|
|
<tone-content>
|
|
<tone-play-toggle></tone-play-toggle>
|
|
<tone-slider label="pitch" min="-12" max="12" value="0"></tone-slider>
|
|
</tone-content>
|
|
</tone-example>
|
|
|
|
<script type="text/javascript">
|
|
var oscillator = new Tone.Oscillator();
|
|
var pitchShift = new Tone.PitchShift();
|
|
|
|
oscillator.connect(pitchShift);
|
|
pitchShift.toMaster();
|
|
|
|
//bind the interface
|
|
document.querySelector("tone-play-toggle").bind(oscillator);
|
|
|
|
document.querySelector("tone-slider").addEventListener("change", e => {
|
|
pitchShift.pitch = e.detail;
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|