assert_equal ( s.phas, 0)
assert_equal ( r, 0)
+ def test_resynth_8_steps_sine(self):
+ """ check the resynthesis of is correct with 87.5% overlap """
+ hop_s = 1024
+ ratio = 8
+ freq = 445; samplerate = 22050
+ sigin = np.sin( 2. * np.pi * np.arange(hop_s).astype(float_type) * freq / samplerate)
+ r2 = self.reconstruction( sigin, hop_s, ratio)
+ error = ((r2 - sigin)**2).mean()
+ self.assertLessEqual(error , 1.e-3)
+
def test_resynth_8_steps(self):
""" check the resynthesis of is correct with 87.5% overlap """
- hop_s = 256
+ hop_s = 1024
ratio = 8
sigin = np.random.rand(hop_s).astype(float_type) * 2. - 1.
- buf_s = hop_s * ratio
- f = pvoc(buf_s, hop_s)
- zeros = fvec(hop_s)
- r2 = f.rdo( f(sigin) )
- for i in range(1, ratio):
- r2 = f.rdo( f(zeros) )
- r2 *= .5
- assert_almost_equal ( r2 - sigin, 0., decimal = precision )
+ r2 = self.reconstruction( sigin, hop_s, ratio)
+ error = ((r2 - sigin)**2).mean()
+ self.assertLessEqual(error , 1.e-2)
def test_resynth_4_steps(self):
""" check the resynthesis of is correct with 75% overlap """
- hop_s = 256
+ hop_s = 1024
ratio = 4
sigin = np.random.rand(hop_s).astype(float_type) * 2. - 1.
+ r2 = self.reconstruction( sigin, hop_s, ratio)
+ error = ((r2 - sigin)**2).mean()
+ self.assertLessEqual(error , 1.e-2)
+
+ def reconstruction(self, sigin, hop_s, ratio):
buf_s = hop_s * ratio
f = pvoc(buf_s, hop_s)
zeros = fvec(hop_s)
r2 = f.rdo( f(sigin) )
for i in range(1, ratio):
r2 = f.rdo( f(zeros) )
- assert_almost_equal ( r2 - sigin, 0., decimal = precision )
-
+ return r2
+
def plot_this( self, this ):
from pylab import semilogy, show
semilogy ( this )