4 def test_noise_setup(sounddevice
, numpy
):
5 from enviroplus
.noise
import Noise
7 noise
= Noise(sample_rate
=16000, duration
=0.1)
11 def test_noise_get_amplitudes_at_frequency_ranges(sounddevice
, numpy
):
12 from enviroplus
.noise
import Noise
14 noise
= Noise(sample_rate
=16000, duration
=0.1)
15 noise
.get_amplitudes_at_frequency_ranges([
20 sounddevice
.rec
.assert_called_with(0.1 * 16000, samplerate
=16000, blocking
=True, channels
=1, dtype
='float64')
23 def test_noise_get_noise_profile(sounddevice
, numpy
):
24 from enviroplus
.noise
import Noise
26 numpy
.mean
.return_value
= 10.0
28 noise
= Noise(sample_rate
=16000, duration
=0.1)
29 amp_low
, amp_mid
, amp_high
, amp_total
= noise
.get_noise_profile(
35 sounddevice
.rec
.assert_called_with(0.1 * 16000, samplerate
=16000, blocking
=True, channels
=1, dtype
='float64')
37 assert amp_total
== 10.0
40 def test_get_amplitude_at_frequency_range(sounddevice
, numpy
):
41 from enviroplus
.noise
import Noise
43 noise
= Noise(sample_rate
=16000, duration
=0.1)
45 noise
.get_amplitude_at_frequency_range(0, 8000)
47 with pytest
.raises(ValueError):
48 noise
.get_amplitude_at_frequency_range(0, 16000)