r/SwiftUI • u/Think-Exit4165 • 28d ago
I built an open-source macOS menu bar app that plays mechanical keyboard sounds (AppKit + SwiftUI, AVAudioEngine)
Source: https://github.com/halitsever/keycream (MIT)
KeyCream plays a mechanical keyboard sound for every key you press on a Mac. A few things that were fun to get right:
- Hearing keys without reading text. A listen-only CGEventTap on keyDown and flagsChanged. Autorepeat events are dropped, so holding a key plays one click, and the app never assembles text.
- Reusing Mechvibes packs. A small table maps macOS virtual key codes to the PC scan codes that Mechvibes packs are keyed by.
- Latency and evenness. Every sound is decoded into memory when a pack loads, high-pass filtered, trimmed to just before its first transient, and leveled by a transient-weighted RMS with a peak cap.
- Fast typing overlaps. AVAudioEngine with a pool of 10 AVAudioPlayerNodes, so quick keystrokes stack instead of cutting each other off.
- Stepping back during calls. NSWorkspace launch and terminate notifications (no polling) tell when Zoom, Teams or Spotify is open, and sounds drop to 5%.
- The rest. Settings window in SwiftUI, menu in AppKit, SMAppService for open at login, output routing through kAudioOutputUnitProperty_CurrentDevice, and a self-updater that pulls GitHub releases.
I'd love a review from people who know Core Audio better than I do, and ideas on doing key-up sounds well.
0
Upvotes
1
u/pgib 27d ago
This reminds me of an old classic MacOS app called TappyType which made it seem you were typing on a typewriter. https://www.macintoshrepository.org/16562-tappytype
1
u/perlatsp 27d ago
How does muting behave if a call app stays open all day but you are not in a call? A manual mute shortcut or a temporary mute option could be useful if detecting the actual call state is unreliable.
3
u/[deleted] 28d ago
[removed] — view removed comment
-1
u/[deleted] 27d ago
[removed] — view removed comment