[Added] Set start time to play sound in A_PlaySound

Moderator: GZDoom Developers

Re: Set start time to play sound in A_PlaySound

Postby Chris » Mon Oct 14, 2019 5:28 pm

Rachael wrote:Because there's no guarantee that the alternate backend would do the same thing as OpenAL would. It's like when we got Vulkan - things are just .. different ... and things are also handled differently, even if ultimately the end-user never sees it.

The same thing might happen if OpenAL went through, for instance, a major refactor where the code was rewritten from scratch. Just as an example.

Basically the point I am trying to drive home is - when coding, it is important to check inputs and make sure they match what is actually supported by the library, in order to avoid mishaps in the future. Not doing input validation leads to unpredictable results, and more often than not, issues.

Oh, sure, the behavior should be defined/documented and predictable. That's actually what the question was about, whether the offset should auto-wrap or -clamp depending if the sound is looping or not, or always auto-clamp, or ignore the offset if it's out of range. OpenAL itself ignores out-of-range offsets, so you get that behavior "for free" if that's the preferred option. Any of the other methods can be implemented, though. Whichever you want, however you want.
User avatar
Chris
 
Joined: 17 Jul 2003

Re: Set start time to play sound in A_PlaySound

Postby Nash » Thu Oct 17, 2019 11:31 pm

Chris wrote:More stylistically, the way you apply the default parameter value for startTime in the sound classes don't look right. It should be applied to the base declaration, what the calling code will "see". It's pretty useless on the implementation definition since callers won't be aware of it when calling the function. I think some compilers will actually warn about this.


Third time's a charm ... which one is the base declaration?
User avatar
Nash
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Github ID: nashmuhandes

Re: Set start time to play sound in A_PlaySound

Postby Major Cooke » Fri Oct 18, 2019 12:39 pm

Nash: I'm making a bunch of comments inside on where I believe Chris is talking about, with all the defaults. Notice how even my pitch parameter doesn't have defaults. That's because I encountered issues when trying to set defaults for pitch myself and, last I recall, it failed to compile even.

Simply remove those = 0.f defaults, but only where I made comments. The rest are fine.
User avatar
Major Cooke
QZDoom Maintenance Team
 
Joined: 28 Jan 2007

Re: Set start time to play sound in A_PlaySound

Postby Chris » Sat Oct 19, 2019 10:09 am

Nash wrote:Third time's a charm ... which one is the base declaration?

Sorry, I forgot to answer that. The base declaration for the sound renderer methods are in the SoundRenderer class in src/sound/backend/i_sound.h.
User avatar
Chris
 
Joined: 17 Jul 2003

Re: Set start time to play sound in A_PlaySound

Postby Nash » Mon Oct 21, 2019 10:13 am

User avatar
Nash
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Github ID: nashmuhandes

Re: Set start time to play sound in A_PlaySound

Postby Chris » Mon Oct 21, 2019 1:11 pm


This doesn't look right:
Code: Select allExpand view
float st = (chanflags&SNDF_LOOP) ? fmod(startTime, (float)GetMSLength(sfx) / 1000.f) : clamp<float>(startTime, 0.f, (float)GetMSLength(sfx));

For non-looped sounds, it's clamping the start time to the length in milliseconds, rather than seconds. More generally, I think it would be better to always clamp the start time instead of conditionally wrapping it when looping, because a sound may have non-default loop points that one would expect such wrapping to acknowledge. I also think this can be just as easily handled outside of the backend, prior to any StartSound[3D] calls so it doesn't depend on the backend to implement this behavior.
User avatar
Chris
 
Joined: 17 Jul 2003

Re: Set start time to play sound in A_PlaySound

Postby Nash » Tue Jun 16, 2020 4:30 am

Has long been added
User avatar
Nash
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Github ID: nashmuhandes

Previous

Return to Closed Feature Suggestions

Who is online

Users browsing this forum: No registered users and 1 guest