Beispiel #1
0
    def test_audio_buffer_volume_filter(self):
        graph = Graph()
        self.link_nodes(
            graph.add_abuffer(
                format="fltp",
                sample_rate=48000,
                layout="stereo",
                time_base=Fraction(1, 48000),
            ),
            graph.add("volume", volume="0.5"),
            graph.add("abuffersink"),
        )
        graph.configure()

        input_frame = generate_audio_frame(0,
                                           input_format="fltp",
                                           layout="stereo",
                                           sample_rate=48000)
        graph.push(input_frame)

        out_frame = graph.pull()
        self.assertEqual(out_frame.format.name, "fltp")
        self.assertEqual(out_frame.layout.name, "stereo")
        self.assertEqual(out_frame.sample_rate, 48000)

        input_data = input_frame.to_ndarray()
        output_data = out_frame.to_ndarray()

        self.assertTrue(np.allclose(input_data * 0.5, output_data),
                        "Check that volume is reduced")
Beispiel #2
0
    def test_audio_buffer_resample(self):
        graph = Graph()
        self.link_nodes(
            graph.add_abuffer(
                format="fltp",
                sample_rate=48000,
                layout="stereo",
                time_base=Fraction(1, 48000),
            ),
            graph.add(
                "aformat",
                "sample_fmts=s16:sample_rates=44100:channel_layouts=stereo"),
            graph.add("abuffersink"),
        )
        graph.configure()

        graph.push(
            generate_audio_frame(0,
                                 input_format="fltp",
                                 layout="stereo",
                                 sample_rate=48000))
        out_frame = graph.pull()
        self.assertEqual(out_frame.format.name, "s16")
        self.assertEqual(out_frame.layout.name, "stereo")
        self.assertEqual(out_frame.sample_rate, 44100)
Beispiel #3
0
    def test_audio_buffer_sink(self):
        graph = Graph()
        audio_buffer = graph.add_abuffer(
            format="fltp",
            sample_rate=48000,
            layout="stereo",
            time_base=Fraction(1, 48000),
        )
        audio_buffer.link_to(graph.add("abuffersink"))
        graph.configure()

        try:
            graph.pull()
        except OSError as e:
            # we haven't pushed any input so expect no frames / EAGAIN
            if e.errno != errno.EAGAIN:
                raise
Beispiel #4
0
    def test_auto_find_sink(self):

        graph = Graph()
        src = graph.add('testsrc')
        src.link_to(graph.add('buffersink'))
        graph.configure()

        frame = graph.pull()
        frame.to_image().save('sandbox/mandelbrot3.png')
Beispiel #5
0
    def test_auto_find_sink(self):

        graph = Graph()
        src = graph.add('testsrc')
        src.link_to(graph.add('buffersink'))
        graph.configure()

        frame = graph.pull()
        frame.to_image().save('sandbox/mandelbrot3.png')
Beispiel #6
0
    def test_auto_find_sink(self):

        graph = Graph()
        src = graph.add("testsrc")
        src.link_to(graph.add("buffersink"))
        graph.configure()

        frame = graph.pull()

        if Image:
            frame.to_image().save(self.sandboxed("mandelbrot3.png"))