Esempio n. 1
0
def spec_cal(signal, averages=1, atten=20, mic_sens=0.015, filter=None):
    #equipment.backend.PA5.SetAtten(atten)
    DAQ.PA5.SetAtten(atten)
    device = DAQ.init_device(**DAQ_SETTINGS)
    signal.fs = device.fs
    device.configure(signal=signal, play_duration=len(signal),
            rec_duration=len(signal) + 100)
    signals = acquire(device, len(signal) + 100, averages)
    #print 'filtering'

    return fft_analyze(signals, device.fs, mic_sens, filter=filter)
Esempio n. 2
0
def level_cal(signal, averages=1, atten=20, mic_sens=3.59e-3):
    DAQ.PA5.SetAtten(atten)
    device = DAQ.init_device(**DAQ_SETTINGS)
    device.signal.initialize()
    device.signal.set(signal)
    device.configure(play_duration=len(signal),
                     rec_duration=len(signal) + 100)
    signals = acquire(device, len(signal) + 100, averages)

    #b, a = butter(1, 100/device.fs, btype='high')
    b, a = butter(4, (np.pi * 1e3 / device.fs, np.pi * 3e3 / device.fs), btype='bandpass')
    signals = [filtfilt(b, a, s) for s in signals]

    signal = np.array(signals).mean(0)
    window = hann(device.fs * 5e-3)
    return spl_analyze(signal, window, device.fs, mic_sens)