コード例 #1
0
def recording_thd(inputData, inputTypes):
    output = []
    outputData = []
    outputTypes = []
    # basic sanity check
    inputError = False
    if (inputTypes[0] != TYPE_MONO):
        inputError = True
    if (inputTypes[1] != TYPE_MONO):
        inputError = True
    if (inputTypes[2] != TYPE_I64):
        inputError = True
    if (inputTypes[3] != TYPE_DOUBLE):
        inputError = True
    if inputError:
        output.append(RESULT_ERROR)
        output.append(outputData)
        output.append(outputTypes)
        return output

    hostRecording = inputData[0]
    deviceRecording = inputData[1]
    signalFrequency = inputData[2]
    thdPassPercentile = inputData[3]
    samplingRate = 44100

    delay = calc_delay.calc_delay(hostRecording, deviceRecording)
    N = len(deviceRecording)
    print "delay ", delay, "deviceRecording samples ", N
    thdHost = calc_thd(hostRecording[delay:delay + N], signalFrequency,
                       samplingRate, 0.02) * 100
    thdDevice = calc_thd(deviceRecording, signalFrequency, samplingRate,
                         0.02) * 100
    print "THD Host %", thdHost, "THD device %", thdDevice, "Margain % ", thdPassPercentile
    if (thdDevice <
        (thdHost + thdPassPercentile)) and (thdHost < thdPassPercentile):
        output.append(RESULT_PASS)
    else:
        output.append(RESULT_OK)
    outputData.append(thdHost)
    outputTypes.append(TYPE_DOUBLE)
    outputData.append(thdDevice)
    outputTypes.append(TYPE_DOUBLE)
    output.append(outputData)
    output.append(outputTypes)
    return output
コード例 #2
0
ファイル: recording_thd.py プロジェクト: rcoscali/cts
def recording_thd(inputData, inputTypes):
    output = []
    outputData = []
    outputTypes = []
    # basic sanity check
    inputError = False
    if inputTypes[0] != TYPE_MONO:
        inputError = True
    if inputTypes[1] != TYPE_MONO:
        inputError = True
    if inputTypes[2] != TYPE_I64:
        inputError = True
    if inputTypes[3] != TYPE_DOUBLE:
        inputError = True
    if inputError:
        output.append(RESULT_ERROR)
        output.append(outputData)
        output.append(outputTypes)
        return output

    hostRecording = inputData[0]
    deviceRecording = inputData[1]
    signalFrequency = inputData[2]
    thdPassPercentile = inputData[3]
    samplingRate = 44100

    delay = calc_delay.calc_delay(hostRecording, deviceRecording)
    N = len(deviceRecording)
    print "delay ", delay, "deviceRecording samples ", N
    thdHost = calc_thd(hostRecording[delay : delay + N], signalFrequency, samplingRate, 0.02) * 100
    thdDevice = calc_thd(deviceRecording, signalFrequency, samplingRate, 0.02) * 100
    print "THD Host %", thdHost, "THD device %", thdDevice, "Margain % ", thdPassPercentile
    if (thdDevice < (thdHost + thdPassPercentile)) and (thdHost < thdPassPercentile):
        output.append(RESULT_PASS)
    else:
        output.append(RESULT_OK)
    outputData.append(thdHost)
    outputTypes.append(TYPE_DOUBLE)
    outputData.append(thdDevice)
    outputTypes.append(TYPE_DOUBLE)
    output.append(outputData)
    output.append(outputTypes)
    return output
