Skip to content

Commit

Permalink
loud sound
Browse files Browse the repository at this point in the history
  • Loading branch information
debashisbiswas committed Jan 30, 2024
1 parent 21b3bf8 commit 93f2680
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
Binary file removed public/asrx_down.wav
Binary file not shown.
Binary file removed public/asrx_up.wav
Binary file not shown.
Binary file removed public/click.wav
Binary file not shown.
19 changes: 10 additions & 9 deletions src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,21 @@
let scheduleId = 0;
Tone.Transport.bpm.value = 80;
const player = new Tone.Player("./asrx_down.wav").toDestination();
async function togglePlaying() {
await Tone.start();
Tone.Transport.start();
if (!playing) {
scheduleId = Tone.Transport.scheduleRepeat(
(time) => {
// Ensure time is passed into this function, or the click timing won't be consistent
player.start(time);
},
"4n",
Tone.now(),
);
scheduleId = Tone.Transport.scheduleRepeat((time) => {
const noteLength = 0.015;
const gain = new Tone.Gain(16).toDestination();
const osc = new Tone.Oscillator(783.99).connect(gain);
gain.gain.linearRampToValueAtTime(0, time + noteLength);
osc.start(time);
osc.stop(time + noteLength);
}, "4n");
} else {
Tone.Transport.clear(scheduleId);
scheduleId = 0;
Expand Down

0 comments on commit 93f2680

Please sign in to comment.