Skip to content

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

Rust

Keys: MIDI is a chip in the keys screen's header (it was the biggest button on the page)

Jameson Hodge288acb6d1653
diff --git a/src/ui/App.tsx b/src/ui/App.tsx
index 8f8da74..e9c60a5 100644
--- a/src/ui/App.tsx
+++ b/src/ui/App.tsx
@@ -7,7 +7,7 @@ import { Stroboscope } from "./components/Stroboscope.tsx";
import { SpectrumView } from "./components/SpectrumView.tsx";
import { VowelMap } from "./components/VowelMap.tsx";
import { VoiceControls, VoiceToggles } from "./components/VoiceControls.tsx";
-import { Keys } from "./components/Keys.tsx";
+import { Keys, MidiButton } from "./components/Keys.tsx";
import { Segmented, Toggle } from "./components/Controls.tsx";
import { Screen } from "./components/Screen.tsx";
import { SpeakRight, speechInfo, speechSlots, speechWords } from "./components/SpeakPanel.tsx";
@@ -207,7 +207,7 @@ function PlayRight() {
<Screen className="s-voice" title="Voice" tools={<VoiceToggles />}>
<VoiceControls />
</Screen>
- <Screen className="s-keys" title="Keys" sub={`${Math.round(f0)} Hz`}>
+ <Screen className="s-keys" title="Keys" sub={`${Math.round(f0)} Hz`} tools={<MidiButton />}>
<Keys />
</Screen>
</div>
diff --git a/src/ui/components/BeatboxPanel.tsx b/src/ui/components/BeatboxPanel.tsx
index 5f98cb4..8213f01 100644
--- a/src/ui/components/BeatboxPanel.tsx
+++ b/src/ui/components/BeatboxPanel.tsx
@@ -2,7 +2,7 @@ import { useEffect, useRef, useState } from "react";
import { useStore } from "../store.ts";
import { engine } from "../../audio/AudioEngine.ts";
import { BEAT_SOUNDS, BEAT_PRESETS, formatBeat, parseBeat, type Airstream } from "../../wasm/engine.ts";
-import { Keys } from "./Keys.tsx";
+import { Keys, MidiButton } from "./Keys.tsx";
import { Chip, Screen } from "./Screen.tsx";
import { EncoderPages } from "./Encoder.tsx";
import { Spectrogram } from "./Spectrogram.tsx";
@@ -217,7 +217,7 @@ export function BeatboxRight() {
<Screen className="s-transport" title="Transport">
<Transport />
</Screen>
- <Screen className="s-keys s-keys-compact" title="Keys" sub="Hum a bass note">
+ <Screen className="s-keys s-keys-compact" title="Keys" sub="Hum a bass note" tools={<MidiButton />}>
<Keys />
</Screen>
</div>
diff --git a/src/ui/components/BestiaryPanel.tsx b/src/ui/components/BestiaryPanel.tsx
index d70a72b..c73a0a1 100644
--- a/src/ui/components/BestiaryPanel.tsx
+++ b/src/ui/components/BestiaryPanel.tsx
@@ -3,7 +3,7 @@ import { useStore } from "../store.ts";
import { CREATURES, creatureById } from "../../wasm/engine.ts";
import type { CreatureDef } from "../../wasm/types.ts";
import { useLiveCreature } from "../creatureLive.ts";
-import { Keys } from "./Keys.tsx";
+import { Keys, MidiButton } from "./Keys.tsx";
import { Chip, Screen } from "./Screen.tsx";
import { EncoderPages, type EncoderPage } from "./Encoder.tsx";
import { Spectrogram } from "./Spectrogram.tsx";
@@ -128,7 +128,7 @@ export function BestiaryRight() {
<Screen className="s-airway" title="Airway" sub="Each tube unrolled">
<CreatureTubes />
</Screen>
- <Screen className="s-keys s-keys-compact" title="Keys" sub="The held voice or a call, at the key's pitch">
+ <Screen className="s-keys s-keys-compact" title="Keys" sub="The held voice or a call, at the key's pitch" tools={<MidiButton />}>
<Keys />
</Screen>
</div>
diff --git a/src/ui/components/Keys.tsx b/src/ui/components/Keys.tsx
index b053b04..dd935a4 100644
--- a/src/ui/components/Keys.tsx
+++ b/src/ui/components/Keys.tsx
@@ -2,6 +2,7 @@ import { useEffect, useRef, useState } from "react";
import { useStore } from "../store.ts";
import { midiSupported } from "../midi.ts";
import { nearestBody, type BodyMix } from "../body.ts";
+import { Chip } from "./Screen.tsx";
/** Computer-keyboard layout: two rows like a piano (A W S E D F T G Y H U J K O L P ;). */
const KEYMAP: Record<string, number> = { a: 0, w: 1, s: 2, e: 3, d: 4, f: 5, t: 6, g: 7, y: 8, h: 9, u: 10, j: 11, k: 12, o: 13, l: 14, p: 15, ";": 16 };
@@ -88,7 +89,6 @@ export function Keys() {
};
return (
<div className="keys-row">
- <MidiButton />
<div className="keys" data-layout="layered" aria-label="Keyboard. Computer keys A to semicolon play notes; Z and X change octave.">
<div className="white-row">
{whites.map((m) => (
@@ -109,8 +109,8 @@ export function Keys() {
);
}
-/** Connect a MIDI keyboard (any mode with keys); shows what is connected. */
-function MidiButton() {
+/** Connect a MIDI keyboard (a chip in the keys screen's header); says what is connected. */
+export function MidiButton() {
const midi = useStore((s) => s.midi);
const setMidi = useStore((s) => s.setMidi);
if (!midiSupported()) return null;
@@ -126,9 +126,8 @@ function MidiButton() {
: "Plug one in"
: "Off";
return (
- <button className={`midi${on ? " on" : ""}`} aria-pressed={on} onClick={() => setMidi(!on)} title={on ? "Disconnect the MIDI keyboard" : "Play with a MIDI keyboard (the browser asks for access)"}>
- <span className="midi-name">MIDI keyboard</span>
- <span className="midi-status">{status}</span>
- </button>
+ <Chip on={on} onClick={() => setMidi(!on)} className="midi-chip" title={`MIDI keyboard: ${status}. ${on ? "Press to disconnect." : "Press to connect (the browser asks for access)."}`}>
+ MIDI{midi.status === "off" ? "" : `: ${status}`}
+ </Chip>
);
}
diff --git a/src/ui/components/SingPanel.tsx b/src/ui/components/SingPanel.tsx
index d0f40c4..efa0b86 100644
--- a/src/ui/components/SingPanel.tsx
+++ b/src/ui/components/SingPanel.tsx
@@ -3,7 +3,7 @@ import { useStore } from "../store.ts";
import { useSing, playDemo, stopSinging, soundingSyllable, sungNow, DEMO_SONGS, ensureDictionary } from "../singing.ts";
import { mouthWords } from "../mouthWords.ts";
import { V } from "../colors.ts";
-import { Keys } from "./Keys.tsx";
+import { Keys, MidiButton } from "./Keys.tsx";
import { PianoRoll } from "./PianoRoll.tsx";
import { SpectrumView } from "./SpectrumView.tsx";
import { Chip, Screen } from "./Screen.tsx";
@@ -158,7 +158,7 @@ export function SingRight() {
<Screen className="s-voice" title="Voice">
<SongControls />
</Screen>
- <Screen className="s-keys" title="Keys" sub={next ? `Next: ${next}` : ""}>
+ <Screen className="s-keys" title="Keys" sub={next ? `Next: ${next}` : ""} tools={<MidiButton />}>
<Keys />
</Screen>
</div>
diff --git a/src/ui/styles.css b/src/ui/styles.css
index 5281d10..2499d47 100644
--- a/src/ui/styles.css
+++ b/src/ui/styles.css
@@ -723,44 +723,6 @@ button.ghost {
min-width: 0;
}
-button.midi {
- flex: 0 0 96px;
- display: flex;
- flex-direction: column;
- justify-content: center;
- gap: 2px;
- padding: 6px 8px;
- border: 1px solid var(--line);
- border-radius: var(--radius-s);
- background: transparent;
- text-align: left;
- cursor: pointer;
- overflow: hidden;
-}
-
-.midi-name {
- font-size: 12.5px;
- font-weight: 550;
- font-stretch: 87%;
- line-height: 1.15;
-}
-
-.midi-status {
- font-size: 12px;
- font-stretch: 87%;
- color: var(--text-dim);
- line-height: 1.2;
- overflow-wrap: anywhere;
-}
-
-button.midi.on {
- border-color: var(--caliper-dim);
-}
-
-button.midi.on .midi-status {
- color: var(--caliper);
-}
-
/* ---------- beatbox */
.beatbox {
display: grid;
@@ -1122,14 +1084,6 @@ button.midi.on .midi-status {
flex-direction: column;
gap: 6px;
}
- button.midi {
- flex: none;
- flex-direction: row;
- align-items: baseline;
- justify-content: flex-start;
- gap: 8px;
- padding: 4px 8px;
- }
}
@media (prefers-reduced-motion: reduce) {
@@ -1387,6 +1341,13 @@ button.ghost:hover,
.s-voice { grid-area: voice; }
.s-keys { grid-area: keys; }
+.midi-chip {
+ max-width: 220px;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+
/* ---------- a screen */
.screen {
position: relative;
@@ -1726,33 +1687,6 @@ button.ghost:hover,
box-shadow: 0 0 6px rgba(91, 227, 129, 0.5);
}
-button.midi {
- border-radius: 0;
- border-color: var(--frame);
-}
-
-.midi-name {
- font-size: 10px;
- font-weight: 300;
- letter-spacing: 0.16em;
- text-transform: uppercase;
-}
-
-.midi-status {
- font-size: 9px;
- letter-spacing: 0.1em;
- text-transform: uppercase;
- color: var(--text-dim);
-}
-
-button.midi.on {
- border-color: var(--green);
-}
-
-button.midi.on .midi-status {
- color: var(--green);
-}
-
/* ---------- panels of modes not yet redrawn: framed, black, capital headings */
.panel {
background: #000;