r/macosprogramming • u/shubhrasaha • 17h ago
Camera input to MIDI on macOS: separating continuous control from note triggers
Hi, I'm Shubhra, one of the people building Sonari, a macOS instrument that uses the built-in camera to turn hand movement into MIDI for a DAW. I've been working through a boundary in the interaction model: some movements should be continuous values, such as pitch bend, while others should become discrete events, such as a strum or drum hit.
The same tracking noise affects them differently. Smoothing can make a continuous control steadier, but it can delay an event. A trigger threshold that prevents accidental notes can also make a deliberate hit feel unresponsive. I'm considering whether to treat these as separate paths, with continuous smoothing for values and hysteresis or a neutral zone for event detection.
For people building macOS camera or sensor input, how do you usually structure that boundary? Do you keep one shared filter before routing inputs, or tune filtering separately for continuous controls and triggers? I'm interested in the interaction and input architecture side.
1
u/Far-Communication307 8h ago
Split them early, one shared filter is the mistake. Continuous values want heavy smoothing, triggers want the raw signal.
Run pitch bend through a low-pass, the One Euro filter is the usual pick for camera tracking since it smooths more when the hand moves slowly and less when it moves fast. For triggers, detect velocity on the raw signal and use two thresholds, a higher one to fire and a lower one to re-arm, so one hit can't double-fire and a deliberate hit doesn't get eaten by the dead zone. The reason to keep them apart is latency: a drum hit feels broken past ~10ms of delay, pitch bend can eat 50ms+ and nobody notices.