Skip to content

Commit

Permalink
clamp pitch range to fix mute bug
Browse files Browse the repository at this point in the history
  • Loading branch information
44100hertz committed Jan 25, 2024
1 parent 1e0d5f6 commit 1d7e204
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions games/redbricks/sound.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const sound = filenames.reduce((acc, filename) => {
}, {});

export function play(name, pitch_offset = 0) {
pitch_offset = Math.min(12*2, Math.max(-12*2, pitch_offset))
sound[name].playbackRate = Math.pow(2, pitch_offset/12);
sound[name].currentTime = 0;
sound[name].play();
Expand Down

0 comments on commit 1d7e204

Please sign in to comment.