Timing accuracy in Python using WXPython
Question: I'm making a simple mp3 player that plays multiple mp3's at a time. It acts
like it is mixing. Timing is critical to ensure a pleasant user experience,
otherwise it just sounds like two cats trying to solve the mid east crisis. I
need accuracy down to 10ms, and probably will need 1ms accuracy if it doesn't
work out.

Currently, I'm using wxpython and I find the timing functions very poor (but
great for audio playback).

    
    
    import wx
    import wx.media
    
    class MediaPanel(wx.Panel):
        INTERVAL = 10
    
        def tick(self, event):
            self.totalMS += self.INTERVAL
    
            if mixstart == self.totalMS:
                # play the song
    
            elif mixend == self.totalMS:
                # stop the song
    
            else 
                pass
    

* * *

So here's my issue: I find that the timing is inconsistent. I can have the
same songs loaded up in a playlist ready to mix, and it will mix in at what
seems like random times. I'm still new to programming in general, and from
what I can tell, it's the timing function that is not accurate. For debugging
purposes, I will print out a timestamp to let me know where I am in the
functions. For some reason, the timer will just stop randomly, then start up
again.

Question: Is there a better way to do this? Or is wx just broken for something
like this?


Answer: I do not think that you can mix mp3 playbacks reliably in any GUI library. It
is not meant to synchronize sound and if you just call two functions playing
mp3s I believe there is not way to control the timing.

Easiest what comes to mind is to mix the two tracks first and then play (like
in [**this question**](http://stackoverflow.com/questions/7629873/how-do-i-
mix-audio-files-using-python)). Is that not good enough?

