-
Notifications
You must be signed in to change notification settings - Fork 0
/
part3.html
37 lines (31 loc) · 991 Bytes
/
part3.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<script src="https://unpkg.com/[email protected]/build/Tone.js"></script>
<button id="play">Play</button>
<button id="higher">Higher</button>
<button id="lower">Lower</button>
<script>
let pitchShift;
const url = "https://cdn.freesound.org/previews/163/163286_1102035-lq.mp3"; // use any valid audio file if this disappears over time...
const btn = document.querySelector("button#play");
btn.addEventListener("click", async () => {
await Tone.start();
const player = new Tone.Player({
url,
loop: true,
autostart: false,
});
await Tone.loaded();
pitchShift = new Tone
.PitchShift({pitch: 0})
.toDestination();
player.connect(pitchShift);
player.start();
});
const btn2 = document.querySelector("button#higher");
btn2.addEventListener("click", async () => {
pitchShift.pitch += 2;
});
const btn3 = document.querySelector("button#lower");
btn3.addEventListener("click", async () => {
pitchShift.pitch -= 2;
});
</script>