コード例 #3
0
def check_spectrum(inputData, inputTypes):
    output = []
    outputData = []
    outputTypes = []
    # basic sanity check
    inputError = False
    if (inputTypes[0] != TYPE_MONO) and (inputTypes[0] != TYPE_STEREO):
        inputError = True
    if (inputTypes[1] != TYPE_MONO) and (inputTypes[1] != TYPE_STEREO):
        inputError = True
    if (inputTypes[2] != TYPE_I64):
        inputError = True
    if (inputTypes[3] != TYPE_I64):
        inputError = True
    if (inputTypes[4] != TYPE_I64):
        inputError = True
    if (inputTypes[5] != TYPE_DOUBLE):
        inputError = True
    if (inputTypes[6] != TYPE_DOUBLE):
        inputError = True
    if inputError:
        print "input error"
        output.append(RESULT_ERROR)
        output.append(outputData)
        output.append(outputTypes)
        return output
    hostData = inputData[0]
    if inputTypes[0] == TYPE_STEREO:
        hostData = toMono(hostData)
    dutData = inputData[1]
    if inputTypes[1] == TYPE_STEREO:
        dutData = toMono(dutData)
    samplingRate = inputData[2]
    fLow = inputData[3]
    fHigh = inputData[4]
    margainLow = inputData[5]
    margainHigh = inputData[6]
    delay = 0
    N = 0
    hostData_ = hostData
    dutData_ = dutData
    if len(hostData) > len(dutData):
        delay = calc_delay.calc_delay(hostData, dutData)
        N = len(dutData)
        hostData_ = hostData[delay:delay+N]
    if len(hostData) < len(dutData):
        delay = calc_delay.calc_delay(dutData, hostData)
        N = len(hostData)
        dutData_ = dutData[delay:delay+N]

    print "delay ", delay, "deviceRecording samples ", N
    (passFail, minError, maxError, TF) = do_check_spectrum(hostData_, dutData_,\
        samplingRate, fLow, fHigh, margainLow, margainHigh)

    if passFail:
        output.append(RESULT_PASS)
    else:
        output.append(RESULT_OK)
    outputData.append(minError)
    outputTypes.append(TYPE_DOUBLE)
    outputData.append(maxError)
    outputTypes.append(TYPE_DOUBLE)
    outputData.append(TF)
    outputTypes.append(TYPE_MONO)
    output.append(outputData)
    output.append(outputTypes)
    return output
コード例 #4
0
ファイル: check_spectrum.py プロジェクト: rcoscali/cts
def check_spectrum(inputData, inputTypes):
    output = []
    outputData = []
    outputTypes = []
    # basic sanity check
    inputError = False
    if (inputTypes[0] != TYPE_MONO) and (inputTypes[0] != TYPE_STEREO):
        inputError = True
    if (inputTypes[1] != TYPE_MONO) and (inputTypes[1] != TYPE_STEREO):
        inputError = True
    if inputTypes[2] != TYPE_I64:
        inputError = True
    if inputTypes[3] != TYPE_I64:
        inputError = True
    if inputTypes[4] != TYPE_I64:
        inputError = True
    if inputTypes[5] != TYPE_DOUBLE:
        inputError = True
    if inputTypes[6] != TYPE_DOUBLE:
        inputError = True
    if inputError:
        print "input error"
        output.append(RESULT_ERROR)
        output.append(outputData)
        output.append(outputTypes)
        return output
    hostData = inputData[0]
    if inputTypes[0] == TYPE_STEREO:
        hostData = toMono(hostData)
    dutData = inputData[1]
    if inputTypes[1] == TYPE_STEREO:
        dutData = toMono(dutData)
    samplingRate = inputData[2]
    fLow = inputData[3]
    fHigh = inputData[4]
    margainLow = inputData[5]
    margainHigh = inputData[6]
    delay = 0
    N = 0
    hostData_ = hostData
    dutData_ = dutData
    if len(hostData) > len(dutData):
        delay = calc_delay.calc_delay(hostData, dutData)
        N = len(dutData)
        hostData_ = hostData[delay : delay + N]
    if len(hostData) < len(dutData):
        delay = calc_delay.calc_delay(dutData, hostData)
        N = len(hostData)
        dutData_ = dutData[delay : delay + N]

    print "delay ", delay, "deviceRecording samples ", N
    (passFail, minError, maxError, TF) = do_check_spectrum(
        hostData_, dutData_, samplingRate, fLow, fHigh, margainLow, margainHigh
    )

    if passFail:
        output.append(RESULT_PASS)
    else:
        output.append(RESULT_OK)
    outputData.append(minError)
    outputTypes.append(TYPE_DOUBLE)
    outputData.append(maxError)
    outputTypes.append(TYPE_DOUBLE)
    outputData.append(TF)
    outputTypes.append(TYPE_MONO)
    output.append(outputData)
    output.append(outputTypes)
    return output