python - Mixing music by using pygame -
i'm foundation student , new coding. i'm planning music notation program can select note want , put on slave , have play button play it. face problem using pygame can play 1 mp3 in time. i'm trying test coding based on tutorial on internet still stucked.
is there other ways me mixing music part?
here coding part want try , mix sound different mp3. error with:
traceback (most recent call last): file "c:/users/user/desktop/python sound test/#def.py", line 23, in <module> tk.button(root, text=' c '.format(c), command=play).pack() nameerror: name 'play' not defined
code:
import pygame import tkinter tk pygame.mixer.init() c_notes = pygame.mixer.music.load("c.mp3") lc_notes = pygame.mixer.music.load("lc.mp3") root=tk.tk() def c(): c_notes.play def lc(): lc_notes.play def mix(): c_notes.play lc_notes.play tk.button(root, text=' c '.format(c), command=play).pack() tk.button(root, text=' lc '.format(lc), command=play).pack() tk.button(root, text=' mix '.format(mix), command=play).pack() root.mainloop()
try following:
import pygame ... sounds = [] sounds.append(pygame.mixer.sound('sound1')) sounds.append(pygame.mixer.sound('sound2')) sound in sounds: sound.play()
Comments
Post a Comment