feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5pitchshiftsamplertimestretchyinfft+
Last change
on this file since efa62ce was
efa62ce,
checked in by Paul Brossier <piem@piem.org>, 9 years ago
|
ext/py-musicutils.c: complete window implementation
|
-
Property mode set to
100755
|
File size:
1.0 KB
|
Rev | Line | |
---|
[913a7f1] | 1 | #! /usr/bin/env python |
---|
| 2 | |
---|
| 3 | from numpy.testing import TestCase |
---|
[efa62ce] | 4 | from numpy.testing.utils import assert_almost_equal |
---|
[913a7f1] | 5 | from aubio import window |
---|
| 6 | |
---|
| 7 | class aubio_window(TestCase): |
---|
| 8 | |
---|
| 9 | def test_accept_name_and_size(self): |
---|
| 10 | window("default", 1024) |
---|
| 11 | |
---|
[5e394ecc] | 12 | def test_fail_name_not_string(self): |
---|
| 13 | try: |
---|
| 14 | window(10, 1024) |
---|
| 15 | except ValueError, e: |
---|
| 16 | pass |
---|
| 17 | else: |
---|
| 18 | self.fail('non-string window type does not raise a ValueError') |
---|
| 19 | |
---|
| 20 | def test_fail_size_not_int(self): |
---|
| 21 | try: |
---|
| 22 | window("default", "default") |
---|
| 23 | except ValueError, e: |
---|
| 24 | pass |
---|
| 25 | else: |
---|
| 26 | self.fail('non-integer window length does not raise a ValueError') |
---|
| 27 | |
---|
[efa62ce] | 28 | def test_compute_hanning_1024(self): |
---|
| 29 | from numpy import cos, arange |
---|
| 30 | from math import pi |
---|
| 31 | size = 1024 |
---|
| 32 | aubio_window = window("hanning", size) |
---|
| 33 | numpy_window = .5 - .5 * cos(2. * pi * arange(size) / size) |
---|
| 34 | assert_almost_equal(aubio_window, numpy_window) |
---|
| 35 | |
---|
[913a7f1] | 36 | if __name__ == '__main__': |
---|
| 37 | from unittest import main |
---|
| 38 | main() |
---|
Note: See
TracBrowser
for help on using the repository browser.