Skip to content

Mixer is not accurate in playing audio at a rate. #3329

Open
@qaqFei

Description

@qaqFei

Environment:

If possible, please include the output of pygame.print_debug_info() from your program in your bug report. It looks something
like this:

pygame-ce 2.5.2 (SDL 2.30.8, Python 3.12.8)
Platform:		Windows 10
System:			Windows
System Version:	10.0.19042.508
Processor:		Genuine Intel(R) 0000 @ 1.80GHz
Architecture:	Bits: 64bit	Linkage: WindowsPE

Python:			    CPython 3.12.8 (tags/v3.12.8:2dc476b, Dec  3 2024, 19:30:04) [MSC v.1942 64 bit (AMD64)] on win32
pygame version:		 2.5.2
SDL versions:		2.30.8.0
SDL Mixer versions:	2.8.0.0

Mixer Driver:		unknow

If you can't get the debug output, any of the environment details included in it that you do know would be useful
in diagnosing the issue & helping you.

Other environment details, not included in print_debug_info(), that might help:

  • Relevant hardware (e.g. if reporting a bug about a controller, tell us the brand & name of it):

Current behavior:
The latency of the Mixer get_pos gradually increases, disappearing when the Mixer is reset (i.e., get_pos reset to zero)

Screenshots

directsound:

dxs.mp4

sdl2_mixer:

sdl2-mixer.mp4

Steps to reproduce:

Please explain the steps required to duplicate the issue, especially if you are able to provide a sample application.
if the bug is caused by a specific file (image, font, sound, level, please upload it as an attachment

  1. Load a long audio file
  2. Play it
  3. Wait playing...

Test code

If possible add a simple test program that shows the problem described in this report.

import time
from pygame import mixer

mixer.init()

mixer.music.load("a_long_music.mp3")
mixer.music.play()
while not mixer.music.get_busy(): ...

start_time = time.time()

while mixer.music.get_busy():
    # There is no error here.
    print(time.time() - start_time, mixer.music.get_pos() / 1000)

# If the length of that audio is 3600s, the variable "use_time" will be greater than 3600s
use_time = time.time() - start_time

Stack trace/error output/other error logs

paste other relevant logs or stack traces here, if applicable

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugNot working as intended

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions