def test_treble(self):
        """
        Test biquad treble filter, compare to SoX implementation
        """

        CENTRAL_FREQ = 1000
        Q = 0.707
        GAIN = 40

        noise_filepath = os.path.join(self.test_dirpath, "assets",
                                      "whitenoise.wav")
        E = torchaudio.sox_effects.SoxEffectsChain()
        E.set_input_file(noise_filepath)
        E.append_effect_to_chain("treble", [GAIN, CENTRAL_FREQ, str(Q) + 'q'])
        sox_output_waveform, sr = E.sox_build_flow_effects()

        waveform, sample_rate = torchaudio.load(noise_filepath,
                                                normalization=True)
        output_waveform = F.treble_biquad(waveform, sample_rate, GAIN,
                                          CENTRAL_FREQ, Q)

        torch.testing.assert_allclose(output_waveform,
                                      sox_output_waveform,
                                      atol=1e-4,
                                      rtol=1e-5)
Exemple #2
0
    def test_treble(self):
        central_freq = 1000
        q = 0.707
        gain = 40
        sample_rate = 8000

        data, path = self.get_whitenoise(sample_rate)
        result = F.treble_biquad(data, sample_rate, gain, central_freq, q)
        self.assert_sox_effect(result, path, ['treble', gain, central_freq, f'{q}q'])
    def test_treble(self):
        """
        Test biquad treble filter, compare to SoX implementation
        """

        central_freq = 1000
        q = 0.707
        gain = 40

        noise_filepath = common_utils.get_asset_path('whitenoise.wav')
        E = torchaudio.sox_effects.SoxEffectsChain()
        E.set_input_file(noise_filepath)
        E.append_effect_to_chain("treble", [gain, central_freq, str(q) + 'q'])
        sox_output_waveform, sr = E.sox_build_flow_effects()

        waveform, sample_rate = torchaudio.load(noise_filepath, normalization=True)
        output_waveform = F.treble_biquad(waveform, sample_rate, gain, central_freq, q)

        self.assertEqual(output_waveform, sox_output_waveform, atol=1e-4, rtol=1e-5)
    def test_treble(self):
        """
        Test biquad treble filter, compare to SoX implementation
        """

        central_freq = 1000
        q = 0.707
        gain = 40

        E = torchaudio.sox_effects.SoxEffectsChain()
        E.set_input_file(self.noise_filepath)
        E.append_effect_to_chain("treble", [gain, central_freq, str(q) + 'q'])
        sox_output_waveform, sr = E.sox_build_flow_effects()

        output_waveform = F.treble_biquad(self.noise_waveform,
                                          self.NOISE_SAMPLE_RATE, gain,
                                          central_freq, q)

        self.assertEqual(output_waveform,
                         sox_output_waveform,
                         atol=1e-4,
                         rtol=1e-5)
 def func(tensor):
     sample_rate = 44100
     gain = 40.
     central_freq = 1000.
     q = 0.707
     return F.treble_biquad(tensor, sample_rate, gain, central_freq, q)