From ccca7cb61f06d706246e17e7aeb9f3cd16cd5865 Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Sun, 20 Dec 2009 20:20:14 +0100 Subject: [PATCH] aubio/__init__.py: added python helper for fvec and cvec --- interfaces/python/aubio/__init__.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 interfaces/python/aubio/__init__.py 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) -- 2.26.2