Example #1
0
def getFrequenciesFromMicrophone(length=10.0, storeWaveFilename=None):
    '''
    records for length (=seconds) a set of frequencies from the microphone.

    If storeWaveFilename is not None, then it will store the recording on disk
    in a wave file.

    Returns a list of frequencies detected.

    TODO -- find a way to test... or at least demo
    '''
    if "numpy" in base._missingImport:
        raise AudioSearchException("Cannot run getFrequenciesFromMicrophone without numpy installed")

    import numpy
    environLocal.printDebug("* start recording")
    storedWaveSampleList = recording.samplesFromRecording(seconds=length,
                                                          storeFile=storeWaveFilename,
                                                          recordChunkLength=audioChunkLength)
    environLocal.printDebug("* stop recording")

    freqFromAQList = []

    for data in storedWaveSampleList:
        samps = numpy.fromstring(data, dtype=numpy.int16)
        freqFromAQList.append(autocorrelationFunction(samps, recordSampleRate))
    return freqFromAQList
Example #2
0
def getFrequenciesFromMicrophone(length=10.0, storeWaveFilename=None):
    '''
    records for length (=seconds) a set of frequencies from the microphone.

    If storeWaveFilename is not None, then it will store the recording on disk
    in a wave file.

    Returns a list of frequencies detected.

    TODO -- find a way to test... or at least demo
    '''
    if "numpy" in base._missingImport:
        raise AudioSearchException(
            "Cannot run getFrequenciesFromMicrophone without numpy installed")

    import numpy
    environLocal.printDebug("* start recording")
    storedWaveSampleList = recording.samplesFromRecording(
        seconds=length,
        storeFile=storeWaveFilename,
        recordChunkLength=audioChunkLength)
    environLocal.printDebug("* stop recording")

    freqFromAQList = []

    for data in storedWaveSampleList:
        samps = numpy.fromstring(data, dtype=numpy.int16)
        freqFromAQList.append(autocorrelationFunction(samps, recordSampleRate))
    return freqFromAQList