code wiki / (root) / nx_synth_serve.nx

nx_synth_serve.nx

buildroot/runtime/nx_synth_serve.nx

21872 B344 linesdepth 7pulls 16 transitivereach 2 importersview sourcekind librarytopic synth
docsdependenciesstructsconstsfunctions

about

nx_synth_serve.nx -- the INTERACTIVE SYNTH STUDIO (all functionality LIVE): one loopback HTTP daemon that serves the studio page + renders on demand. Type a caption -> neural text2motion clip; pick a move -> clip; choose swap slots -> a creature still. Mounted behind the site proxy at /synth. Routes: GET /synth or / -> the studio SPA GET /synth/health -> {"ok":1} POST /synth/api/text2motion body = caption text -> APNG (neural: learned encoder -> class -> tokens) GET /synth/api/move?id=1..6 -> APNG (parametric move) POST /synth/api/variant?sp&hv&ev&tv&build -> PNG still (swap-slot creature, skinned raymarch) Forks per connection (heavy render mmaps reclaimed on child exit). Composes the proven synth organs; nothing new in the render math. license_tier: ORIGINAL

dependencies 12 imports · 2 importers

nx_syscalls.nx nx_skeleton.nx nx_figure_render.nx nx_movelib.nx nx_motion_neural.nx nx_text2motion.nx nx_assetvariant.nx nx_apng.nx nx_png.nx nx_pose_coach.nx nx_synth_serve.nx nx_synth_serve_daemon.nx nx_synth_serve_gate.nx

diagram shows first 10 each side; +2 more imports, +0 more importers in the complete lists below.

imports: nx_syscalls.nxnx_skeleton.nxnx_figure_render.nxnx_movelib.nxnx_motion_neural.nxnx_text2motion.nxnx_assetvariant.nxnx_apng.nxnx_png.nxnx_pose_coach.nxnx_lipsync.nxnx_outfit.nx

imported by: nx_synth_serve_daemon.nxnx_synth_serve_gate.nx

structs

none

consts

93const SV_W: i64 = 128
94const SV_H: i64 = 96
202const VR_W: i64 = 160
203const VR_H: i64 = 120
204const VR_FOCAL: i64 = 183 // 586*160/512
245const SVC_T: i64 = 16
246const SVC_NJ: i64 = 3
286const TK_W: i64 = 96
287const TK_H: i64 = 96
315const STUDIO_HTML: *u8 = "<!doctype html><meta charset=utf-8><meta name=viewport content=\"width=device-width,initial-scale=1\"><title>Synth Studio</title><style>body{font-family:system-ui,sans-serif;max-width:860px;margin:2vh auto;padding:0 16px;background:#151118;color:#eae3da}h1{font-size:1.35rem}h1 em{color:#e6a582;font-style:normal}h2{font-size:.95rem;color:#a094aa;margin:26px 0 8px;text-transform:uppercase;letter-spacing:.1em}.card{background:#1f1a24;border:1px solid #372f3e;border-radius:10px;padding:16px;margin:10px 0}input,select,button{font:inherit;padding:9px 12px;border-radius:7px;border:1px solid #372f3e;background:#121019;color:#eae3da}button{background:#e6a582;color:#1b1418;border:0;cursor:pointer;font-weight:600}#cap{width:60%}.out img{max-width:100%;image-rendering:pixelated;border-radius:6px;background:#0c0a10;margin-top:10px}label{font-size:.82rem;color:#a094aa;margin-right:6px}.row{display:flex;gap:8px;flex-wrap:wrap;align-items:center}a{color:#e6a582}</style><h1>Synth Studio &mdash; <em>type it, watch it move</em></h1><div class=card><h2>Text &rarr; motion (neural)</h2><div class=row><input id=cap placeholder=\"e.g. say hello with a wave\" value=\"say hello with a wave\"><button onclick=t2m()>Generate</button></div><div class=out id=o1></div></div><div class=card><h2>Named move</h2><div class=row><select id=mv><option value=1>wave</option><option value=2>cheer</option><option value=3>sway</option><option value=4>kick</option><option value=5>lookaround</option><option value=6>armcircle</option></select><button onclick=mv()>Play</button></div><div class=out id=o2></div></div><div class=card><h2>Creature (swap slots)</h2><div class=row><label>species</label><select id=sp><option value=0>human</option><option value=1>wolf</option><option value=2>goblin</option></select><label>head</label><select id=hv><option value=0>plain</option><option value=1>horns</option><option value=2>snout</option></select><label>ears</label><select id=ev><option value=1>pointed</option><option value=0>none</option></select><label>tail</label><select id=tv><option value=0>none</option><option value=1>tail</option></select><label>build</label><input id=bd type=number value=100 min=70 max=140 style=width:70px><button onclick=vr()>Render</button></div><div class=out id=o3></div></div><div class=card><h2>Download meshes</h2><p>STL: <a href=/synth/human.stl download>human</a> &middot; <a href=/synth/wolf.stl download>wolf</a> &middot; <a href=/synth/goblin.stl download>goblin</a> &nbsp; OBJ: <a href=/synth/human.obj download>human</a> &middot; <a href=/synth/wolf.obj download>wolf</a></p></div><script>function t2m(){var c=document.getElementById('cap').value;document.getElementById('o1').innerHTML='...';fetch('/synth/api/text2motion',{method:'POST',body:c}).then(function(r){return r.blob()}).then(function(b){document.getElementById('o1').innerHTML='<img src='+URL.createObjectURL(b)+'>'})}\nfunction mv(){var i=document.getElementById('mv').value;document.getElementById('o2').innerHTML='...';fetch('/synth/api/move?id='+i).then(function(r){return r.blob()}).then(function(b){document.getElementById('o2').innerHTML='<img src='+URL.createObjectURL(b)+'>'})}\nfunction vr(){var q='sp='+document.getElementById('sp').value+'&hv='+document.getElementById('hv').value+'&ev='+document.getElementById('ev').value+'&tv='+document.getElementById('tv').value+'&build='+document.getElementById('bd').value;document.getElementById('o3').innerHTML='...';fetch('/synth/api/variant?'+q,{method:'POST'}).then(function(r){return r.blob()}).then(function(b){document.getElementById('o3').innerHTML='<img src='+URL.createObjectURL(b)+'>'})}</script>" as *u8

