A_IsPlayingSound and S_GetMSLength

Moderator: GZDoom Developers

Post Reply
User avatar
Rachael
Posts: 13571
Joined: Tue Jan 13, 2004 1:31 pm
Preferred Pronouns: She/Her
Contact:

A_IsPlayingSound and S_GetMSLength

Post by Rachael »

This originally came from a QZDoom submission. Pull request

I don't know if anything needs to be done to "secure" this on the ZScript side, to be honest I am not very experienced with ZScript scopes and what needs to go where. I would prefer this to be deterministic-compliant.
_mental_
 
 
Posts: 3812
Joined: Sun Aug 07, 2011 4:32 am

Re: A_IsPlayingSound and S_GetMSLength

Post by _mental_ »

A bit unrelated to changes themselves. Can this be squashed to a single commit?
Diffing, blaming, bisecting fix-for-fix-for-... style history is a painful process.

IMHO it's OK for long-term feature branches but not for simple stuff.
Can't say for everyone of course, to me this is just a complication out of nowhere.
User avatar
Rachael
Posts: 13571
Joined: Tue Jan 13, 2004 1:31 pm
Preferred Pronouns: She/Her
Contact:

Re: A_IsPlayingSound and S_GetMSLength

Post by Rachael »

Done.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49073
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: A_IsPlayingSound and S_GetMSLength

Post by Graf Zahl »

What's the point of having A_IsPlayingSound when it actually cannot be used due to being UI scope?
Personally I'd rather leave this function out for now, I have no idea how this can be used with C/S networking like in Zandronum.
User avatar
Rachael
Posts: 13571
Joined: Tue Jan 13, 2004 1:31 pm
Preferred Pronouns: She/Her
Contact:

Re: A_IsPlayingSound and S_GetMSLength

Post by Rachael »

It wouldn't even work in a C/S setting unless it was strictly client-side and sounds were done purely there.
User avatar
Marisa the Magician
Posts: 3886
Joined: Fri Feb 08, 2008 9:15 am
Preferred Pronouns: She/Her
Operating System Version (Optional): (btw I use) Arch
Graphics Processor: nVidia with Vulkan support
Location: Vigo, Galicia
Contact:

Re: A_IsPlayingSound and S_GetMSLength

Post by Marisa the Magician »

Hello, I'm the one who submitted this. Initially, I wanted to add A_IsPlayingSound because I had no idea S_GetMSLength was available. So that half of this submission can go away.
User avatar
Rachael
Posts: 13571
Joined: Tue Jan 13, 2004 1:31 pm
Preferred Pronouns: She/Her
Contact:

Re: A_IsPlayingSound and S_GetMSLength

Post by Rachael »

Removed A_IsPlayingSound and left S_GetMSLength.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49073
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: A_IsPlayingSound and S_GetMSLength

Post by Graf Zahl »

Rachael wrote:It wouldn't even work in a C/S setting unless it was strictly client-side and sounds were done purely there.
That's precisely what I thought. It is definitely better to have an opaque interface to the sound system that handles this stuff internally. That's why I changed all sound calls in the existing action functions to A_PlaySound when I scriptified it and any further additions should probably be done as new flags to that function.
User avatar
Major Cooke
Posts: 8176
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: A_IsPlayingSound and S_GetMSLength

Post by Major Cooke »

So how does S_GetLength work?
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49073
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: A_IsPlayingSound and S_GetMSLength

Post by Graf Zahl »

It returns the sounds length in milliseconds. Where you go from there is up to you.
User avatar
Marisa the Magician
Posts: 3886
Joined: Fri Feb 08, 2008 9:15 am
Preferred Pronouns: She/Her
Operating System Version (Optional): (btw I use) Arch
Graphics Processor: nVidia with Vulkan support
Location: Vigo, Galicia
Contact:

Re: A_IsPlayingSound and S_GetMSLength

Post by Marisa the Magician »

The only problem with the function is that it doesn't account for pitch shift, so you'd have to calculate the "longest" possible length when using random shift yourself.

Of course that problem doesn't exist if the sound you want to use doesn't have pitch shift.

Oh and also, for random sounds it returns the length of longest sound among them already.

The main use case I wanted this for was to have a moving actor destroy itself once it has finished playing sound.
Post Reply

Return to “Closed Feature Suggestions [GZDoom]”