Sound played by weapon interrupted at the start of a level

Is there something that doesn't work right in the latest GZDoom? Post about it here.

Moderator: Developers

Forum rules
Please construct and post a simple demo whenever possible for all bug reports. Please provide links to everything.

If you can include a wad demonstrating the problem, please do so. Bug reports that include fully-constructed demos have a much better chance of being investigated in a timely manner than those that don't.

Sound played by weapon interrupted at the start of a level

Postby Player701 » Wed Dec 05, 2018 6:44 am

So, it appears that playing sounds and doing other non-trivial things on the first tick of a weapon's Select state doesn't work after a level transition, and this is not a bug (though it keeps puzzling me why). So I tried to circumvent it by doing this on the second tick instead. It all seems to work fine, save for one thing: playing sounds. They work almost fine - an average player may not even notice this, but it also depends on the sound itself. Consider this example code:

Code: Select allExpand view
class TestPistol : Pistol
{
    States
    {
        Select:
            PISG A 1 A_Raise;
            PISG A 1 A_PlaySound("misc/teleport", CHAN_WEAPON);
            PISG A 1 A_Raise;
            Goto Select+2;       
    }
}

The testing procedure is given below. It is advised to turn music off so that the sound can be heard better. Also, it looks like this bug only happens when "Screen wipe style" is not "None" (see below for more on this).

  1. Warp to any map.
  2. Type "give TestPistol" in the console. The pistol plays a teleporting sound when it is selected.
  3. Switch to another level by using the "changemap" console command, so that the weapons you are carrying are preserved.
  4. When the next level starts, the following may happen: First, you hear a very short part of the teleporting sound, for a fraction of a second. Then, the sound gets interrupted for a noticeable amount of time (a second at the very least) - this is probably when the screen wipe effect happens. After that, you hear the rest of the sound.
Unfortunately, this behavior cannot be reproduced reliably. Several iterations of the testing procedure may be required for the interruption to appear. The length of the interrupted fragment also seems to vary, but it's always very short - that's why I've picked the teleporting sound for testing, as it is quite loud in the beginning, which probably makes noticing the bug easier.

I also can't reproduce this in any number of iterations if I disable the screen wipe effect. It appears that the sound erroneously starts playing before the screen wipe happens, gets interrupted by it, and then continues from where it left off. Although this is only a theory, as I haven't looked at the code yet.
Attachments
zscript.txt
(239 Bytes) Downloaded 1 time
User avatar
Player701
You are now breathing manually.
 
Joined: 13 May 2009
Location: Russian Federation
Discord: Player701#8214

Re: Sound played by weapon interrupted at the start of a lev

Postby Graf Zahl » Wed Dec 05, 2018 7:47 am

The wipe code is very badly designed, using a busy loop in which other subsystems do not get their regular updates. This is probably just a side effect of that problem.
This particular piece of code is how id originally implemented the wipe for DOS.
User avatar
Graf Zahl
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: Sound played by weapon interrupted at the start of a lev

Postby Apeirogon » Wed Dec 05, 2018 8:31 am

Player701 wrote:non-trivial things on the first tick of a weapon's Select state doesn't work after a level transition

You can make weapon switching instantly, this trick gzdoom, by using SetPlayerProperty(0,0,2) to turn it on and SetPlayerProperty(0,1,2) to turn it off, and use something like
Code: Select allExpand view
Select:
sprite a 0 SetPlayerProperty(0,0,2);
goto state_name;

state_name:
sprite a 0 {do stuff};
goto ready;

deselect:
sprite a 0 SetPlayerProperty(0,1,2);
deselect_loop:
sprite a 1 A_Lower();
Loop;
Apeirogon
I have a strange sense of humour
 
Joined: 12 Jun 2017

Re: Sound played by weapon interrupted at the start of a lev

Postby Player701 » Wed Dec 05, 2018 8:42 am

Thanks, but even with your solution, playing sounds from the weapon on the first tick after a level change still doesn't work. Perhaps I worded it incorrectly by saying the problem was with the Select state. It is not actually important what state is used, at least one tick has to pass since the start of the level.
User avatar
Player701
You are now breathing manually.
 
Joined: 13 May 2009
Location: Russian Federation
Discord: Player701#8214

Re: Sound played by weapon interrupted at the start of a lev

Postby Apeirogon » Wed Dec 05, 2018 8:46 am

I mention this in connection with bug you mention in you post, which not a bug, not this one.
Apeirogon
I have a strange sense of humour
 
Joined: 12 Jun 2017


Return to Bugs

Who is online

Users browsing this forum: No registered users and 2 guests