How To

Pause/resume Sounds or Tracks

3

nathanielbabiak 2022-06-05 03:35

I have a sound that lasts for 2 seconds (120 ticks or 120 frames) and I'd like it to go silent if the pause button is pressed during the sound, and I'd like it to return when the pause button is pressed again to resume the game.

I have a similar situation for a track.

I have some ideas, but it gets complicated pretty quick. Does anybody have a good way to handle this?


was8bit 2022-06-05 04:36

You can issue the command to stop playing music, but initiated sounds will expire natually beyond the command

Think of it this way... if you have added an echo effect to a sound, say a horn... you can stop playing the horn... but you can do nothing to stop the echo.... same analalgy... ;)


was8bit 2022-06-05 04:38

IF you remove ALL echo, so that the sound stops completely when it’s done, you will get what you want.. but this will severely limit your sound effects


nathanielbabiak 2022-06-05 11:18 (Edited)

Stopping isn't so bad just by setting the volume to 0, but the issue is (and I forgot to write this above), the resumed sound/track needs to resume in-the-middle, when it was paused. Otherwise the timing is incorrect.


was8bit 2022-06-05 12:03 (Edited)

As far as I know, tracks always start at the top...

It IS technically possible to code your own player... if your music is very simple it might be something to look into...


Timo 2022-06-05 20:42

I can’t think of a way to continue a stopped sound. Maybe somehow edit the sound values so that a new sound sounds like the continuation of the old. But that’s very tricky…
There is no way to freeze the timer of the sound chip.


Log in to reply.