An instrument in SwiftUI
Beep Boop is a drum machine drawn on glass. The app holds one picture, its icon. Every key, light and dial is drawn by code, in SwiftUI, from a handful of numbers.
The rule
The test for every screen is Dieter Rams's: as little design as possible, and what there is must be useful, understandable and honest. On a panel that becomes three working rules.
- Nothing on screen that is not needed.
- One accent colour, used for one meaning.
- A part looks like what it does, and does it the same way every time.
One orange, and only as light
The panel is paper white, with black ink and grey labels. The drums have one colour, an orange, and it is never paint. No word is orange. Orange appears only where something is lit: a step key glowing from inside its cap, the ridge of a key held to accent, the figures in the window. So orange always means the same thing, which is that this is live.
The rule has been bent twice, both times by the same test. SYNTH has its own light, a yellow, so a tune is never mistaken for a beat, and a pad struck live glows green. Each is a light and never a paint, and each means one thing.
The grey of the labels was chosen by measurement. It passes 4.5 to 1 against the body for small text. The first grey did not, and was changed.
A key is a few shapes and a light
Fig. 1 is one step key. In code it is a few shapes in a stack: a darker foot, 2 points below; the body, 40 points by 56 with a corner of 7; a moulded ridge across it, 0.64 of its width; and a light inside the cap, cut to the body's own outline. There is no image and no texture.
It has height because it travels. Pressed, the body moves down 1.5 points onto its foot in 40 milliseconds, and its shadow shortens. That is the whole press. A key that did more would be showing off, and a key that did less would not feel pressed.
The light is in the cap
A step that is on lights its own key, from inside, as a lamp under a silicone cap does. The light warms in 90 milliseconds and cools in 150. When the playhead passes a lit step, the flash lands at once, at the moment the step is heard, and cools over 100 milliseconds.
The numbers are different on purpose. Light that arrives late looks wrong against sound, so the flash does not fade in. Light that leaves slowly looks warm.
Hold a key for half a second and the step is accented: struck harder, with its ridge lit orange. The accent is a held key and not a second control, so the panel gains nothing to look at.
Labels are silkscreen
Most parts carry a mark, not a word. TEMPO, KEEP, PLAY, PRINT and SWING each have a small engraved glyph, so the row under the keys reads at a glance. Where a word is needed it is set as if printed on: uppercase, in a monospaced face, a noun or two. SOUND. KICK. 1 OF 8. A label names the part and stops.
The same key on every screen
The panel is drawn once, on a canvas of 402 points by 874, the size of the phone it was designed on. On another iPhone the whole canvas is fitted by one factor. On an iPad the parts move, whole, to new places, and are fitted by one factor again. A key is never stretched, so it is the same key everywhere.
Where SwiftUI stops
SwiftUI draws the panel. It does not take the touches. A SwiftUI button answers when the finger lifts, and a gesture waits a moment to see what kind of gesture it is. An instrument must sound when the finger lands. So a clear layer from UIKit sits over each drawn part and reports touch-down with the touch's own timestamp.
The sound is kept apart in the same way. The panel never touches the audio system, and the engine never imports the code that draws. They speak through one queue. The audio thread never waits has that side of it.
Sources
- The key's measurements, its light and its timings: the panel's own SwiftUI source for its keys and the light in the cap, read from 1.0.4, 26 October 2026.
- The accent's half second: the panel's accent rule, in the same build.
- The palette, and the contrast of the label grey: the panel's colour tokens, where the measured ratio is written beside each grey.
- The canvas of 402 by 874 and the one factor: the panel's layout. The touch layer: the panel's touch surface, where the reason is written above it.
- Rams's principles, "as little design as possible", useful, understandable, honest: Dieter Rams, ten principles for good design, Vitsœ.
More sheets
- A kick drum is twelve numbersHow a drum machine's kit is built.
- How Beep Boop makes a soundTwo voices, TEAR, and one path out.
- The audio thread never waitsNo allocation, no lock, one queue.
- Every note in keyEight rows, one scale, no wrong notes.
- PatternsDrum patterns drawn on sixteen steps.
- Tempo by genreBPM for twelve genres, on one scale.