functions

25func sv_slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
26func sv_itoa(dst: *u8, off: i64, v: i64) -> i64 { let t: *u8=sys_mmap(28); var m: i64=v; var k: i64=0; if m==0{t[0]=48 as u8;k=1} while m>0{t[k]=(48+(m%10)) as u8;m=m/10;k=k+1} var o: i64=off; var q: i64=k-1; while q>=0{dst[o]=t[q];o=o+1;q=q-1} return o }
27func sv_cat(dst: *u8, off: i64, s: *u8) -> i64 { var o: i64=off; var i: i64=0; while s[i]!=(0 as u8){dst[o]=s[i]; o=o+1; i=i+1} return o }
28func sv_catb(dst: *u8, off: i64, src: *u8, n: i64) -> i64 { var o: i64=off; var i: i64=0; while i<n {dst[o]=src[i]; o=o+1; i=i+1} return o }
called by 1: sv_send
29func sv_starts(buf: *u8, n: i64, pre: *u8) -> i64 { var i: i64=0; while pre[i]!=(0 as u8){ if i>=n {return 0} if buf[i]!=pre[i]{return 0} i=i+1 } return 1 }
called by 1: sv_serve_conn
30func sv_find_seq(buf: *u8, n: i64, needle: *u8, nl: i64) -> i64 { if nl==0 {return 0} var i: i64=0; while i+nl<=n { var j: i64=0; var ok: i64=1; while j<nl { if buf[i+j]!=needle[j]{ok=0; j=nl} else {j=j+1} } if ok==1 {return i} i=i+1 } return 0-1 }
31func sv_send(cfd: i64, status: *u8, ctype: *u8, body: *u8, blen: i64) -> i64
40func sv_send_bin(cfd: i64, ctype: *u8, body: *u8, blen: i64) -> i64
50func sv_hdr_int(req: *u8, hend: i64, name: *u8, nl: i64) -> i64
called by 1: sv_read_full calls 1: sv_find_seq
57func sv_read_full(cfd: i64, req: *u8, cap: i64) -> i64
65func sv_reqpath(req: *u8, rn: i64, out: *u8, cap: i64) -> i64
called by 1: sv_serve_conn
74func sv_qint(path: *u8, pn: i64, name: *u8, dflt: i64) -> i64
97func sv_do_text2motion(cfd: i64, body: *u8, bn: i64) -> i64
174func sv_do_move(cfd: i64, path: *u8, pn: i64) -> i64
205func sv_do_variant(cfd: i64, path: *u8, pn: i64) -> i64
247func svc_jname(j: i64) -> *u8 { if j == 0 { return "shoulder" as *u8 } if j == 1 { return "elbow" as *u8 } return "wrist" as *u8 }
called by 1: sv_do_coach
248func svc_track(sk: i64, track: *i64, elbowdeg: i64) -> i64
263func sv_do_coach(cfd: i64, path: *u8, pn: i64) -> i64
288func sv_do_talk(cfd: i64, body: *u8, bn: i64) -> i64
317func sv_serve_conn(cfd: i64) -> i64