Пример #1
0
 def test_hifreqs(self):
     # For those freq, downsample2 should return zero
     for freq in [36, 40, 56, 64]:
         x = pure_tone(freq, sr=128)
         y = resample._downsample2(x)
         y_gt = 0 * y
         self.assertSimilar(y, y_gt, x, f"freq={freq}")
Пример #2
0
 def test_lowfreqs(self):
     # For those freq, downsample2 should be almost decimation
     for freq in [8, 16, 20, 28]:
         x = pure_tone(freq, sr=128)
         y_gt = x[::2]
         y = resample._downsample2(x)
         self.assertSimilar(y, y_gt, x, f"freq={freq}")
Пример #3
0
 def test_mixture(self):
     # Test one mixture
     x_low = pure_tone(16, sr=128)
     x_high = pure_tone(40, sr=128)
     x = x_low + x_high
     y = resample._downsample2(x)
     y_gt = x_low[::2]
     self.assertSimilar(y, y_gt, x, "mixture")
Пример #4
0
 def test_ref(self):
     # Compare to _upsample2 and _downsample2
     for freq in [8, 16, 20, 28, 32, 36, 40, 56, 64]:
         x = pure_tone(freq, sr=128)
         y_gt_down = resample._downsample2(x)
         y_down = resample.resample_frac(x, 2, 1, rolloff=1)
         self.assertSimilar(y_down, y_gt_down, x, f"freq={freq} down")
         y_gt_up = resample._upsample2(x)
         y_up = resample.resample_frac(x, 1, 2, rolloff=1)
         self.assertSimilar(y_up, y_gt_up, x, f"freq={freq} up")