pygame audio playback speed

前端 未结 5 666
走了就别回头了
走了就别回头了 2020-12-03 18:19

quick question.

I\'m running pygame under linux just to play some audio files. I\'ve got some .wav files and I\'m having problems playing them back at the right spe

5条回答
  •  广开言路
    2020-12-03 18:55

    I had some mp3 audio tracks playing back slowed down. I updated the mixer frequency to be based on the mp3 sample rate using mutagen like so:

    import pygame, mutagen.mp3
    
    song_file = "your_music.mp3"
    
    mp3 = mutagen.mp3.MP3(song_file)
    pygame.mixer.init(frequency=mp3.info.sample_rate)
    
    pygame.mixer.music.load(song_file)
    pygame.mixer.music.play()
    

    And it fixed the problem.

提交回复
热议问题