from math import sin class AudioProducer(object): offset = 0 def callback(self): offset = self.offset self.offset += 512 return [ 0.5 * sin(3.1415*440.0/44100.0*(frame+offset)) for frame in xrange(512) ] import thread import coreaudio import time ## Have to initialize the threading mechanisms in order for PyGIL_Ensure to work thread.start_new_thread(lambda: None, ()) ap = AudioProducer() coreaudio.installAudioCallback(ap) time.sleep(5) coreaudio.stopAudio(ap)