Beispiel #1
0
def computeLowLevel(input_file,
                    neqPool,
                    eqPool,
                    startTime,
                    endTime,
                    namespace=''):
    llspace = 'lowlevel.'
    rhythmspace = 'rhythm.'
    if namespace:
        llspace = namespace + '.lowlevel.'
        rhythmspace = namespace + '.rhythm.'

    rgain, sampleRate, downmix = getAnalysisMetadata(neqPool)
    loader = streaming.EasyLoader(filename=input_file,
                                  sampleRate=sampleRate,
                                  startTime=startTime,
                                  endTime=endTime,
                                  replayGain=rgain,
                                  downmix=downmix)

    eqloud = streaming.EqualLoudness()
    loader.audio >> eqloud.signal
    lowlevel.compute(eqloud.signal, loader.audio, neqPool, startTime, endTime,
                     namespace)
    lowlevel.compute(eqloud.signal, eqloud.signal, eqPool, startTime, endTime,
                     namespace)
    essentia.run(loader)

    # check if we processed enough audio for it to be useful, in particular did
    # we manage to get an estimation for the loudness (2 seconds required)
    if not neqPool.containsKey(llspace + "loudness") and\
       not eqPool.containsKey(llspace + "loudness"):
        INFO('ERROR: File is too short (< 2sec)... Aborting...')
        sys.exit(2)

    sampleRate = neqPool['metadata.audio_properties.analysis_sample_rate']

    numOnsets = len(neqPool[rhythmspace + 'onset_times'])
    onset_rate = numOnsets / float(loader.audio.totalProduced()) * sampleRate
    neqPool.set(rhythmspace + 'onset_rate', onset_rate)

    numOnsets = len(eqPool[rhythmspace + 'onset_times'])
    onset_rate = numOnsets / float(loader.audio.totalProduced()) * sampleRate
    eqPool.set(rhythmspace + 'onset_rate', onset_rate)
Beispiel #2
0
def computeMidLevel(input_file,
                    neqPool,
                    eqPool,
                    startTime,
                    endTime,
                    namespace=''):
    rgain, sampleRate, downmix = getAnalysisMetadata(neqPool)
    loader = streaming.EasyLoader(filename=input_file,
                                  sampleRate=sampleRate,
                                  startTime=startTime,
                                  endTime=endTime,
                                  replayGain=rgain,
                                  downmix=downmix)

    eqloud = streaming.EqualLoudness()
    loader.audio >> eqloud.signal
    midlevel.compute(loader.audio, neqPool, startTime, endTime, namespace)
    midlevel.compute(eqloud.signal, eqPool, startTime, endTime, namespace)
    essentia.run(loader)