Python3 - how to change volume of a sound in pygame mixer

Viewed 1183

i am making a game in pygame and there is one sound which when i play using

import pygame
retro = pygame.mixer.Sound("sounds/retro.wav")
retro.play()

it almost kills my ears it's too loud, is there a way to change the volume of the sound i am playing...

Thanks for helping in advance

1 Answers

Use pygame.mixer.Sound.set_volume to set the volume, from 0.0 to 1.0 where higher is louder.

import pygame
retro = pygame.mixer.Sound("sounds/retro.wav")
retro.set_volume(1.0)
retro.play()
Related