$limit in SNDINFO does not limit the amount of instances

Bugs that have been investigated and resolved somehow.

Moderator: GZDoom Developers

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 Reply
Kzer-Za
Posts: 521
Joined: Sat Aug 19, 2017 11:52 pm
Graphics Processor: nVidia (Modern GZDoom)

$limit in SNDINFO does not limit the amount of instances

Post by Kzer-Za »

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
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49234
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

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

Post by Graf Zahl »

$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.
Post Reply

Return to “Closed Bugs [GZDoom]”