I wrote this simple drum pad program with pygame and the lag between key
presses and the start of the sound bugs me. Can I use JACK with pygame so
there will be less latency (in the same way that SooperLooper+Jack in Ubuntu
is super fast)? Any code snippets or links to articles would be greatly
appreciated.
###### start simple.py #############
import pygame
from pygame.locals import *
from sys import exit
pygame.mixer.pre_init(48000,-16,2,1024)
screen = pygame.display.set_mode((400, 300), RESIZABLE, 32)
pygame.display.set_caption("Simple!!1")
pygame.init()
pygame.mixer.set_reserved(1)
reserved_channel_0 = pygame.mixer.Channel(0)
sound1 = pygame.mixer.Sound("beat1.wav")
while True:
for event in pygame.event.get():
if event.type == QUIT:
exit()
if event.type == KEYDOWN:
if event.key == K_UP:
sound1.play()
#print "UP"
if event.key == K_DOWN:
sound1.stop()
#print "DOWN"
###### end simple.py #################