def hfc(filename): audio = MonoLoader(filename=filename, sampleRate=44100)() features = [] for frame in FrameGenerator(audio, frameSize = 1024, hopSize = 512): mag, phase =CartesianToPolar()(FFT()(Windowing(type='hann')(frame))) features.append(OnsetDetection(method='hfc')(mag, phase)) return Onsets()(array([features]),[1])
def noveltycurve(filename): audio = MonoLoader(filename=filename, sampleRate=44100)() band_energy = [] for frame in FrameGenerator(audio, frameSize = 1024, hopSize = 512): mag, phase, = CartesianToPolar()(FFT()(Windowing(type='hann')(frame))) band_energy.append(FrequencyBands()(mag)) novelty = NoveltyCurve()(band_energy) return Onsets()(np.array([novelty]),[1])
def f_essentia_extract(Audio): ## METODOS DE LIBRERIA QUE DETECTAN DONDE OCURRE CADA NOTA RESPECTO AL TIEMPO od2 = OnsetDetection(method='complex') # Let's also get the other algorithms we will need, and a pool to store the results w = Windowing(type='hann') fft = FFT() # this gives us a complex FFT c2p = CartesianToPolar( ) # and this turns it into a pair (magnitude, phase) pool = essentia.Pool() # Computing onset detection functions. for frame in FrameGenerator(Audio, frameSize=1024, hopSize=512): mag, phase, = c2p(fft(w(frame))) pool.add('features.complex', od2(mag, phase)) ## inicio de cada "nota" onsets = Onsets() tiempos_detectados_essentia = onsets( essentia.array([pool['features.complex']]), [1]) #print(tiempos_detectados_essentia) return tiempos_detectados_essentia
sampleRate = 44100 frameSize = 2048 hopSize = 1024 windowType = "hann" mean = Mean() keyDetector = essentia.standard.Key(pcpSize=12) spectrum = Spectrum() window = Windowing(size=frameSize, zeroPadding=0, type=windowType) mfcc = MFCC() gaussian = SingleGaussian() od = OnsetDetection(method='hfc') fft = FFT() # this gives us a complex FFT c2p = CartesianToPolar() # and this turns it into a pair (magnitude, phase) onsets = Onsets(alpha=1) # dissonance spectralPeaks = SpectralPeaks(sampleRate=sampleRate, orderBy='frequency') dissonance = Dissonance() # barkbands barkbands = BarkBands(sampleRate=sampleRate) # zero crossing rate # zerocrossingrate = ZeroCrossingRate() # odd-to-even harmonic energy ratio # odd2evenharmonicenergyratio = OddToEvenHarmonicEnergyRatio() # energybands