FadeOut stop playing a sound when player is changing rooms

Started by Gal Shemesh, Thu 03/08/2023 12:59:28

Previous topic - Next topic

Gal Shemesh

Hi everyone,

Not sure if it's a bug, but better get a reply that it's not than not reporting at all:

When the 'player.ChangeRoom()' function is used along with the default 'FadeInAndOut' behavior, and a certain sound is set to be played just before changing the room, the sound doesn't play but only after entering the changed room.

For example, I made a click sound for buttons on a main menu screen, and set it to play right before the player.ChangeRoom() function. The click sound however plays either when the fade-out is finished or when the changed room is loaded (I can't tell). But if I set a FadeOut() function manually and afterwrads put the player.ChangeRoom() function then the sound plays correctly upon pressing the button.

Thanks
Gal Shemesh,
goldeng

RootBound

My guess would be that sounds are nonblocking and change room is blocking, so change room would execute first. You could put a Wait(length of sound) in after the sound and before the change room function and see if that works.
J. They/them. Here are my most recent games:

Gal Shemesh

Thanks for the reply, @RootBound! Yep, I tried the Wait() function. But unfortunately, it doesn't work very well as I want the sound to play when the FadeOut starts playing, and not to have to wait for the sound to end before it does...
Gal Shemesh,
goldeng

Khris

Sounds like the built-in room fade is hard-coded into the engine in a way that completely halts the main loop, whereas the script command is simply a blocking function like any other which doesn't pause the main loop.

Not sure it qualifies as a bug, but a lot of legacy stuff is somewhat inconsistent internally and should be "fixed" at some point, I guess. Definitely a worthy suggestion for AGS 4.

RootBound

@Gal Shemesh hmm. You could try putting in Wait(1) instead of waiting for the whole sound length, and see if that starts the sound playing before the room starts to fade out?

So it would be

Audioclip.play();
Wait(1);
player.Changeroom();
J. They/them. Here are my most recent games:

Gal Shemesh

@RootBound, it's working! 8-0 I thought that 'Wait(1)' will be too short and that the player.ChangeRoom() function will cut it in the middle that I didn't even tried it. Thanks!!  8-)
Gal Shemesh,
goldeng

RootBound

J. They/them. Here are my most recent games:

Crimson Wizard

Quote from: Khris on Fri 04/08/2023 11:04:14Sounds like the built-in room fade is hard-coded into the engine in a way that completely halts the main loop, whereas the script command is simply a blocking function like any other which doesn't pause the main loop.

Not sure it qualifies as a bug, but a lot of legacy stuff is somewhat inconsistent internally and should be "fixed" at some point, I guess.

This is likely not a legacy inconsistency, but, on contrary, a new issue caused by how audio commands "sync" with the new audio subsystem in 3.6.0.
I can swear I already fixed this before, but maybe I fixed it for some other command rather than FadeOut.

@Gal Shemesh, please tell which version of AGS are you using exactly?

Gal Shemesh

Quote from: Crimson Wizard on Fri 04/08/2023 19:01:56Gal Shemesh, please tell which version of AGS are you using exactly?
AGS Editor .NET (Build 3.6.0.50)
v3.6.0, July 2023
Gal Shemesh,
goldeng

AndreasBlack

#9
Quote from: Gal Shemesh on Fri 04/08/2023 10:35:38Thanks for the reply, @RootBound! Yep, I tried the Wait() function. But unfortunately, it doesn't work very well as I want the sound to play when the FadeOut starts playing, and not to have to wait for the sound to end before it does...

In the future, just do like i do. Go into Photoshop Take the biggest black Pencil tool you can get hit your leftmouse. Save the file as the same size as your room is. Either animate it in Photoshop itself fading out or do it in AGS with object transparency and Tween Module. Problem solved, none-blocking! 8-)

eri0o

I think @Crimson Wizard made a change in the engine to fix this, since AGS 3.6.1.6.

Gal Shemesh

Thanks guys. By now I've already implemented a black GUI and made a custom FadeIn and FadeOut functions with it by using transparancy - I don't think I'm going to use the built-in transitions anymore due to their limitations and as they don't give the freedom of control; in my custom fades I can do mostly anything I want, and even choose the amount of transparent value that I wish to make the fade kind of 'jump' to on each screen draw. For example, subtracting transparancy in jumps of '10' with a minor Wait of (3) or so for making a '10 frame like' FadeOut, instead of a smooth fade that drawn on each game cycle.
Gal Shemesh,
goldeng

eri0o

In the sense of screen transitions, I always had a feeling that if it was possible to screenshot the room without the mouse cursor, it would be easy to script your own transition - say you hold the screenshot in a GUI and then instant fade in in the next room, then you can change the transparency of the GUI holding the screenshot to "crossfade" to the next room. If it was possible to screenshot without GUIs too it would be perfect because then you can do things like slide left and slide the new screen from left - or perhaps this is doable with a combination of previous screenshot+viewport... To hack around this in my game I used the fake screen module with some fixes and used it to make my own transitions...

Crimson Wizard

Quote from: eri0o on Sat 16/09/2023 14:51:01In the sense of screen transitions, I always had a feeling that if it was possible to screenshot the room without the mouse cursor, ... If it was possible to screenshot without GUIs too it would be perfect

This was an old feature suggestion for idk how many years, to pass which screen layers to draw in screenshot function.

Since 3.6.1 there are no more game logic updates in the draw routine, afaik, which means it may be safe to call it anytime, passing some "draw on target" and "draw which layers" parameters.

Cassiebsg

QuoteI always had a feeling that if it was possible to screenshot the room without the mouse cursor

But wait, it IS possible to do this.
You just have to hide the mouse cursor and any GUI you don't want in the screenshot, take the screenshot and reactivate everything right after.That's how we take screenshots to use as thumbnails for save games.
There are those who believe that life here began out there...

SMF spam blocked by CleanTalk