aubio/__init__.py: added python helper for fvec and cvec
authorPaul Brossier <piem@piem.org>
Sun, 20 Dec 2009 19:20:14 +0000 (20:20 +0100)
committerPaul Brossier <piem@piem.org>
Sun, 20 Dec 2009 19:20:14 +0000 (20:20 +0100)
interfaces/python/aubio/__init__.py [new file with mode: 0644]

diff --git a/interfaces/python/aubio/__init__.py b/interfaces/python/aubio/__init__.py
new file mode 100644 (file)
index 0000000..cc324ef
--- /dev/null
@@ -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)