Bug in New Audio System

Started by skuttleman, Fri 26/08/2011 03:59:51

Previous topic - Next topic

skuttleman

Has anyone else experienced the following problem with the audio system:

The volume of one or more audio channels or one or more audio types has to be set to 0, but System.Volume is NOT set to 0. Then if you get to a skippable cutscene and SKIP it, the volume of any channel or audio type that is set to 0, will jump to the value of System.Volume.

Has anyone else run into this?

arj0n


skuttleman

Nope. Not the same. The audio is completely unaffected unless, the volume of the channel in question is set to 0. If the volume of the channel is set to 1 or any other value from 1 to 100, it stays right where it should.

Haggis

Not sure if a solution to this has been found yet but I too am experiencing this issue.

I have a music volume slider in my 'settings' GUI - if I adjust this to 0 then the music is essentially muted.
When I enter a cutscene the music volume remains muted throughout, however when the cutscene ends the music volume is suddenly set back to (I assume) the System volume. The Music volume slider will still be set to 0 and if I adjust the slider afterwards the music volume will resolve back to the slider setting. This only affects music audio types and only when the volume is set to 0 (muted).

At present I get round the issue by running the following immediately after an endCutscene event (sMusic being the music volume slider value) - which in effect sets the volume back to the slider value:
Code: AGS
Game.SetAudioTypeVolume(eAudioTypeMusic, sMusic.Value*10, eVolExistingAndFuture);


I did have this in the global 'repeat all the time' but it meant that track cross fades stopped working as the fade effect was overruled.

Billbis

#4
I hope it's ok if I revive this old topic.
I experimented the same issue : If music / effects / ambient Volume is set to 0, at the end of a cutscene (whether or not you skip it), volume will be reset to some default original value.
I am not a C/C++ coder, but I had a look at the source code. In global_game.cpp line 484 and next ones :
Code: C++
int EndCutscene () {
    if (play.in_cutscene == 0)
        quit("!EndCutscene: not in a cutscene");

    int retval = play.fast_forward;
    play.in_cutscene = 0;
    // Stop it fast-forwarding
    stop_fast_forwarding();

    // make sure that the screen redraws
    invalidate_screen();

    // Return whether the player skipped it
    return retval;
}

stop_fast_forwarding is call at the end of cutscenes. It is define in game.cpp line 2612 and next ones :
Code: C++
void stop_fast_forwarding() {
    // when the skipping of a cutscene comes to an end, update things
    play.fast_forward = 0;
    setpal();
    if (play.end_cutscene_music >= 0)
        newmusic(play.end_cutscene_music);

    // Restore actual volume of sounds
    for (int aa = 0; aa < MAX_SOUND_CHANNELS; aa++)
    {
        if ((channels[aa] != NULL) && (!channels[aa]->done) &&
            (channels[aa]->volAsPercentage == 0) &&
            (channels[aa]->originalVolAsPercentage > 0))
        {
            channels[aa]->volAsPercentage = channels[aa]->originalVolAsPercentage;
            channels[aa]->set_volume((channels[aa]->volAsPercentage * 255) / 100);
        }
    }

    update_music_volume();
}

I have the (possibly wrong) intuition that :
Code: C++
(channels[aa]->originalVolAsPercentage > 0))

should be :
Code: C++
(channels[aa]->originalVolAsPercentage >= 0))


Can someone more expert have a look at this?
Thank you.

EDIT: I forget to say that this bug is present in current stable release: AGS 3.2.1. I should have test the latest beta maybe it is already fixed? :sealed:

Crimson Wizard

#5
I confirm, still present in 3.3.0 beta.
Thanks for bumping this, Billbis, I wasn't aware of this.


EDIT:
What I experience, and what I see from the code too, is that if any clip's volume will be by any means exactly 0 at the time of  EndCutscene() call, then its volume will be reset to what it was when the clip started playing.
If it started playing with volume 0, it will stay so. If it started with volume 50, it will return to 50.

To clarify:
Code: ags

Game.SetAudioTypeVolume(eAudioTypeMusic, 0, eVolExistingAndFuture);
AudioChannel *c = aMusic1.Play();
Display("%d", c.Volume); // will display '0'
StartCutscene(eSkipESCOnly);
Display("%d", c.Volume); // will display '0'
EndCutscene();
Display("%d", c.Volume); // will display '0'

All is correct.

But
Code: ags

AudioChannel *c = aMusic1.Play();
Display("%d", c.Volume); // will display '100'
Game.SetAudioTypeVolume(eAudioTypeMusic, 0, eVolExistingAndFuture);
Display("%d", c.Volume); // will display '0'
StartCutscene(eSkipESCOnly);
Display("%d", c.Volume); // will display '0'
EndCutscene();
Display("%d", c.Volume); // will display '100' !!

Error!



Also
Code: ags

AudioChannel *c = aMusic1.Play();
Display("%d", c.Volume); // will display '100'
StartCutscene(eSkipESCOnly);
c.Volume = 0;
Display("%d", c.Volume); // will display '0'
c.Volume = 50;
Display("%d", c.Volume); // will display '50'
EndCutscene();
Display("%d", c.Volume); // will display '50'

All is correct.

But
Code: ags

AudioChannel *c = aMusic1.Play();
Display("%d", c.Volume); // will display '100'
StartCutscene(eSkipESCOnly);
c.Volume = 50;
Display("%d", c.Volume); // will display '50'
c.Volume = 0;
Display("%d", c.Volume); // will display '0'
EndCutscene();
Display("%d", c.Volume); // will display '100' !!

Error!

Crimson Wizard

Ok, I think I fixed this one.


But, - while we are at it, - the cutscenes might produce more audio related issues.

For example, if you start a clip inside a cutscene, and player is skipping cutscene, then the clip starts silent, but saves the "correct" volume to be restored after cutscene.
Thing is that if you use AudioChannel.Volume property, the return value will be different, depending on whether cutscene is being skipped or not.
Now, imagine you want to set volume to the multiple of default:

Code: ags

AudioChannel *c = aMusic1.Play();
c.Volume = c.Volume / 2;


If cutscene is playing normally, you get a music playing at half volume. But if cutscene is being skipped, you get c.Volume = 0 / 2 = 0, and the music is not played even when cutscene is over...

Question is, should this be considered a bug, or a cutscene specific behavior, that game developer must take into consideration?

Billbis

Quote from: Crimson WizardOk, I think I fixed this one.
Many thanks ! ;-D
Quote from: Crimson WizardQuestion is, should this be considered a bug, or a cutscene specific behavior, that game developer must take into consideration?
I have no idea... ???

Crimson Wizard

Ok, I guess since I am fixing how "saved volume" works during cutscene, I think I can return saved volume on getting Volume property instead. This should solve this issue for good.

selmiak

will this be fixed in ags3.3? I ran into the same problem and would appreciate this fix :)

Crimson Wizard

Quote from: selmiak on Sat 28/09/2013 18:13:43
will this be fixed in ags3.3? I ran into the same problem and would appreciate this fix :)
Yes (already fixed in repository).

selmiak

nice :D
Now I'll wait for a stable release.

SMF spam blocked by CleanTalk