示例#1
0
    def test_DFT(self):
        testFile = join(self.tmp, 'red_16000.wav')
        data, sampleRate = microphone.readWavFile(testFile)

        with pytest.raises(OverflowError):
            microphone.getDft([])
        microphone.getDft(data)
        microphone.getDftBins(data)
        microphone.getDftBins(data, sampleRate=16000)
        microphone.getDft(data, sampleRate=sampleRate)
        microphone.getDft(data, wantPhase=True)
示例#2
0
    # When in the file did the onset tone start and stop?
    onset, offset = mic.getMarkerOnset(
        chunk=64, secs=0.2)  # increase secs if miss the markers
    onsets.append(onset)

    # display options:
    text.draw()
    win.flip()
    print("%.3f %.3f" % (onset, offset))
    if len(event.getKeys(['escape'])):
        core.quit()
    if len(event.getKeys()):
        msg2.draw()
        win.flip()
        data, sampleRate = microphone.readWavFile(filename)
        plotYX(data, list(range(len(data))), "time domain @ %iHz" % sampleRate)
        mag, freqV = microphone.getDft(data, sampleRate)
        plotYX(mag, freqV,
               "frequency domain (marker at %i Hz)" % mic.getMarkerInfo()[0])

    # no need to keep the recorded file:
    os.unlink(filename)

print("\nmarker onset = %.3fs %.3f (mean SD), relative to start of file" %
      (np.mean(onsets), np.std(onsets)))

win.close()
core.quit()

# The contents of this file are in the public domain.
示例#3
0
    while mic.recorder.running:
        core.wait(.01, 0)

    # When in the file did the onset tone start and stop?
    onset, offset = mic.getMarkerOnset(chunk=64, secs=0.2)  # increase secs if miss the markers
    onsets.append(onset)

    # display options:
    text.draw()
    win.flip()
    print("%.3f %.3f" % (onset, offset))
    if len(event.getKeys(['escape'])):
        core.quit()
    if len(event.getKeys()):
        msg2.draw()
        win.flip()
        data, sampleRate = microphone.readWavFile(filename)
        plotYX(data, list(range(len(data))), "time domain @ %iHz" % sampleRate)
        mag, freqV = microphone.getDft(data, sampleRate)
        plotYX(mag, freqV, "frequency domain (marker at %i Hz)" % mic.getMarkerInfo()[0])

    # no need to keep the recorded file:
    os.unlink(filename)

print("\nmarker onset = %.3fs %.3f (mean SD), relative to start of file" % (np.mean(onsets), np.std(onsets)))

win.close()
core.quit()

# The contents of this file are in the public domain.