From: Thomas Fillon Date: Thu, 19 Jun 2014 13:57:12 +0000 (+0200) Subject: feat(aubio_pitch.py): add blocksize and stepsize as input parameters X-Git-Tag: 0.6~4^2~91 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=fded28e5a63a22e77e24cd644be9a0c4fd8bda15;p=timeside.git feat(aubio_pitch.py): add blocksize and stepsize as input parameters --- diff --git a/timeside/analyzer/aubio/aubio_pitch.py b/timeside/analyzer/aubio/aubio_pitch.py index bcd7d6d..378707b 100644 --- a/timeside/analyzer/aubio/aubio_pitch.py +++ b/timeside/analyzer/aubio/aubio_pitch.py @@ -26,17 +26,19 @@ from timeside.api import IAnalyzer from timeside.analyzer.preprocessors import downmix_to_mono, frames_adapter from aubio import pitch import numpy as np - +from timeside.analyzer.utils import nextpow2 class AubioPitch(Analyzer): """Aubio Pitch estimation analyzer""" implements(IAnalyzer) # TODO check if needed with inheritance - def __init__(self): + def __init__(self, blocksize_s=None, stepsize_s=None): + super(AubioPitch, self).__init__() - self.input_blocksize = 2048 - self.input_stepsize = self.input_blocksize / 2 + + self._blocksize_s = blocksize_s + self._stepsize_s = stepsize_s @interfacedoc def setup(self, channels=None, samplerate=None, @@ -45,6 +47,20 @@ class AubioPitch(Analyzer): samplerate, blocksize, totalframes) + + + # Frame parameters setup + if self._blocksize_s: + self.input_blocksize = nextpow2(self._blocksize_s * samplerate) + else: + self.input_blocksize = 2048 + + if self._stepsize_s: + self.input_stepsize = nextpow2(self._stepsize_s * samplerate) + else: + self.input_stepsize = self.input_blocksize / 2 + + # Aubio Pitch set-up self.aubio_pitch = pitch( "default", self.input_blocksize, self.input_stepsize, samplerate)