Exemple #1
0
def testNote(freq,noteValueEntries,isWinSound,debug=False):
    #plays a note once, given the valueEntries and frequency of the note to play
    if debug: print freq
    attack,decay,sustain,release,dur,mul = noteValueEntries
    #plays using winSound if isWinSound
    if isWinSound:
        winsound.Beep(freq,int(dur*1000))
    #otherwise, uses pyo
    else: 
        note = music.note(freq,attack,decay,sustain,release,dur,mul)
        note.play()
        time.sleep(dur)
Exemple #2
0
def playNote(freq,entries, distanceQueue, taskDoneEvent,isWinSound,debug=False):
    '''Used by main().  It is what is threaded over and over'''
    attack,decay,sustain,release,dur,mul = entries
    if not isWinSound:
        note = music.note(freq,attack,decay,sustain,release,dur,mul)
    while True:
        if not distanceQueue.empty(): #if there is a distance available
            print 'getting data...',
            data = distanceQueue.get() #gets the data from the queue
            print 'got',data
            data = int(data/10)
            if isWinSound:
                winsound.Beep(freq,int(dur*1000))
                if debug: print 'played'
            else:
                if debug: print 'pyo...',
                if debug: print 'data',data,
                note.play(data) #plays a note
                if debug: print 'played'
                time.sleep(dur) #waits for it to finish
            taskDoneEvent.set() #lets the upper thread know that the thread is finished