source: tests/python/src/spectral/phasevoc.py @ 1cc007c

feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5pitchshiftsamplertimestretchyinfft+
Last change on this file since 1cc007c was 66a150a2, checked in by Paul Brossier <piem@piem.org>, 17 years ago

move around files in tests/python according to src/ changes

  • Property mode set to 100644
File size: 2.0 KB
Line 
1import unittest
2
3from aubio.aubiowrapper import *
4
5buf_size = 1024
6hop_size = 256
7channels = 2
8
9precision = 6
10
11class phasevoc_unit(unittest.TestCase):
12
13  def setUp(self):
14    self.o = new_aubio_pvoc(buf_size, hop_size, channels)
15
16  def tearDown(self):
17    del_aubio_pvoc(self.o)
18
19  def test_create(self):
20    """ create and delete phasevoc object """
21    pass
22
23  def test_zeroes(self):
24    """ run phasevoc object on zeroes """
25    input    = new_fvec(hop_size, channels)
26    fftgrain = new_cvec(buf_size, channels)
27    output   = new_fvec(hop_size, channels)
28    for index in range(hop_size):
29      for channel in range(channels):
30        self.assertEqual(0., fvec_read_sample(input, channel, index))
31    aubio_pvoc_do (self.o, input, fftgrain)
32    aubio_pvoc_rdo(self.o, fftgrain, output)
33    for index in range(hop_size):
34      for channel in range(channels):
35        self.assertEqual(0., fvec_read_sample(output, channel, index))
36    del input
37    del fftgrain
38
39  def test_ones(self):
40    """ run phasevoc object on ones """
41    input    = new_fvec(hop_size, channels)
42    fftgrain = new_cvec(buf_size, channels)
43    output   = new_fvec(hop_size, channels)
44    for index in range(hop_size):
45      for channel in range(channels):
46        fvec_write_sample(input, 1., channel, index)
47        self.assertEqual(1., fvec_read_sample(input, channel, index))
48    # make sure the first buf_size-hop_size samples are zeroes
49    for i in range(buf_size/hop_size - 1):
50      aubio_pvoc_do (self.o, input, fftgrain)
51      aubio_pvoc_rdo(self.o, fftgrain, output)
52      for index in range(hop_size):
53        for channel in range(channels):
54          self.assertAlmostEqual(0., fvec_read_sample(output, channel, index), precision)
55    # make sure the first non zero input is correctly resynthesised
56    aubio_pvoc_do (self.o, input, fftgrain)
57    aubio_pvoc_rdo(self.o, fftgrain, output)
58    for index in range(hop_size):
59      for channel in range(channels):
60        self.assertAlmostEqual(1., fvec_read_sample(output, channel, index), precision)
61    del input
62    del fftgrain
Note: See TracBrowser for help on using the repository browser.