Combining background MIDI music with MIDI output in pygame
So I am working with this game in which I want to have background music and trigger notes using MIDI out. The background music must also be in MIDI format. Long story short, I have something like:
pygame.init()
pygame.midi.init()
pygame.mixer.music.load("background.mid")
# I have 2 midi devices available, have tried with both
output = pygame.midi.Output(pygame.midi.get_default_output_id())
pygame.mixer.music.play()
...
... And as soon as he tries to play music, he falls. No trace, but "pythonw.exe has stopped working." I'm not sure how MIDI works, but I think the music and the output are conflicting because they are trying to use the same devices. My question is, is there a way around this or should I use a different format for the music?
+3
Pablo reyes de rojas
source
to share
1 answer
Try this little snippet and it should work fine:
import pygame
import time
pygame.mixer.init()
pygame.mixer.music.load("background.mid")
pygame.mixer.music.play()
time.sleep(10000)
In fact, try multiple processes of this script and you shouldn't have any problems either.
0
BPL
source
to share