Created
July 15, 2019 18:43
-
-
Save excenter/4aadddfd618b31b8b02d3a0a051732d4 to your computer and use it in GitHub Desktop.
a bad anser to https://stackoverflow.com/questions/2159365/pygame-audio-playback-speed/57045476#57045476
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pyogg import VorbisFile | |
from pygame import mixer | |
# path to your audio | |
path = "./file.ogg" | |
# an object representing the audio, see https://github.com/Zuzu-Typ/PyOgg | |
sound = VorbisFile(path) | |
# pull the frequency out of the Vorbis abstraction | |
frequency = sound.frequency | |
# initialize the mixer | |
mixer.init(frequency=frequency) | |
# add the audio to the mixer's music channel | |
mixer.music.load(path) | |
# mixer.music.set_volume(1.0) | |
# mixer.music.fadeout(15) | |
# play | |
mixer.music.play() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment