Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Is there a way to stop a looping sound?
User01 Offline
Member

Posts: 97
Threads: 30
Joined: Feb 2013
Reputation: 0
#1
Is there a way to stop a looping sound?

I'm playing a snt file with several sounds which is looping but I just noticed that StopSound isn't working. The sound keeps playing. I'm pretty sure it's because of the looping/saving. Is there a proper way to make looping sound stop?
(This post was last modified: 03-26-2018, 06:18 PM by User01.)
03-26-2018, 06:17 PM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#2
RE: Is there a way to stop a looping sound?

How are you playing the looping sound? Via the editor or via script? If script, you must simply give the internal name of the sound you started in the stop script for it to find it. Remember to actually include a name in the start script, otherwise you can't stop it.

If you started it via the editor "Sound" object, then I'm not certain if it has a default name you can stop via script or not, but if you only want it to play once and never loop, you can copy the .snt file and edit it to be loop="false", then use that in your story instead.

03-27-2018, 11:25 AM
Find
User01 Offline
Member

Posts: 97
Threads: 30
Joined: Feb 2013
Reputation: 0
#3
RE: Is there a way to stop a looping sound?

(03-27-2018, 11:25 AM)Mudbill Wrote: How are you playing the looping sound? Via the editor or via script? If script, you must simply give the internal name of the sound you started in the stop script for it to find it. Remember to actually include a name in the start script, otherwise you can't stop it.

If you started it via the editor "Sound" object, then I'm not certain if it has a default name you can stop via script or not, but if you only want it to play once and never loop, you can copy the .snt file and edit it to be loop="false", then use that in your story instead.
Via script PlaySoundAtEntity. I gave the sound an internal name and the sound is playing at a script area. I copied the internal name in the StopSound script. All of the the script is working, except that the sound still keeps playing after StopSound is called.

This made me thought that you cannot stop looped sounds but I'm not sure. And yes, it has to be looped.
(This post was last modified: 03-27-2018, 03:05 PM by User01.)
03-27-2018, 03:05 PM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#4
RE: Is there a way to stop a looping sound?

Can you show the script?

03-27-2018, 04:10 PM
Find
User01 Offline
Member

Posts: 97
Threads: 30
Joined: Feb 2013
Reputation: 0
#5
RE: Is there a way to stop a looping sound?

I'll give you an example.

void OnStart()
{
PlaySoundAtEntity("sound1","sound1.snt","area_sound", 0, true);
AddUseItemCallback("", "item", "area_event", "event", true);
}

void event(string &in asItem, string &in asEntity)
{
StopSound("sound1", 0.1f);
PlaySoundAtEntity("", "sound3.snt", "Player", 0, false);
PlaySoundAtEntity("sound2", "sound2.snt", "area_sound", 0, false);
PlayPropAnimation("object", "animation", 0, false, "event2");
RemoveItem("item");
}

void event2(string asProp)
{
StopSound("sound2", 0.1f);
}
Both sound1 and sound2 keep playing in my script.
03-27-2018, 04:22 PM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#6
RE: Is there a way to stop a looping sound?

Hmm, yeah that does look a little odd why they keep playing. Could you post the contents of the snt files as well?

03-27-2018, 10:45 PM
Find
User01 Offline
Member

Posts: 97
Threads: 30
Joined: Feb 2013
Reputation: 0
#7
RE: Is there a way to stop a looping sound?

It looks like this.

<SOUNDENTITY>
  <SOUNDS>
      <Main>
          <Sound File="sound1" />
        <Sound File="sound2" />
        <Sound File="sound3" />
        <Sound File="sound4" />
        <Sound File="sound5" />
        <Sound File="sound6" />
      </Main>
  </SOUNDS>
  <PROPERTIES Volume="0.8" MinDistance="10" MaxDistance="20" Random="1" Interval="0.05" FadeEnd="False" FadeStart="False" Stream="False" Loop="True" Use3D="True" Blockable="False" BlockVolumeMul="0.7" Priority="0" />
</SOUNDENTITY>
03-28-2018, 11:26 AM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#8
RE: Is there a way to stop a looping sound?

Not sure if it'll help, but I suggest keeping names separate, that way you don't accidentally refer to something else. So by naming the sounds something different from the internal names, it might clear up some potential issues.

Another thing you can try is naming the internal sound the same as the item you're using. Then you can use RemoveItem(asItem) and StopSound(asItem) to make sure it affects the exact reference it gets.

(This post was last modified: 03-28-2018, 04:52 PM by Mudbill.)
03-28-2018, 04:52 PM
Find
User01 Offline
Member

Posts: 97
Threads: 30
Joined: Feb 2013
Reputation: 0
#9
RE: Is there a way to stop a looping sound?

(03-28-2018, 04:52 PM)Mudbill Wrote: Not sure if it'll help, but I suggest keeping names separate, that way you don't accidentally refer to something else. So by naming the sounds something different from the internal names, it might clear up some potential issues.

Another thing you can try is naming the internal sound the same as the item you're using. Then you can use RemoveItem(asItem) and StopSound(asItem) to make sure it affects the exact reference it gets.
Actually, the internal names from the sounds are different to their file names.
RemoveItem doesn't affect sounds via script I think.
03-28-2018, 07:14 PM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#10
RE: Is there a way to stop a looping sound?

No, but it allows you to make sure the correct reference is captured by checking if your item has been removed.

From what I can see, your sounds are named sound1 with same file name + .ogg / .snt etc.
Humor me and try what I suggested. It may not do anything, but I don't really have any other suggestions right now.

If it doesn't help, perhaps package it all up and send it over and I can take a look.

(This post was last modified: 03-29-2018, 01:17 AM by Mudbill.)
03-29-2018, 01:15 AM
Find




Users browsing this thread: 3 Guest(s)