Changeset ac65a2f


Ignore:
Timestamp:
Apr 27, 2016, 8:47:31 PM (8 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
Children:
1f4d932
Parents:
1d0370a
Message:

python/tests/test_phasevoc.py: check perfect reconstruction for overlap > 75%

File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/tests/test_phasevoc.py

    r1d0370a rac65a2f  
    22
    33from numpy.testing import TestCase, assert_equal, assert_almost_equal
    4 from aubio import fvec, cvec, pvoc
     4from aubio import fvec, cvec, pvoc, float_type
    55from numpy import array, shape
    66from numpy.random import random
     7import numpy as np
    78
    8 precision = 6
     9precision = 4
    910
    1011class aubio_pvoc_test_case(TestCase):
     
    3940            assert_equal ( r, 0)
    4041
    41     def test_resynth_two_steps(self):
    42         """ check the resynthesis of steps is correct with 50% overlap """
    43         hop_s = 512
    44         buf_s = hop_s * 2
     42    def test_resynth_8_steps(self):
     43        """ check the resynthesis of is correct with 87.5% overlap """
     44        hop_s = 256
     45        ratio = 8
     46        sigin = np.random.rand(hop_s).astype(float_type) * 2. - 1.
     47        buf_s = hop_s * ratio
    4548        f = pvoc(buf_s, hop_s)
    46         sigin = fvec(hop_s)
    4749        zeros = fvec(hop_s)
    48         # negative step
    49         sigin[20:50] = -.1
    50         # positive step
    51         sigin[100:200] = .1
    52         s1 = f(sigin)
    53         r1 = f.rdo(s1)
    54         s2 = f(zeros)
    55         r2 = f.rdo(s2)
    56         #self.plot_this ( s2.norm.T )
    57         assert_almost_equal ( r2, sigin, decimal = precision )
    58    
    59     def test_resynth_three_steps(self):
    60         """ check the resynthesis of steps is correct with 25% overlap """
    61         hop_s = 16
    62         buf_s = hop_s * 4
    63         sigin = fvec(hop_s)
     50        r2 = f.rdo( f(sigin) )
     51        for i in range(1, ratio):
     52            r2 = f.rdo( f(zeros) )
     53        r2 *= .5
     54        assert_almost_equal ( r2 - sigin, 0., decimal = precision )
     55
     56    def test_resynth_4_steps(self):
     57        """ check the resynthesis of is correct with 75% overlap """
     58        hop_s = 256
     59        ratio = 4
     60        sigin = np.random.rand(hop_s).astype(float_type) * 2. - 1.
     61        buf_s = hop_s * ratio
     62        f = pvoc(buf_s, hop_s)
    6463        zeros = fvec(hop_s)
    65         f = pvoc(buf_s, hop_s)
    66         for i in range(hop_s):
    67             sigin[i] = random() * 2. - 1.
    68         t2 = f.rdo( f(sigin) )
    69         t2 = f.rdo( f(zeros) )
    70         t2 = f.rdo( f(zeros) )
    71         t2 = f.rdo( f(zeros) )
    72         assert_almost_equal( sigin, t2, decimal = precision )
     64        r2 = f.rdo( f(sigin) )
     65        for i in range(1, ratio):
     66            r2 = f.rdo( f(zeros) )
     67        assert_almost_equal ( r2 - sigin, 0., decimal = precision )
    7368   
    7469    def plot_this( self, this ):
Note: See TracChangeset for help on using the changeset viewer.