Beispiel #1
0
 def test_can_phase_shift_2d_signal(self):
     samplerate = SR22050()
     samples = SineSynthesizer(samplerate) \
         .synthesize(Milliseconds(2500), [220, 440, 880])
     windowsize = TimeSlice(duration=Milliseconds(200))
     stepsize = TimeSlice(duration=Milliseconds(100))
     _, windowed = samples.sliding_window_with_leftovers(
         windowsize=windowsize, stepsize=stepsize, dopad=True)
     coeffs = fft(windowed)
     shifted = phase_shift(coeffs, samplerate, Milliseconds(40))
     synth = FFTSynthesizer()
     new_samples = synth.synthesize(shifted).squeeze()
     self.assertNotEqual(0, self._mean_squared_error(samples, new_samples))
Beispiel #2
0
 def test_can_phase_shift_2d_signal(self):
     samplerate = SR22050()
     samples = SineSynthesizer(samplerate) \
         .synthesize(Milliseconds(2500), [220, 440, 880])
     windowsize = TimeSlice(duration=Milliseconds(200))
     stepsize = TimeSlice(duration=Milliseconds(100))
     _, windowed = samples.sliding_window_with_leftovers(
         windowsize=windowsize, stepsize=stepsize, dopad=True)
     coeffs = fft(windowed)
     shifted = phase_shift(coeffs, samplerate, Milliseconds(40))
     synth = FFTSynthesizer()
     new_samples = synth.synthesize(shifted).squeeze()
     self.assertNotEqual(0, self._mean_squared_error(samples, new_samples))
Beispiel #3
0
 def test_2d_phase_shift_returns_correct_shape(self):
     samplerate = SR22050()
     samples = SineSynthesizer(samplerate) \
         .synthesize(Milliseconds(2500), [220, 440, 880])
     windowsize = TimeSlice(duration=Milliseconds(200))
     stepsize = TimeSlice(duration=Milliseconds(100))
     _, windowed = samples.sliding_window_with_leftovers(
         windowsize=windowsize, stepsize=stepsize, dopad=True)
     coeffs = fft(windowed)
     shifted = phase_shift(coeffs=coeffs,
                           samplerate=samplerate,
                           time_shift=Milliseconds(40),
                           frequency_band=FrequencyBand(50, 5000))
     self.assertEqual(coeffs.shape, shifted.shape)
Beispiel #4
0
 def test_2d_phase_shift_returns_correct_shape(self):
     samplerate = SR22050()
     samples = SineSynthesizer(samplerate) \
         .synthesize(Milliseconds(2500), [220, 440, 880])
     windowsize = TimeSlice(duration=Milliseconds(200))
     stepsize = TimeSlice(duration=Milliseconds(100))
     _, windowed = samples.sliding_window_with_leftovers(
         windowsize=windowsize, stepsize=stepsize, dopad=True)
     coeffs = fft(windowed)
     shifted = phase_shift(
         coeffs=coeffs,
         samplerate=samplerate,
         time_shift=Milliseconds(40),
         frequency_band=FrequencyBand(50, 5000))
     self.assertEqual(coeffs.shape, shifted.shape)