简体   繁体   中英

Python: Most accurate way to play time the playing of sound samples

There are plenty of question and answers about playing sound samples in Python, but I'm interested to know the most accurate way to time the playing of samples. Suppose I'm writing a bit of Python capable of playing a complex rhythm made up from samples of drum hits: I want the timer-based triggering of my audio samples to be as accurate as possible.

Any recommendations? Would be happy to hear any ideas such as "Audio library X does accurate timings fine", or "The most accurate general timing mechanism in Python is Y", etc.

For sound samples I only have experience with SDL which you can use through the Pygame package:

http://www.pygame.org/docs/ref/mixer.html

While I can't speak to its performance with the kind of application you have in mind SDL is used in a fair number of games so I imagine it's performance is fairly solid. I can say that Pygame is quite easy to figure out and has quite a bit of documentation and example games to look at.

Some interesting audo related projects using pygame:

http://www.pygame.org/project-noiselib-1442-2573.html http://www.pygame.org/project-pygame+music+grid+beta+.9-1185-.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM