Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Laura Hunt on Tue 10/09/2019 17:31:52

Title: Audio linked to animation frame cutting off other sound
Post by: Laura Hunt on Tue 10/09/2019 17:31:52
I have an animation with a sound linked to one of its frames and when this sound plays, the sound that was playing before it gets cut off.

Code (ags) Select
    streetatmo1 = aWhisper1.Play(eAudioPriorityNormal, eRepeat);
   
    cCharlie.LockView(27);
    cCharlie.Animate(2, 5, eOnce, eBlock);
    cCharlie.LockView(28);
    cCharlie.Animate(2, 5, eOnce, eBlock);
    cCharlie.LockView(29);
    cCharlie.Animate(2, 5, eOnce, eBlock);  // aWhisper1 gets cut off here, when the frame with audio plays



Useful things to know, maybe:

- streetatmo1 is a global Audiochannel which I've been using for ambient sounds. I've also tried defining an Audiochannel* instance on the fly instead. Same issue.
- aWhisper1 is defined as a "Sound" in the editor and I have set Maxchannels = 0 for sounds.
- View 29 is the one that has the frame with the audio clip linked to it.
- Apart from this code, there's a music track playing in the background. This track is defined as "Music" in the editor (maxchannels = 1) and doesn't get cut when the linked frame sound plays.
- Also tried upping the priority of aWhisper1 to "high". No dice.

Any idea what might be happening here?  :confused:
Title: Re: Audio linked to animation frame cutting off other sound
Post by: Laura Hunt on Wed 11/09/2019 08:24:51
Figured it out. Of course, the problem was in the part of the code that I didn't think of including:

Code (ags) Select
    streetatmo1 = aWhisper1.Play(eAudioPriorityNormal, eRepeat);
   
    cCharlie.LockView(27);
    cCharlie.Animate(2, 5, eOnce, eBlock);
    cCharlie.LockView(28);
    cCharlie.Animate(2, 5, eOnce, eBlock);
    cCharlie.LockView(29);
    cCharlie.Animate(2, 5, eOnce, eBlock);
    cCharlie.LockView(28);
    cCharlie.Animate(2, 5, eOnce, eNoBlock);

    dCharlieFinal.Start();
    streetatmo1.Stop();


I thought the Stop statement would be executed AFTER the script returned from the dialog. Turns out that dialogs are run at the end of the function where they are inserted, as per the manual: "NOTE: The conversation will not start immediately; instead, it will be run when the current script function finishes executing."  (roll)

Anyway, non-issue solved, but maybe my stupidity will be useful to somebody in the future.
Title: Re: Audio linked to animation frame cutting off other sound
Post by: Snarky on Wed 11/09/2019 09:01:00
Thanks for posting the explanation!
It's always annoying when people just post "nvm, figured it out".