$limit in SNDINFO does not limit the amount of instances

Forum rules
Please don't bump threads here if you have a problem - it will often be forgotten about if you do. Instead, make a new thread here.

Post a reply

Smilies
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :geek: :ugeek: :!: :?: :idea: :arrow: :| :mrgreen: :3: :wub: >:( :blergh:
View more smilies

BBCode is OFF
Smilies are ON

Topic review
   

Expand view Topic review: $limit in SNDINFO does not limit the amount of instances

Re: $limit in SNDINFO does not limit the amount of instances

by Graf Zahl » Tue Apr 12, 2022 6:37 am

$LIMIT has no effect if you restart the same sound on the same channel - the old one gets terminated before the new one starts, so it never affects the limit. In this case you have to manually check if the sound is still playing.

$limit in SNDINFO does not limit the amount of instances

by Kzer-Za » Tue Nov 30, 2021 12:04 am

At least, if I understand correctly what it is supposed to do. From the description in wiki I get the impression that if I limit the amount of instances to 1, then while this sound is playing, another instance would not be played within the limitdistance.

However, in the example I present below, multiple instances clearly overlap. I'm gonna both paste the code and attach a zip file. I used "caco/sight" as the test sound because it's relatively long and illustrates the issue well.

SNDINFO:

Code: Select all

$alias Test_Sound caco/sight

$limit Test_Sound 1 256
// $singular Test_Sound
ZSCIPT

Code: Select all

version "3.3"

class TestActor : Actor
{
	Default
	{
		+NOINTERACTION;
	}
	States
	{
	Spawn:
		TNT1 A 3 A_StartSound("Test_Sound");
		Loop;
	Death:
		Stop;
	}
}

class TestActor2 : Actor
{
	Default
	{
		+NOINTERACTION;
	}
	States
	{
	Spawn:
		TNT1 A 3 A_StartSound("Test_Sound", flags: CHANF_NOSTOP);
		Loop;
	Death:
		Stop;
	}
}
Steps to reproduce (with GZDoom launched and Test1.zip in your mod folder):

1. Start a new game.

2. Open console and execute "summon TestActor". Hear the sounds.

3. Start a new game.

4. Open console and execute "summon TestActor2". Hear the sounds.

Expected results: both actors to sound the same: 1 sound plays until it ends, only then the next sound starts playing.

Actual results: TestActor1 starts playing the next sound each 3rd frame, despite "$limit Test_Sound 1 256" in the SNDINFO.

BTW, $singular in this example does not limit the sound instance to 1 either, which can be tested by commenting the line 3 and uncommenting the line 4 in the SNDINFO.

If I misunderstand what $limit is supposed to do, is it possible add a feature that implements such behavior? Using A_StartSound with CHANF_NOSTOP flag is not always possible. For example, see this topic: viewtopic.php?f=122&t=73990. Also, I'm sure there are other cases when it is simpler to achieve this limitation through SNDINFO rather than by using A_StartSound with CHANF_NOSTOP flag.
Attachments
Test1.zip
(514 Bytes) Downloaded 46 times

Top