Пример #1
0
    def read_block_mono_test(self):
        wfile, infos = wav.open_read_mode(STEPS_MONO_16B)
        samples = wav.read_block(wfile, 4410)

        self.assertEqual(samples.shape, (4410, 1))
        self.assertEqual(infos['frame_rate'], 44100)
        self.assertEqual(infos['channel_count'], 1)

        expected = numpy.ones([4410, 1]) * -1
        numpy.testing.assert_array_equal(expected.round(3), samples.round(3))
Пример #2
0
    def read_block_mono_test(self):
        wfile, infos = wav.open_read_mode(STEPS_MONO_16B)
        samples = wav.read_block(wfile, 4410)

        self.assertEqual(samples.shape, (4410, 1))
        self.assertEqual(infos['frame_rate'], 44100)
        self.assertEqual(infos['channel_count'], 1)

        expected = numpy.ones([4410, 1]) * -1
        numpy.testing.assert_array_equal(expected.round(3), samples.round(3))
Пример #3
0
    def seek_and_read_mono_block_test(self):
        wfile, infos = wav.open_read_mode(STEPS_MONO_16B)
        frames = wav.seek(wfile, 0.4, 0.5)
        samples = wav.read_block(wfile, 100)

        self.assertEqual(frames, numpy.round((0.5 - 0.4) * 44100, 6))
        self.assertEqual(samples.shape, (100, 1))
        self.assertEqual(infos['frame_rate'], 44100)
        self.assertEqual(infos['channel_count'], 1)

        expected = numpy.ones([100, 1]) * -0.6
        numpy.testing.assert_array_equal(expected.round(3), samples.round(3))
Пример #4
0
    def seek_and_read_mono_block_test(self):
        wfile, infos = wav.open_read_mode(STEPS_MONO_16B)
        frames = wav.seek(wfile, 0.4, 0.5)
        samples = wav.read_block(wfile, 100)

        self.assertEqual(frames, numpy.round((0.5 - 0.4) * 44100, 6))
        self.assertEqual(samples.shape, (100, 1))
        self.assertEqual(infos['frame_rate'], 44100)
        self.assertEqual(infos['channel_count'], 1)

        expected = numpy.ones([100, 1]) * -0.6
        numpy.testing.assert_array_equal(expected.round(3), samples.round(3))
Пример #5
0
    def seek_and_read_stereo_block_test(self):
        wfile, infos = wav.open_read_mode(STEPS_STEREO_16B)
        frames = wav.seek(wfile, 0.6)
        samples = wav.read_block(wfile, 100)

        self.assertEqual(frames, (infos['duration'] - 0.6) * 44100)
        self.assertEqual(samples.shape, (100, 2))
        self.assertEqual(infos['frame_rate'], 44100)
        self.assertEqual(infos['channel_count'], 2)

        expected = numpy.ones([100, 2])
        expected[:, 0] *= -0.4
        expected[:, 1] *= 0.4
        numpy.testing.assert_array_equal(expected.round(3), samples.round(3))
Пример #6
0
    def seek_and_read_stereo_block_test(self):
        wfile, infos = wav.open_read_mode(STEPS_STEREO_16B)
        frames = wav.seek(wfile, 0.6)
        samples = wav.read_block(wfile, 100)

        self.assertEqual(frames, (infos['duration'] - 0.6) * 44100)
        self.assertEqual(samples.shape, (100, 2))
        self.assertEqual(infos['frame_rate'], 44100)
        self.assertEqual(infos['channel_count'], 2)

        expected = numpy.ones([100, 2])
        expected[:, 0] *= -0.4
        expected[:, 1] *= 0.4
        numpy.testing.assert_array_equal(expected.round(3), samples.round(3))