Changeset ac65a2f
- Timestamp:
- Apr 27, 2016, 8:47:31 PM (9 years ago)
- 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
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
python/tests/test_phasevoc.py
r1d0370a rac65a2f 2 2 3 3 from numpy.testing import TestCase, assert_equal, assert_almost_equal 4 from aubio import fvec, cvec, pvoc 4 from aubio import fvec, cvec, pvoc, float_type 5 5 from numpy import array, shape 6 6 from numpy.random import random 7 import numpy as np 7 8 8 precision = 69 precision = 4 9 10 10 11 class aubio_pvoc_test_case(TestCase): … … 39 40 assert_equal ( r, 0) 40 41 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 45 48 f = pvoc(buf_s, hop_s) 46 sigin = fvec(hop_s)47 49 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) 64 63 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 ) 73 68 74 69 def plot_this( self, this ):
Note: See TracChangeset
for help on using the changeset viewer.