pygame.set_volume(2.0) max volume 1

pygame.set_volume(2.0) max volume

very_quiet = 0.2
normal = 1
very_loud = 10

my_sound_channel.set_volume(very_quiet)
my_sound_channel.set_volume(normal)
my_sound_channel.set_volume(very_loud)

Here is what the above code is Doing:
1. We import the mixer module from the pygame library.
2. We create a variable called my_sound_channel and assign it to the mixer.Channel() function.
3. We create a variable called my_sound and assign it to the mixer.Sound() function.
4. We call the play() method on my_sound_channel and pass in my_sound as an argument.
5. We call the set_volume() method on my_sound_channel and pass in a number between 0 and 1 as an argument.

Similar Posts