|
Everything Else
Playing music in Python
Calling MATLAB functions from
Python
Of course, there are several ways to do this. I found the pygame module best for playing MIDI files. Here are some pointers to get started: After importing pygame, Set some playback parameters this way: freq = 44100 bitsize = -16 channels = 2 buffer = 1024 # number of samples pygame.mixer.init(freq, bitsize, channels, buffer) pygame.mixer.music.set_volume(1.0) Now you can try to load and play the file: pygame.mixer.music.load(music_file) #music_file is the path to your MIDI file pygame.mixer.music.play() To stop playing: pygame.mixer.music.stop() Go back home |