From fded28e5a63a22e77e24cd644be9a0c4fd8bda15 Mon Sep 17 00:00:00 2001 From: Thomas Fillon Date: Thu, 19 Jun 2014 15:57:12 +0200 Subject: [PATCH] feat(aubio_pitch.py): add blocksize and stepsize as input parameters --- timeside/analyzer/aubio/aubio_pitch.py | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) 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) -- 2.39.5