Skip to content

the ultimate vocal synthesizer - sing, speak, beatbox, and more

Rust

Body: the presets and the triangle move into the head's header (the top bar wrapped at 1440 px)

Jameson Hodge8b59189605eb
diff --git a/src/ui/App.tsx b/src/ui/App.tsx
index e9c60a5..3263409 100644
--- a/src/ui/App.tsx
+++ b/src/ui/App.tsx
@@ -20,7 +20,7 @@ import { playDemo, DEMO_SONGS } from "./singing.ts";
import type { Mode } from "./store.ts";
import type { BodyName } from "../worklet/protocol.ts";
import { BodyPad } from "./components/BodyPad.tsx";
-import { bodyLabel, presetOf, PRESETS } from "./body.ts";
+import { presetOf, PRESETS } from "./body.ts";
// three.js only loads when the 3D view is first shown
const AnatomyView3D = lazy(() => import("./components/AnatomyView3D.tsx").then((m) => ({ default: m.AnatomyView3D })));
@@ -37,8 +37,6 @@ function TopBar() {
const started = useStore((s) => s.started);
const starting = useStore((s) => s.starting);
const start = useStore((s) => s.start);
- const body = useStore((s) => s.body);
- const setBody = useStore((s) => s.setBody);
const volume = useStore((s) => s.volume);
const setVolume = useStore((s) => s.setVolume);
const mode = useStore((s) => s.mode);
@@ -66,21 +64,6 @@ function TopBar() {
{ value: "beatbox", label: "Beatbox" },
]}
/>
- {mode !== "bestiary" && (
- <div className="body-control">
- <Segmented<BodyName>
- label="Body"
- value={presetOf(body)}
- onChange={(b) => setBody(PRESETS[b])}
- options={[
- { value: "male", label: "Male" },
- { value: "female", label: "Female" },
- { value: "child", label: "Child" },
- ]}
- />
- <BodyPad />
- </div>
- )}
<div className="topbar-right">
<label className="volume">
<span>Volume</span>
@@ -163,22 +146,35 @@ function StartPrompt() {
);
}
-/** The tall left screen: the face (or the creature) with its overlays. */
+/** The body, in the head's header: three presets and the triangle between them. */
+function BodyControl() {
+ const body = useStore((s) => s.body);
+ const setBody = useStore((s) => s.setBody);
+ return (
+ <div className="body-control">
+ <Segmented<BodyName>
+ label="Body"
+ value={presetOf(body)}
+ onChange={(b) => setBody(PRESETS[b])}
+ options={[
+ { value: "male", label: "Male" },
+ { value: "female", label: "Female" },
+ { value: "child", label: "Child" },
+ ]}
+ />
+ <BodyPad />
+ </div>
+ );
+}
+
+/** The tall left screen: the face (or the creature) with its overlays. No title: it shows itself. */
function LeftScreen() {
const mode = useStore((s) => s.mode);
- const body = useStore((s) => s.body);
const threeD = useStore((s) => s.view.threeD);
const bestiary = mode === "bestiary";
const Face = threeD ? AnatomyView3D : AnatomyView;
return (
- <Screen
- className="left"
- focus
- title={bestiary ? "Creature" : "Vocal tract"}
- sub={bestiary ? "Airway / live" : `${bodyLabel(body)} / ${threeD ? "3D" : "midsagittal"}`}
- label={bestiary ? "Live creature airway" : "Live vocal tract"}
- tools={<ViewToggles />}
- >
+ <Screen className="left" focus lead={bestiary ? undefined : <BodyControl />} label={bestiary ? "Live creature airway" : "Live vocal tract"} tools={<ViewToggles />}>
<Suspense fallback={null}>
{bestiary ? <CreatureView /> : mode === "speak" ? <Face slots={speechSlots} info={speechInfo} overlay={speechWords} /> : mode === "sing" ? <Face info={singInfo} overlay={singWords} /> : mode === "beatbox" ? <Face slots={beatSlots} info={beatInfo} showFormants={false} /> : <Face />}
</Suspense>
diff --git a/src/ui/components/Screen.tsx b/src/ui/components/Screen.tsx
index 8852c5b..1599928 100644
--- a/src/ui/components/Screen.tsx
+++ b/src/ui/components/Screen.tsx
@@ -3,16 +3,21 @@ import type { ButtonHTMLAttributes, ReactNode } from "react";
/**
* One screen on the wall: a black panel with a thin frame and a single-stroke title.
* The body always has a positive size (see .screen-body in styles.css); canvases fill it.
+ * A screen whose content names itself (the head) has no title: `lead` takes its place in the
+ * header, and `label` names the screen for assistive tech.
*/
-export function Screen(props: { title: string; sub?: string; focus?: boolean; className?: string; tools?: ReactNode; children: ReactNode; label?: string }) {
- const { title, sub, focus, className, tools, children, label } = props;
+export function Screen(props: { title?: string; sub?: string; lead?: ReactNode; focus?: boolean; className?: string; tools?: ReactNode; children: ReactNode; label?: string }) {
+ const { title, sub, lead, focus, className, tools, children, label } = props;
return (
<section className={`screen${focus ? " focus" : ""}${className ? " " + className : ""}`} aria-label={label ?? title}>
- <header className="screen-head">
- <h2 className="screen-title">{title}</h2>
- {sub && <span className="screen-sub">{sub}</span>}
- {tools && <div className="screen-tools">{tools}</div>}
- </header>
+ {(title || lead || sub || tools) && (
+ <header className="screen-head">
+ {title && <h2 className="screen-title">{title}</h2>}
+ {lead}
+ {sub && <span className="screen-sub">{sub}</span>}
+ {tools && <div className="screen-tools">{tools}</div>}
+ </header>
+ )}
<div className="screen-body">{children}</div>
</section>
);
diff --git a/src/ui/styles.css b/src/ui/styles.css
index 2499d47..a0157a2 100644
--- a/src/ui/styles.css
+++ b/src/ui/styles.css
@@ -1348,6 +1348,17 @@ button.ghost:hover,
white-space: nowrap;
}
+/* the body, in the head's header */
+.left .screen-head {
+ align-items: center;
+ padding-top: 8px;
+}
+
+.left .body-control .segmented button {
+ padding: 2px 9px;
+ font-size: 10px;
+}
+
/* ---------- a screen */
.screen {
position: relative;