コード例 #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)
コード例 #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)
コード例 #3
0
    def computeNoveltyCurve(self,
                            filename,
                            frameSize=1024,
                            hopSize=512,
                            windowType='hann',
                            weightCurveType='hybrid',
                            sampleRate=44100.0,
                            startTime=0,
                            endTime=2000):

        loader = ess.EasyLoader(filename=filename,
                                startTime=startTime,
                                endTime=endTime,
                                sampleRate=sampleRate,
                                downmix='left')
        fc = ess.FrameCutter(frameSize=frameSize,
                             hopSize=hopSize,
                             silentFrames="keep",
                             startFromZero=False,
                             lastFrameToEndOfFile=True)
        window = ess.Windowing(type=windowType,
                               zeroPhase=True,
                               zeroPadding=1024 - frameSize)
        freqBands = ess.FrequencyBands(
            sampleRate=sampleRate)  # using barkbands by default
        spec = ess.Spectrum()

        pool = Pool()
        loader.audio >> fc.signal
        fc.frame >> window.frame >> spec.frame
        spec.spectrum >> freqBands.spectrum
        freqBands.bands >> (pool, 'frequency_bands')
        essentia.run(loader)

        noveltyCurve = NoveltyCurve(frameRate=sampleRate / float(hopSize),
                                    weightCurveType=weightCurveType)(
                                        pool['frequency_bands'])

        return noveltyCurve