Skip to content

Commit

Permalink
bug fix: zero duration sound (#243)
Browse files Browse the repository at this point in the history
  • Loading branch information
martin-henz authored Sep 12, 2023
1 parent 1560bc1 commit c9ce9df
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/bundles/sound/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,8 @@ export function play_in_tab(sound: Sound): Sound {
throw new Error(`${play_in_tab.name}: audio system still playing previous sound`);
} else if (get_duration(sound) < 0) {
throw new Error(`${play_in_tab.name}: duration of sound is negative`);
} else if (get_duration(sound) === 0) {
return sound;
} else {
// Instantiate audio context if it has not been instantiated.
if (!audioplayer) {
Expand Down Expand Up @@ -417,6 +419,8 @@ export function play(sound: Sound): Sound {
);
} else if (get_duration(sound) < 0) {
throw new Error(`${play.name}: duration of sound is negative`);
} else if (get_duration(sound) === 0) {
return sound;
} else {
// Instantiate audio context if it has not been instantiated.
if (!audioplayer) {
Expand Down
4 changes: 4 additions & 0 deletions src/bundles/stereo_sound/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,8 @@ export function play_in_tab(sound: Sound): Sound {
throw new Error(`${play_in_tab.name}: audio system still playing previous sound`);
} else if (get_duration(sound) < 0) {
throw new Error(`${play_in_tab.name}: duration of sound is negative`);
} else if (get_duration(sound) === 0) {
return sound;
} else {
// Instantiate audio context if it has not been instantiated.
if (!audioplayer) {
Expand Down Expand Up @@ -478,6 +480,8 @@ export function play(sound: Sound): Sound {
throw new Error(`${play.name}: audio system still playing previous sound`);
} else if (get_duration(sound) < 0) {
throw new Error(`${play.name}: duration of sound is negative`);
} else if (get_duration(sound) === 0) {
return sound;
} else {
// Instantiate audio context if it has not been instantiated.
if (!audioplayer) {
Expand Down

0 comments on commit c9ce9df

Please sign in to comment.