source: tests/python/src/spectral/phasevoc.py @ e6b2a0c

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

tests/python: update imports

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