Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: xBRANEx on Sat 01/10/2016 14:43:05

Title: Audio channel problem adjusting volume across rooms
Post by: xBRANEx on Sat 01/10/2016 14:43:05
Hi everyone. I'm losing my mind over this. I've done this before and I have no idea what's the problem.

I made a global variable muzika of an audio channel. I start the music in the first room:

Code (ags) Select
muzika = aThe_starry_sky_above_me.Play();
muzika.Volume = 100;


Later in other rooms when I try muzika.volume=20 or anything like that it doesn't work, but if I do muzika.Stop() it works. I think I lost like an hour beating my head against the wall.
Title: Re: Audio channel problem adjusting volume across rooms
Post by: Jack on Sat 01/10/2016 16:48:43
I had similar issues with the volume property when I was making the awards client. Eventually I used another solution. There may be a bug here.
Title: Re: Audio channel problem adjusting volume across rooms
Post by: Crimson Wizard on Sat 01/10/2016 18:14:04
First of all, silly question, but have you tried setting different volume at the start to see if different volume works at all?
Could you also tell which type (format) of music is that?


Regarding bugs,
Spoiler
I've noted couple of potential bugs with audio channels in the past (although never got to working on them). However, as far as I remember, troubles arise when you keep an audio channel for the short and/or non-looping playback. If the music is looping, and not interrupted by overriding clip on same channel, then it might be something else...

There is a steady (albeit kinda ugly) workaround when there is only one instance of clip played at a time:
Code (ags) Select

AudioChannel *GetChannelForPlayingClip(AudioClip *clip)
{
  int i = 0;
  while (i < System.AudioChannelCount)
  {
    if (System.AudioChannels[i].PlayingClip == clip)
      return System.AudioChannels[i];
    i++;
  }
  return null;
}

This function returns the first channel that plays given clip. It can be used when you are wondering if your AudioChannel pointer variable actually references the correct channel.
[close]
Although from your description it is hard to tell whether all that is relevant...
Title: Re: Audio channel problem adjusting volume across rooms
Post by: xBRANEx on Sat 01/10/2016 21:25:35
Just tried it. You are right. It does not work. I'm using WAV. Will try with mp3
Title: Re: Audio channel problem adjusting volume across rooms
Post by: xBRANEx on Sat 01/10/2016 21:30:16
Used MP3. Problem solved! Thanks a lot!