Exemple #1
0
    def test_resampling(self):
        sound = Sound.from_array([-0.4, -0.2, 0.0, 0.2, 0.4], 5)

        self.assertEqual(
            Resampling(9).apply(sound),
            Sound.from_array([-0.4, -0.3, -0.2, -0.1, 0.0, 0.1, 0.2, 0.3, 0.4],
                             9))

        self.assertEqual(
            Resampling(3).apply(sound), Sound.from_array([-0.4, 0.0, 0.4], 3))
Exemple #2
0
    def test_linear_fade_out(self):
        self.assertEqual(LinearFadeOut().apply(self.sound),
                         Sound.from_array([1.0, -0.75, 0.5, -0.25, 0.0], 1))

        self.assertEqual(
            LinearFadeOut(duration=2).apply(self.sound),
            Sound.from_array([1.0, -1.0, 1.0, -1.0, 0.0], 1))

        self.assertEqual(
            LinearFadeOut(duration=3).apply(self.sound),
            Sound.from_array([1.0, -1.0, 1.0, -0.5, 0.0], 1))
Exemple #3
0
    def test_same_samplerate(self):
        sound = Sound.from_sinwave(440, samplerate=44100)

        resample_to_same_rate = Resampling(sound.samplerate).apply(sound)

        self.assertIs(resample_to_same_rate, sound)
        self.assertTrue((resample_to_same_rate.data == sound.data).all())
Exemple #4
0
    def setUp(self):
        self.a = Sound.from_sinwave(100,
                                    duration=0.1,
                                    volume=1 / 3,
                                    samplerate=60000)

        self.b = Sound.from_sinwave(200,
                                    duration=0.1,
                                    volume=1 / 3,
                                    samplerate=60000)

        self.c = Sound.from_sinwave(300,
                                    duration=0.1,
                                    volume=1 / 3,
                                    samplerate=60000)

        self.ab = overlay(self.a, self.b)
        self.bc = overlay(self.b, self.c)
        self.abc = overlay(self.a, self.b, self.c)
Exemple #5
0
 def setUp(self):
     self.sound = Sound.from_array([1, -1, 1, -1, 1], 1)