$ show marin-m/SongRec
SongRec is a Linux desktop application (with CLI counterpart) that recognizes songs by sending audio fingerprints to Shazam's proprietary API. It is written in Rust and uses GTK4/libadwaita for the GUI. The architecture is a multi-threaded monolith with dedicated threads for microphone capture, audio processing (fingerprinting), HTTP communication with Shazam, and the GUI event loop. External dependencies include Shazam's servers (reverse-engineered endpoint), FFmpeg for audio file decoding, and platform audio backends (CPAL, PulseAudio, ALSA). The application provides persistent song history with CSV export, favorites, MPRIS integration, system tray icon, and configurable request intervals to handle rate limiting. The codebase shows good engineering practices with trait abstractions for audio backends, a typed channel message system, and versioned preferences. A separate Python reference implementation exists in the `python-version/` directory but is not the primary codebase.
The LLM identified 3 files worth highlighting for reuse:
Defines the `AudioBackend` trait that abstracts audio device enumeration and selection across CPAL and PulseAudio. Implementations (`cpal.rs`, `pulseaudio.rs`) provide platform-specific device discovery. This pattern allows isolating audio hardware concerns from the recognition logic, making it reusable in any Rust audio application that needs backend-agnostic device selection.
Implements encode/decode of Shazam's proprietary audio fingerprint signature format (binary packet with CRC32, sample rates, frequency bands). Produces standard `data:audio/vnd.shazam.sig;base64` URIs. This module has no internal dependencies on other SongRec modules – it is a standalone, testable library for any project that needs to create or parse Shazam-compatible fingerprints.
Provides the `SongRecordInterface` trait and CSV-based implementation for storing recognized songs, favorites, and timestamps. The trait abstracts history operations (insert, list, favorites, clear) away from the GUI, enabling alternative storage backends (e.g., JSON, SQLite) to be swapped in without modifying the UI code. The CSV implementation includes proper quoting and date formatting.