2 repeating songs problem

Discussion in 'Mapping Questions & Discussion' started by bamibal, Sep 23, 2015.

  1. bamibal

    bamibal L1: Registered

    Messages:
    47
    Positive Ratings:
    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
     
  2. Exactol

    aa Exactol Certified Hammer Hacker

    Messages:
    399
    Positive Ratings:
    462
    try adding in fadeout with a parameter of 0 to both
     
    • Thanks Thanks x 1
  3. Muddy

    Server Staff Muddy Muddy

    Messages:
    2,387
    Positive Ratings:
    4,220
    ambient_generic can be a bit funny about playing and stopping sounds. Your best bet may be to change the volume of each sound to 0 when you don't want them to be playing.
     
    • Thanks Thanks x 1
  4. Exactol

    aa Exactol Certified Hammer Hacker

    Messages:
    399
    Positive Ratings:
    462
    fadeout stops the sound too
     
  5. bamibal

    bamibal L1: Registered

    Messages:
    47
    Positive Ratings:
    5
    Cool, I'm going to try:)
     
  6. worMatty

    aa worMatty Repacking Evangelist

    Messages:
    1,072
    Positive Ratings:
    834
    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.
     
  7. bamibal

    bamibal L1: Registered

    Messages:
    47
    Positive Ratings:
    5
    Yay, got it to work using FadeOut and 'is NOT looped' enabled for both! Thanks all.