2 repeating songs problem

bamibal

L1: Registered
Aug 14, 2015
47
5
I have added 2 music buttons in my map, both triggering a logic_timer (which I use to make the songs repeat since they are mp3s), which triggers an ambient_generic.

I want the currently playing song to shut up as soon as someone hits the other music button. This does work when I have the 'is NOT looped' flags unchecked. In this case though, the songs don't replay when the logic_timer refires.

When I uncheck the 'is NOT looped' flags on both ambient_generics, the songs DO repeat when they're finished, but now they won't switch each other off when the buttons are hit. I'm breaking my brains over this.

My settings

Button 1

logic_timer is named Folsomtimer
ambient_generic is named Folsomprison

Outputs:
OnDamaged: Folsomtimer Enable
OnDamaged: Folsomtimer FireTimer (with delay 0.01, seems to be necessary as enabling and firing at the same time sometimes doesn't work)
OnDamaged: looptimer Disable
OnDamaged: Soundplayer Stopsound

Button 2 (this is a toggle)

logic_timer is named looptimer
ambient_generic is named Soundplayer

Outputs:
OnIn: looptimer Enable
OnIn: Looptimer Firetimer
OnIn: Folsomtimer Disable
OnIn: Folsomprison Stopsound

I hope it's slightly clear like this, might be hard to understand because of the stupid names I give things :p
 

worMatty

Repacking Evangelist
aa
Jul 22, 2014
1,258
999
Hi, there.

Mudpie has already provided the best solution but here is some more information:

If your ambient_generic has 'Is NOT looped' enabled, the StopSound input is ignored. Non-looping sounds are usually short, and don't typically need to be stopped. You can use PlaySound to play the sound on command, and it will interrupt itself and play from the beginning.

If your ambient_generic has 'Is NOT looped' disabled, the StopSound input works. Looping sounds obviously need to be turned off sometimes. A benefit to disabling this spawnflag is that the sound will automatically be stopped when the round changes, so you don't have to include logic to mute it at the beginning of the next round. A downside is that you must stop the sound before you can start it again.

The volume and fadeout inputs will work across different rounds.

fadeout must have a minimum value of 1 second.

Sending the input volume with a value of 1 or above (up to 10) starts an MP3 from the beginning after you have used volume 0 previously to turn it off. This also works if the sound has never been played.
 

bamibal

L1: Registered
Aug 14, 2015
47
5
Yay, got it to work using FadeOut and 'is NOT looped' enabled for both! Thanks all.