Unexpected audio file substitution

Started by elentgirl, Tue 18/05/2021 08:23:02

Previous topic - Next topic

elentgirl

I have another issue with audio files, different from the one I reported in March.  I do not know whether or not they are related.

My current game program has developed an unusual and irritating fault involving the audio system.  My game includes a sound effect which is called from a frame in a view based animation.  This has worked as it should until a recent test play.  For some reason which I cannot understand, the sound effect audio file has now been replaced with another audio file (a speech from later in the game).
The name of the file has not changed in the calling instruction. but I did notice that the substitued file had the next number in sequence (the numbers that AGS alloctes to audio files). I tried deleting and re-importing the sound effect (all my audio files are ogg format) so that the effect, which is called by name in the program, now has a different allocated number.  When I run the program, however, it still plays the alternative file.

I tried removing the sound effect from the view altogether, and it still played the alternative speech file.  In desperation, I deleted that speech file to see if I could clear whatever was causing this to play.  I succeeded in preventing the program playing that speech file, but instead it substitued another speech file, and not even the next numbered one this time!

Can anyone please explain what is going on, and more importantly, advise me on how to get back to making the program play the sound effect file it should?
elentgirl

Crimson Wizard

When you say "speech file", do you mean it plays a file from Speech folder?

Also, what happened to your old problem, was it solved or no?

Khris

#2
Quote from: elentgirl on Tue 18/05/2021 08:23:02I tried removing the sound effect from the view altogether, and it still played the alternative speech file.
This sounds like something else is causing the file to play. Have you thouroughly checked all other frames of the view for linked audio? And other views that might play?

elentgirl

Quote from: Crimson Wizard on Tue 18/05/2021 09:06:48
When you say "speech file", do you mean it plays a file from Speech folder?

Also, what happened to your old problem, was it solved or no?

The file was not in the AGS speech folder as the speeches in my game are standard sound clips, so AGS would not record any difference between a sound effect and speech file.  However, the two files play in completley different rooms with no associated code beyond the usual global functions, and until recently it all ran as I intended.  I accept that I may have done something somewhere in the program to cuase it, but I can think of nothing that links to these two audio files.

Regarding my earlier problem, I hesitate to say that it is solved as it was always only an intermittant event, but I took the advice to lengthen all my short audio clips to longer than one second and the issue seems to have stopped.

What I really find hard to understand in this new case is why, when I deleted the file the program kept playing, it substitued another file to play instead of giving me a "file not found" or similar error message.
elentgirl

Crimson Wizard

Quote from: elentgirl on Tue 18/05/2021 09:35:37
What I really find hard to understand in this new case is why, when I deleted the file the program kept playing, it substitued another file to play instead of giving me a "file not found" or similar error message.

View frames reference sound by index, not by name. When you delete some file the indexes shift, and old slot is taken by another sound that was after the deleted one.

Crimson Wizard

Quote from: elentgirl on Tue 18/05/2021 08:23:02
I tried removing the sound effect from the view altogether, and it still played the alternative speech file.

Like Khris, I find this most strange, because if you removed sound effect setting from the view frames then these frames should not be calling any sound at all.

I wonder, do you set frame sound using a script command anywhere? that would explain why the frames keep playing sounds.

elentgirl

Quote from: Crimson Wizard on Tue 18/05/2021 09:37:16
View frames reference sound by index, not by name. When you delete some file the indexes shift, and old slot is taken by another sound that was after the deleted one.

I'm beginning to think that this is a situation where I need to find another way to skin the cat!  Maybe I will not use the frame reference to call the sound effect, but add a little silence to the start of the effect so that I can start it from the program before launching the animation.  The only thing that worries me about doing that is that when I removed the sound call from the frame in the view file, it still insisted on playing the wrong sound.  I will have to experimant further.

Thank you all for you help.
elentgirl

Crimson Wizard

Quote from: elentgirl on Tue 18/05/2021 13:23:54The only thing that worries me about doing that is that when I removed the sound call from the frame in the view file, it still insisted on playing the wrong sound.

Can you please elaborate on this? Are you saying that the sound is playing even if no sound is set in the view frame? If so, then what plays the sound?
I think this might be the root of the problem, and finding what's making sound to play will bring you closer to the solution.

elentgirl

Quote from: Crimson Wizard on Tue 18/05/2021 13:55:35
Can you please elaborate on this? Are you saying that the sound is playing even if no sound is set in the view frame? If so, then what plays the sound?
I think this might be the root of the problem, and finding what's making sound to play will bring you closer to the solution.

I think I may have found an explanation, though I do not fully understand why.  I currently have the game out for testing, and when doing this, I check on reported bugs by loading a previously saved game close to the point I want to investigate (getting the program to run from a particular place usually means switching off some things, which can easily get overlooked when compiling the program!) .  It was while doing this that I dscovered the audio file substituion.  This afternoon I set up the program to start at the relative point and ran it.  The sound effect worked as it should.

I don't understand why an earlier save affects something later in the program, but it seems it does.

Thank you all for your time and suggestions.
elentgirl

Crimson Wizard

#9
Quote from: elentgirl on Tue 18/05/2021 14:40:09
I don't understand why an earlier save affects something later in the program, but it seems it does.

The save stores which sounds were assigned to the view frame (it has to because it's possible to change sounds in script). So in the old save you have old sound index.
If the list of sounds changed between game versions, then restoring old save will make wrong sound play.

elentgirl

Quote from: Crimson Wizard on Tue 18/05/2021 14:42:11
The save stores which sounds were assigned to the view frame (it has to because it's possible to change sounds in script). So in the old save you have old sound index.
If the list of sounds changed between game versions, then restoring old save will make wrong sound play.

Thank you for that information - it is useful to learn how AGS functions.  It just makes it a little more difficult for testing the game!

Thank you for your help.
elentgirl

Crimson Wizard

If you really care about this you may write a script that adjusts frame sounds after restoring a save - in case something has changed in the game since the save was made.

To do so use "on_event" script function: https://github.com/adventuregamestudio/ags-manual/wiki/Globalfunctions_Event#on_event

Code: ags

function on_event(EventType event, int data)
{
    if (event == eEventRestoreGame)
    {
         // do something here
    }
}

elentgirl

Quote from: Crimson Wizard on Wed 19/05/2021 01:20:49
If you really care about this you may write a script that adjusts frame sounds after restoring a save - in case something has changed in the game since the save was made.

Thank you - this looks very useful as I have a report from a tester of something else not working properly after a save.  I shall definitely try this.

Many thanks,
elentgirl

SMF spam blocked by CleanTalk