Thanks to visit codestin.com
Credit goes to github.com

Skip to content

holo-q/moo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

moo

Sub-3ms audio feedback daemon for the Spaceship.

Preloads sounds into memory via rodio and listens on a Unix socket. Events trigger mapped sounds based on the active profile. Target latency: sound playback begins within one frame at 180Hz (~5.5ms).

Install

cargo install --path .

Usage

# Daemon (run via systemd)
moo daemon

# Trigger events (<1ms socket send)
moo clipboard_copy
moo switch2_in
moo claude_fire

# Direct sound playback (bypasses profile)
moo raw tick

# Status and control
moo status
moo reload

# Profile management
moo profile              # Show current
moo profile sparse       # Switch profile
moo profile --list       # List events in current profile
moo profiles             # List all profiles

# Sound utilities
moo sounds               # List available sounds
moo preview tick         # Preview a sound (via pw-play)

Architecture

┌─────────────────────────────────────────────────────────┐
│                     moo daemon                          │
│                                                         │
│  ┌─────────────┐    channel    ┌──────────────────┐    │
│  │ Socket Loop │──────────────▶│   Audio Thread   │    │
│  │   (tokio)   │               │   (std::thread)  │    │
│  └─────────────┘               │                  │    │
│         ▲                      │  - SoundBank     │    │
│         │                      │  - AudioEngine   │    │
│  Unix Datagram                 │  - rodio output  │    │
│  $XDG_RUNTIME_DIR/moo.sock     └──────────────────┘    │
└─────────────────────────────────────────────────────────┘
         ▲
         │ <1ms
    ┌────┴────┐
    │ Clients │  moo <event>
    └─────────┘

Audio lives on a dedicated thread because rodio's OutputStream isn't Send. Commands flow through an unbounded channel for immediate processing.

Configuration

Source of truth: ~/Workspace/sfx.toml

[meta]
default_profile = "rhythmic"
sounds_dir = "/path/to/sounds"

[sounds]
tick = "tick.wav"
confirm = "confirm.wav"
pulse_whisper = { file = "pulse-whisper.wav", volume = 0.9, pitch = "0.98~1.02" }

[profiles.rhythmic]
clipboard_copy = "tick"
yank = { sound = "tick_deep", pitch = "0.9~1.1" }  # per-trigger override
claude_fire = "pulse_2"

FloatOrRange

Volume and pitch support constants or random ranges:

volume = 0.9           # constant
pitch = "0.98~1.02"    # random within range each play

Profiles

  • sparse: Ritual punctuation - only major actions chirp
  • rhythmic: Working rhythm - navigation + lifecycle events
  • immersive: Full cockpit - the spaceship hums

Systemd

# ~/.config/systemd/user/moo.service
[Unit]
Description=moo - Sub-3ms audio feedback daemon
After=graphical-session.target pipewire.socket

[Service]
Type=simple
ExecStart=%h/.cargo/bin/moo daemon
Restart=always
RestartSec=1

[Install]
WantedBy=graphical-session.target
systemctl --user enable --now moo
systemctl --user status moo
journalctl --user -t moo -f

SIGHUP

Config reload via signal:

pkill -HUP moo
# or
moo reload

Both sfx config and logging levels (via spaceship-std) reload on SIGHUP.

Logging

Uses spaceship-std for centralized logging. Configure in ~/Workspace/logging.toml:

[levels]
moo = "debug"  # trace, debug, info, warn, error

View logs:

journalctl --user -t moo -f

Dependencies