Music volume overlay. [SOLVED]

Started by rmonic79, Sat 29/07/2017 16:06:13

Previous topic - Next topic

rmonic79

hi guys there is any fast way to have always system music volume in overlay. I need it for testing purpose.

Slasher

If I understand you correctly: you could always use a slider on a gui that sets system music volume.

Khris

Put a label on a GUI, then update its .Text in repeatedly_execute_always.

rmonic79

#3
I didn't find a Way to get system music volume, there is a specific command?

horusr

#4
QuoteSeeking and changing volume
So, how do you change a sound once it is playing? Well, there are no methods on the Audio Clip to do this, because you might be playing two copies of the same sound at once, and then AGS wouldn't know which one you wanted to access. That's where Audio Channels come to the rescue.

When you use the Play() command, AGS returns to you an AudioChannel* instance representing the channel on which the sound is playing. You can store this to a global variable and access it later on. For example:


AudioChannel* chan = aExplosion.Play();
chan.Volume = 20;

This will start the aExplosion audio clip playing, and then change its volume to 20%.

I think manual only says this. System.Volume controls all sounds I think.

rmonic79

#5
Quote from: horusr on Sat 29/07/2017 21:01:34
Quotestatic int System.Volume;

Gets/sets the overall system volume, from 0 to 100. This is the master volume control, that affects all audio in the game. You would usually attach this to a GUI Slider to enable the player to control the volume from some sort of Control Panel GUI.

o thanks i was searching in Game.
But he gets the overall system volume and i need to get music volume.

Crimson Wizard

It is Game.SetAudioTypeVolume.

Code: ags

Game.SetAudioTypeVolume(eAudioTypeMusic, 20, eVolExistingAndFuture);

rmonic79

#7
Quote from: Crimson Wizard on Sat 29/07/2017 21:15:03
It is Game.SetAudioTypeVolume.

Code: ags

Game.SetAudioTypeVolume(eAudioTypeMusic, 20, eVolExistingAndFuture);


i can use it also to get the volume?

horusr

I think you can use a loop to get audio clips and thenif their .Type is eAudioTypeMusic then you can get its channel and get its volume with .Volume option and then set a label's .Text to it...

I will look into how can you do these all.

rmonic79

i know it can be done with a some coding, i would like to knew if there's was a fast way to do it, cause i have a very short time to finish the build and i have a lot of things to do ;)

horusr

#10
Only took half an hour and I learned a lot of things!

Code: ags
AudioChannel* channel;

function repeadetly_execute()
{
  for (int i; i < System.AudioChannelCount; i++)
  {
    channel = System.AudioChannels[i];
    if (channel.PlayingClip != null && channel.PlayingClip.Type == eAudioTypeMusic)
      Label.Text = String.Format("%d", channel.Volume);
  }
}


This displays volume of current music.

rmonic79


Crimson Wizard

Quote from: rmonic79 on Sat 29/07/2017 21:18:39
Quote from: Crimson Wizard on Sat 29/07/2017 21:15:03
It is Game.SetAudioTypeVolume.

Code: ags

Game.SetAudioTypeVolume(eAudioTypeMusic, 20, eVolExistingAndFuture);


i can use it also to get the volume?


No, but you can simply remember volume you set in your own variable.

SMF spam blocked by CleanTalk