def computeLowLevel(input_file, pool, startTime, endTime, namespace=''): llspace = 'lowlevel.' rhythmspace = 'rhythm.' if namespace: llspace = namespace + '.lowlevel.' rhythmspace = namespace + '.rhythm.' rgain, sampleRate, downmix = getAnalysisMetadata(pool) loader = streaming.EqloudLoader(filename=input_file, sampleRate=sampleRate, startTime=startTime, endTime=endTime, replayGain=rgain, downmix=downmix) lowlevel.compute(loader.audio, loader.audio, pool, 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 pool.containsKey(llspace + "loudness"): INFO('ERROR: File is too short (< 2sec)... Aborting...') sys.exit(2) numOnsets = len(pool[rhythmspace + 'onset_times']) sampleRate = pool['metadata.audio_properties.analysis_sample_rate'] onset_rate = numOnsets / float(loader.audio.totalProduced()) * sampleRate pool.set(rhythmspace + 'onset_rate', onset_rate)
def computeMidLevel(input_file, pool, startTime, endTime, namespace=''): rgain, sampleRate, downmix = getAnalysisMetadata(pool) loader = streaming.EqloudLoader(filename=input_file, sampleRate=sampleRate, startTime=startTime, endTime=endTime, replayGain=rgain, downmix=downmix) midlevel.compute(loader.audio, pool, startTime, endTime, namespace) essentia.run(loader)