Ejemplo n.º 1
0
        pdb.set_trace()

    replThread = Thread(target=replFunc)
    replThread.start()
#repl()

def initRecording(sig):
    p = pyaudio.PyAudio()
    def callback(in_data, frame_count, time_info, status):
        nextTime = time.time()
        newSamples = np.fromstring(in_data,dtype=np.int16)
        sig.Y = np.append(sig.Y,zip(newSamples[::2],newSamples[1::2]),0)
        sig.A = signal.lift((sig.Y[:,0] + sig.Y[:,1]) / 2, True)
        startTime = nextTime
        return (in_data,pyaudio.paContinue)
    startTime = time.time()
    stream = p.open(channels=2,
                    format=pyaudio.paInt16,
                    frames_per_buffer=1024,
                    rate=44100,
                    input=True,
                    input_device_index=0,
                    stream_callback=callback,
                    )
    return stream
# apply utility "lift"s -- this sets up signal.avgN and longavgN variables
signalutil.setup(sig)
# perceive signal at 90 fps (or lesser when not possible)
stream = initRecording(sig)
signal.realTimeProcess([graphsProcess, beatDetected], sig, 32)
Ejemplo n.º 2
0
        pdb.set_trace()

    replThread = Thread(target=replFunc)
    replThread.start()
#repl()

def initRecording(sig):
    p = pyaudio.PyAudio()
    def callback(in_data, frame_count, time_info, status):
        nextTime = time.time()
        newSamples = np.fromstring(in_data,dtype=np.int16)
        sig.Y = np.append(sig.Y,zip(newSamples[::2],newSamples[1::2]),0)
        sig.A = signal.lift((sig.Y[:,0] + sig.Y[:,1]) / 2, True)
        startTime = nextTime
        return (in_data,pyaudio.paContinue)
    startTime = time.time()
    stream = p.open(channels=2,
                    format=pyaudio.paInt16,
                    frames_per_buffer=1024,
                    rate=44100,
                    input=True,
                    input_device_index=0,
                    stream_callback=callback,
                    )
    return stream
# apply utility "lift"s -- this sets up signal.avgN and longavgN variables
signalutil.setup(sig)
# perceive signal at 90 fps (or lesser when not possible)
stream = initRecording(sig)
signal.realTimeProcess([graphsProcess], sig, 90)
Ejemplo n.º 3
0
        pdb.set_trace()

    replThread = Thread(target=replFunc)
    replThread.start()
#repl()

def initRecording(sig):
    p = pyaudio.PyAudio()
    def callback(in_data, frame_count, time_info, status):
        nextTime = time.time()
        newSamples = np.fromstring(in_data,dtype=np.int16)
        sig.Y = np.append(sig.Y,zip(newSamples[::2],newSamples[1::2]),0)
        sig.A = signal.lift((sig.Y[:,0] + sig.Y[:,1]) / 2, True)
        startTime = nextTime
        return (in_data,pyaudio.paContinue)
    startTime = time.time()
    stream = p.open(channels=2,
                    format=pyaudio.paInt16,
                    frames_per_buffer=1024,
                    rate=44100,
                    input=True,
                    input_device_index=3, #change index based on the device id
                    stream_callback=callback,
                    )
    return stream
# apply utility "lift"s -- this sets up signal.avgN and longavgN variables
signalutil.setup(sig)
# perceive signal at 90 fps (or lesser when not possible)
stream = initRecording(sig)
signal.realTimeProcess([graphsProcess, beatDetected], sig, 32)