File size: 1,928 Bytes
570b87b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env python3
"""Phase 0 demo: encode sources, rotate, iterative walk, print spatial summary."""

from __future__ import annotations

import sys
from pathlib import Path

import numpy as np

sys.path.insert(0, str(Path(__file__).resolve().parents[1]))

from hoa64 import (
    N_CHANNELS,
    channel_names,
    encode_points,
    mix,
    doa_from_intensity,
    peak_direction,
    field_energy,
    beamform,
)
from hoa64.rnn_stub import step_rotate, world_from_sources


def main() -> None:
    print(f"hoa64 Phase 0 — channels={N_CHANNELS}")
    print("names:", ", ".join(channel_names()[:9]), "...")

    # Two sources: front loud, rear quieter
    field = mix(
        encode_points([0.0], [0.0], [1.0]),
        encode_points([180.0], [20.0], [0.4]),
    )
    print(f"\nenergy={field_energy(field):.4f}")
    az, el = doa_from_intensity(field)
    print(f"intensity DOA: az={az:.1f}° el={el:.1f}°")
    paz, pel, pv = peak_direction(field)
    print(f"power peak:    az={paz:.1f}° el={pel:.1f}°  power={pv:.4f}")
    print(
        f"beam front={float(beamform(field, 0, 0)):.3f}  "
        f"rear={float(beamform(field, 180, 20)):.3f}"
    )

    # Iterative agent motion (order-3 dense for demo speed/quality balance)
    st = world_from_sources([0.0], [0.0], [1.0])
    print("\nRNN-stub walk: agent yaws +30° × 3 (order-3 field)")
    for i in range(3):
        st = step_rotate(st, d_yaw=30.0, max_order=3, dense=True)
        snap = st.history[-1]
        daz, del_ = snap["doa_intensity_az_el"]
        print(
            f"  step {i+1}: pose_yaw={st.yaw:.0f}°  "
            f"head-frame intensity DOA=({daz:.1f},{del_:.1f})  "
            f"E={snap['energy']:.4f}"
        )

    print("\nHypothesis check: geometry is formula-driven, state is 64-D, loop integrates pose.")
    print("Vision tower deferred. Audio encode/analyze/rotate path is live.")


if __name__ == "__main__":
    main()