Exemplo n.º 1
0
def offline_settings():
    resonant.SAMPLING_RATE = 3
    resonant.NUM_MICS = 3
    resonant.MIC_POSITIONS = [
        SphericalPt(1, 0, 0),
        SphericalPt(1, 2 * math.pi / 3, 0),
        SphericalPt(1, 4 * math.pi / 3, 0)
    ]
Exemplo n.º 2
0
    def test_delay_from_source(self, mic_fixture):
        signal = np.array([1, 1, 1, 2, 2])

        # 2d first, top left corner of square first
        angle = math.pi / 4
        microphone: Mic = mic_fixture(signal)
        microphone.position = SphericalPt(1, math.pi / 4, 0)
        src = SphericalPt(1, math.pi / 4, 0)

        expected = 1 / resonant.V_SOUND
        assert microphone.delay_from_source(src) == expected
Exemplo n.º 3
0
def test_interpolation(signal, expected):
    resonant.INTERPOLATION_AMOUNT = 1
    signal = np.array(signal)
    mic = Mic(signal, SphericalPt(1, 0, 0))

    algo = Algorithm([mic])
    result = algo.interpolate_signals([signal])
    assert result[0].tolist() == np.array(expected).tolist()
Exemplo n.º 4
0
    def __init__(self, polar_angle, audio: np.ndarray):
        self.id = None
        self.position: SphericalPt = SphericalPt.angle_only(polar_angle)
        self.name = ""  # TODO FIX

        temp_arr = np.empty(resonant.MAX_ML_SAMPLES)
        temp_arr[:] = np.nan
        self.audio = push_array(audio, temp_arr)
        self.cycles_lived = 0
        self.cycles_to_live = resonant.CYCLES_TO_LIVE
Exemplo n.º 5
0
def sources():
    empty_audio = np.zeros(5)
    resonant.SOURCE_MARGIN = SphericalPt.angle_only(5)
    resonant.MAX_ML_SAMPLES = 8
    resonant.MIN_ML_SAMPLES = 6

    sources = [
        Source(30, empty_audio),
        Source(88, empty_audio),
    ]
    return sources
Exemplo n.º 6
0
 def mic(signal):
     src = SphericalPt(1, math.pi / 4, math.pi / 4)
     return Mic(signal, src)
Exemplo n.º 7
0
 def test_to_cartesian(self):
     cartesian_coords = (3, 4, 5)
     spherical_coords = (7.0710678118655, 0.92729521800161,
                         math.pi/2 - 0.78539816339745)
     assert pytest.approx(SphericalPt(
         *spherical_coords).to_cartesian()) == cartesian_coords
Exemplo n.º 8
0
    def test_within_margin(self):
        origin = SphericalPt(1, 0, 0)
        margin = SphericalPt(1, 5, 4)

        # Test polar
        polar_inside = SphericalPt(1, 3, 0)
        assert origin.within_margin(margin, polar_inside) is True

        polar_outside = SphericalPt(1, 6.1, 0)
        polar_outside_neg = SphericalPt(1, -6.1, 0)
        assert origin.within_margin(margin, polar_outside) is False
        assert origin.within_margin(margin, polar_outside_neg) is False

        # Test azimuth
        polar_inside = SphericalPt(1, 0, 3)
        assert origin.within_margin(margin, polar_inside) is True

        polar_outside = SphericalPt(1, 0, 4.1)
        polar_outside_neg = SphericalPt(1, 0, -4.1)
        assert origin.within_margin(margin, polar_outside) is False
        assert origin.within_margin(margin, polar_outside_neg) is False
Exemplo n.º 9
0
 def test_copy(self):
     pt = SphericalPt(1, 2, 3)
     assert SphericalPt.copy(pt) == pt