Log In  

Is it possible to pause or mute music in Pico-8 from script?

I want to halt the music for a short period when the player dies, and resume it when they respawn. Pause or Mute would both work in this case; I just don't want to restart the whole song every time they die.


This is what I currently do:

-- Player Spawns...

--Player dies

-- Player Spawns...
P#35493 2017-01-11 20:59 ( Edited 2017-01-12 01:59)

Hey, @mhughson, have you figured out any other workaround for pausing (or muting music)? This would be super useful to me too.

P#70323 2019-11-28 17:08

Sorry @alanxoc3, but I don't even remember which project this was for!

P#70324 2019-11-28 17:10
:: dw817

This works sort of. It will record the music position where you are and continue it. Unfortunately there does not seem to be a way to play back according to location in the music position either peek or poke, I checked.

Now while STAT() does contain information about what is playing and where, you cannot reverse to send STAT back to the best of my knowledge.

Cart #totafohese-0 | 2019-11-28 | Code ▽ | Embed ▽ | No License


P#70331 2019-11-28 19:33

A bit brutal (stops sfx as well) but that undocument poke was found some time ago: https://twitter.com/bone_volt/status/1173584954359517184

P#70334 2019-11-28 20:06

Ok, @dw817, I didn't know stat could tell you music information. But not exactly what I was looking for.

I did figure something out though. One way pauses the music with a specific memory location with poke. The other way will mute the music, while still playing it. Here is an example cartridge.

Cart #pause_music-0 | 2019-11-28 | Code ▽ | Embed ▽ | No License

The downside to using poke is that it pauses all sound for the cartridge, so you can't play any sound effects while the sound is paused. The other way plays a sound effect over the music. If the sound effect is empty and looping, it can act as "muting" the music.

EDIT: Note that playing an empty sound effect over the music also lets you play sound effects while the music is muted!

P#70335 2019-11-28 20:07 ( Edited 2019-11-28 20:10)

@freds72 I did find out about that just before you commented :), but yeah, it is a bit too brutal for me.

P#70336 2019-11-28 20:09
:: dw817

Pretty nifty poke there, @freds72. Adding to my notes ... thanks.

@alanxoc3, glad to help out !

P#70339 2019-11-28 20:37 ( Edited 2019-11-28 20:57)

[Please log in to post a comment]

Follow Lexaloffle:        
Generated 2020-09-28 11:36 | 0.061s | 2097k | Q:58