Changeset 6937842


Ignore:
Timestamp:
Apr 28, 2016, 7:32:48 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:
98e9d69
Parents:
92a8800
Message:

python/tests/test_phasevoc.py: add more tests

File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/tests/test_phasevoc.py

    r92a8800 r6937842  
    4040            assert_equal ( r, 0)
    4141
     42    def test_resynth_8_steps_sine(self):
     43        """ check the resynthesis of is correct with 87.5% overlap """
     44        hop_s = 1024
     45        ratio = 8
     46        freq = 445; samplerate = 22050
     47        sigin = np.sin( 2. * np.pi * np.arange(hop_s).astype(float_type) * freq / samplerate)
     48        r2 = self.reconstruction( sigin, hop_s, ratio)
     49        error = ((r2 - sigin)**2).mean()
     50        self.assertLessEqual(error , 1.e-3)
     51
    4252    def test_resynth_8_steps(self):
    4353        """ check the resynthesis of is correct with 87.5% overlap """
    44         hop_s = 256
     54        hop_s = 1024
    4555        ratio = 8
    4656        sigin = np.random.rand(hop_s).astype(float_type) * 2. - 1.
     57        r2 = self.reconstruction( sigin, hop_s, ratio)
     58        error = ((r2 - sigin)**2).mean()
     59        self.assertLessEqual(error , 1.e-2)
     60
     61    def test_resynth_4_steps(self):
     62        """ check the resynthesis of is correct with 75% overlap """
     63        hop_s = 1024
     64        ratio = 4
     65        sigin = np.random.rand(hop_s).astype(float_type) * 2. - 1.
     66        r2 = self.reconstruction( sigin, hop_s, ratio)
     67        error = ((r2 - sigin)**2).mean()
     68        self.assertLessEqual(error , 1.e-2)
     69
     70    def reconstruction(self, sigin, hop_s, ratio):
    4771        buf_s = hop_s * ratio
    4872        f = pvoc(buf_s, hop_s)
     
    5175        for i in range(1, ratio):
    5276            r2 = f.rdo( f(zeros) )
    53         r2 *= .5
    54         assert_almost_equal ( r2 - sigin, 0., decimal = precision )
     77        return r2
    5578
    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)
    63         zeros = fvec(hop_s)
    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 )
    68    
    6979    def plot_this( self, this ):
    7080        from pylab import semilogy, show
Note: See TracChangeset for help on using the changeset viewer.