import pygame import numpy def playnote(pitch, duration): pitch = 110 * (2 ** (1./12)) ** pitch samples_per_cycle = 44100 / pitch values = (numpy.arange(samples_per_cycle) / float(pitch)) * 65535 values = values.astype(numpy.int32) values = numpy.resize(values, (44100,)) sound = pygame.mixer.Sound(array=values) channel = sound.play(-1) pygame.time.delay(duration) sound.stop() pygame.mixer.pre_init(44100, -16, 1) pygame.init() playnote(0,250) playnote(2,250) playnote(3,250) playnote(0,250) playnote(7,250)