From: Paul Brossier Date: Sun, 20 Dec 2009 19:20:14 +0000 (+0100) Subject: aubio/__init__.py: added python helper for fvec and cvec X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=ccca7cb61f06d706246e17e7aeb9f3cd16cd5865;p=aubio.git aubio/__init__.py: added python helper for fvec and cvec --- diff --git a/interfaces/python/aubio/__init__.py b/interfaces/python/aubio/__init__.py new file mode 100644 index 00000000..cc324ef9 --- /dev/null +++ b/interfaces/python/aubio/__init__.py @@ -0,0 +1,20 @@ +import numpy + +class fvec(numpy.ndarray): + + def __init__(self, length = 1024, **kwargs): + super(numpy.ndarray, self).__init__(**kwargs) + + def __new__(self, length = 1024, **kwargs): + self = numpy.zeros(length, dtype='float32', **kwargs) + return self + +class cvec: + + def __init__ (self, length = 1024, **kwargs): + self.norm = numpy.zeros(length / 2 + 1, dtype='float32', **kwargs) + self.phas = numpy.zeros(length / 2 + 1, dtype='float32', **kwargs) + + def __len__ (self): + assert len(self.norm) == len(self.phas) + return len(self.norm)