# Apple Music Remote (AMR) v3.0.0 — Complete Technical Architecture & Reference (`llms-full.txt`) > Comprehensive engineering whitepaper for AI assistants, search indexers, RAG pipelines, audiophiles, and smart-home developers. > Source Repository: https://github.com/1orgar/amr > Product Site: https://amraudio.app/ > Homebrew Cask: `brew tap 1orgar/tap && brew install --cask 1orgar/tap/amr` (https://github.com/1orgar/homebrew-tap) > Direct Download (Apple-Notarized Universal macOS DMG): https://github.com/1orgar/amr/releases/latest/download/AppleMusicRemoteMac-Universal.dmg > License: MIT (100% Free & Open Source) --- ## 1. Executive Summary **Apple Music Remote (AMR)** is a native pure-Swift macOS server (`LSUIElement` menu bar app, Apple Developer ID signed & notarized) and zero-latency Progressive Web App (PWA) remote controller engineered to unlock true audiophile playback from **Apple Music (`Music.app`)**. Unlike Electron wrappers, AirPlay receivers, or virtual-driver hacks: - AMR is compiled directly to native `arm64` and `x86_64` machine code (`410+` automated XCTest unit tests, zero third-party runtime dependencies, zero-Keychain `AES-256-GCM` vault) using Apple's `CoreAudio`, `AudioToolbox`, `Accelerate (vDSP / AMX)`, `Metal`, `Network.framework`, `ScriptingBridge`, `iTunesLibrary`, `NaturalLanguage`, `Vision`, `PDFKit`, and `CryptoKit`. - Audio is captured non-intrusively via macOS 14.2+/14.0+ native **CoreAudio Process Tap (`AudioHardwareCreateProcessTap`)** with lock-free C11 Single-Producer Single-Consumer (`CAtomicPrimitives`) ring buffers and zero heap allocations on the real-time `IOProc` thread. - Every connected remote device (iPhone, iPad, Android, Desktop browser, 4K Living Room TV) communicates over persistent WebSocket (`ws://:8080`) with `<15 ms` state synchronization, granular per-device zero-trust authorization (`ClientDeviceManager`), and instant camera QR pairing (`?invite=`). --- ## 2. Bit-Perfect CoreAudio Engine & Hardware Synchronization ### 2.1 Automatic Sample Rate Switching (`44.1 – 192 kHz`) `CoreAudioDeviceManager` and `BitPerfectLogMonitor` inspect incoming Apple Music track stream parameters prior to and during playback, switching the external hardware DAC's nominal sample rate across `44.1`, `48`, `88.2`, `96`, `176.4`, and `192.0 kHz` to match the native source rate 1:1. ### 2.2 Strict Format Lock, Volume Lock & Exclusive Integer Mode - **100% Digital Volume Lock**: Pegs `Music.app` and CoreAudio software volume at `100% (0.0 dBFS)` so macOS never truncates 24-bit words or injects software volume dither. - **AAC vs ALAC Pre-Inspection**: Distinguishes lossy `AAC (16-bit / 44.1 kHz)` from `ALAC Lossless` and `Hi-Res Lossless (24-bit / up to 192 kHz)`. - **Exclusive Hog Mode + Integer Mode (`0x4c`)**: When Hybrid DSP is active, AMR acquires `kAudioDevicePropertyHogMode` (preventing macOS notification chimes or browser audio from contaminating the DAC or breaking DoP markers) and negotiates `Non-Mixable Signed Integer (0x4c)`, bypassing `coreaudiod`'s 32-bit floating-point mixer entirely. - **3-Stage DAC Muting Guard**: Optional click-free relay protection (`Pre-Mute -> Hardware PLL Clock Lock -> Smooth Unmute`) eliminates transients and mechanical relay clicks on external DACs during sample rate changes. --- ## 3. Real-Time Spectral Hi-Res Verifier (`SpectralIntegrityAnalyzer`) Many streaming catalog releases labeled `24-bit / 96 kHz` or `24-bit / 192 kHz` are actually `44.1 kHz` CD masters or `16-bit` files upsampled or zero-padded into a Hi-Res container. AMR verifies every track mathematically in real time: - **Algorithm**: Continuous `4096-point` Hann-windowed real FFT (`vDSP_fft_zrip`) paired with bitwise Least Significant Bit (`LSB 0..7`) activity inspection directly on the tapped PCM frames. - **Five Automated Verdicts**: 1. `TRUE HI-RES`: Confirmed ultrasonic musical energy above `22.05 kHz` plus active 24-bit LSB entropy. 2. `FAKE HI-RES • 22K CUT`: Steep brickwall low-pass cutoff detected at `22.05 kHz` inside an `88.2 / 96 / 176.4 / 192 kHz` container (Red Book CD upsample). 3. `UPSAMPLED 48K`: Brickwall cutoff detected at `24.0 kHz` inside a `96 / 192 kHz` stream. 4. `16-BIT PADDED`: Lower 8 bits (`LSB 0..7`) inside a 24-bit container are 100% digital zeros. 5. `CD LOSSLESS`: Authentic `16-bit / 44.1 kHz` Red Book lossless stream. - **Two-Tier Persistent Cache**: Verified verdicts are cached on disk (`spectral_validation_cache_v1.json`) keyed by `persistentID` (local) and `catalogId` (Apple Music cloud) and synced via iCloud (`CloudSettingsSyncService`). On repeat plays, verdicts appear instantaneously while the analyzer drops to lightweight `visualizationOnly` mode (computing only the 32-band 60fps RTA). --- ## 4. 64-Bit Hybrid DSP Engine (`DSD DoP 7EC` & `HQ PCM NOS LNS15`) AMR includes a studio-grade real-time 64-bit DSP engine written in pure Swift (`Accelerate AMX FP64` + `Metal GPU df64`), selectable via 6 factory presets or custom user presets (`DSPPresetManager`): ### 4.1 Three Output Topologies 1. **`Bit-Perfect Passthrough` (Default)**: `100%` bit-identical PCM output (`44.1–192 kHz`) with zero DSP overhead. 2. **`DSD DoP v1.1 (7EC SDM)`**: Converts PCM into 1-bit high-rate `DSD64` (`2.8224 / 3.072 MHz`, `176.4 / 192 kHz` DoP), `DSD128` (`5.6448 / 6.144 MHz`, `352.8 / 384 kHz` DoP), or `DSD256` (`11.2896 / 12.288 MHz`, `705.6 / 768 kHz` DoP) packed in lossless `DoP v1.1` (`0x05 / 0xFA` markers) so USB DACs and DDCs (Topping, SMSL PO100 PRO, Holo Audio, Denafrips, Chord, Matrix) engage their direct native DSD path up to macOS CoreAudio's `705.6 / 768 kHz` USB Audio Class 2 ceiling. - **7th-Order Chebyshev Zero Modulator (`7EC`)**: Three selectable Noise Transfer Function (`NTF`) Out-of-Band Gain profiles: `7EC-Transient (OBG = 1.38)`, `7EC-Balanced (OBG = 1.50)`, and `7EC-Super (OBG = 1.62, >155 dB SNR)`. - **Viterbi Trellis Look-Ahead (`M = Off / 4 / 8 / 16`)**: Evaluates `M` parallel integrator state branches 8–16 clocks ahead to eliminate idle tones and noise-floor modulation. - **ISI Regularizer**: Penalizes excessive high-frequency `0101` bit transitions in the Viterbi cost metric to minimize physical 1-bit DAC Inter-Symbol Interference distortion in the vocal midrange. - **Clock Grid Policies**: `Strict SACD (44.1k)` (resamples `48/96/192 kHz` in `FP64` to the `44.1 kHz` family for strict DoP DACs), `Adaptive Dual-Grid (44.1k & 48k)`, or `Hybrid (44.1k DSD / 48k HQ PCM NOS)`. - **Modulator Headroom & ISP Guard**: `-3.0` to `-4.0 dB` 64-bit headroom attenuation plus true Inter-Sample Peak (`+1.5` to `+3.2 dBTP`) protection. 3. **`HQ PCM NOS` (High-Quality Non-Oversampling PCM up to `705.6 / 768 kHz`)**: - Engineered specifically for **R2R / Multibit ladder DACs** (*Holo Audio Spring/May, Denafrips Ares/Pontus/Venus/Terminator, Musician Pegasus, Schiit Multibit*) operating in hardware `NOS` mode, as well as offloading first-stage interpolators on ESS/AKM/Cirrus delta-sigma chips. - Upsamples `8x–16x` to `705.6 / 768 kHz` (`352.8 / 384 kHz` or `176.4 / 192 kHz` over S/PDIF) in 64-bit precision and quantizes to `24/32-bit` using the **15th-order Lipshitz / Wannamaker psychoacoustic noise shaper (`LNS15`)** (or linear `24-bit TPDF`), pushing quantization noise out of the `1–6 kHz` ear-sensitivity band above `100 kHz` and lowering the `20 Hz – 20 kHz` noise floor below **`-165 dBFS` (`27+ effective bits` of resolution)**. ### 4.2 Dual Oversampling Compute Kernels & Phase Topologies - **`Accelerate AMX (FP64)`**: Multi-stage polyphase FIR (`65,536` equivalent taps, `>155 dB` stopband attenuation) running in true IEEE-754 64-bit `Double` on Apple Silicon `AMX` matrix coprocessors with ultra-low latency and minimal power draw. - **`Metal GPU (Overlap-Save df64)`**: Single-stage `262,144-tap` Kaiser window FFT convolution on Apple GPU using emulated double-float (`df64`, ~48-bit mantissa) for surgical Nyquist brickwall selectivity. - **Phase Response**: Switchable between **Linear-Phase** (zero phase dispersion, holographic soundstage) and Kolmogorov–Hilbert cepstral **Minimum-Phase** (`0%` pre-ringing, natural acoustic post-ringing and visceral drum transient slam). --- ## 5. 64-Bit Pre-DSP Mastering Restoration, Room Auto-PEQ & Late-Night DRC Signal order inside the 64-bit (`Float64`) Pre-DSP chain: `Float32 (Tap) -> [0a] Mastering De-Clipper -> [0b] Weiss De-Esser -> [1] Headroom/ISP -> [2] 64-Bit Room Auto-PEQ -> [3] Late-Night DRC -> Oversampler / Local DAC / BluOS & DLNA` When all Pre-DSP modules are set to `Off` in `Bit-Perfect Passthrough` mode, the CoreAudio processing unit completely unloads from memory, restoring `100%` hardware Bit-Perfect passthrough. ### 5.1 Loudness War De-Clipper (`MasteringDeClipper`) & Weiss-Style Dynamic De-Esser - **De-Clipper**: `256-sample` look-ahead adaptive ceiling detector identifies brickwall-shaved plateaus (`2+` consecutive samples at `0.0` to `-1.0 dBFS`, ignoring synth square waves `>1.05 ms`) and reconstructs natural transient crests via `C1` slope-continuous cubic Hermite interpolation (`Auto Smart Guard DR <= 10` auto-bypassing `DR11+` audiophile masters, `Gentle +2.8 dB`, `Studio +4.2 dB`). Unclipped samples remain `100%` bit-identical (`0.0` error). - **Weiss-Style Dynamic De-Esser**: Level-independent `Sibilance-to-Body Ratio` sidechain (`6.5–7.0 kHz` Mid energy vs `>180 Hz` body, modeled on *Weiss DS1-MK3 / DAC501*) tame harsh vocal sibilance equally at `-26 dBFS` whispers and `0 dBFS` choruses (`Gentle -3.5 dB`, `Weiss Studio -6.0 dB`) via zero-phase-shift symmetric RBJ subtraction. ### 5.2 Room Acoustic Correction (`64-Bit Auto-PEQ` via iPhone / iPad Microphone) - **Measurement**: Mac outputs Paul Kellet calibrated semi-correlated pink noise (`85% Mid + 15% Side` to prevent off-axis comb cancellation) while the listener's iPhone or iPad records from the listening seat (live via `WebAudio` or native iOS Voice Capture upload over plain LAN HTTP without requiring HTTPS). - **Calibration & Target**: Computes 31 ISO 1/3-octave bands (`4096-pt` Welch-Hann FFT), compensates for iOS omnidirectional MEMS microphone low-end roll-off (`<45 Hz`) and `10–14 kHz` Helmholtz resonance, and fits the **Harman In-Room Target** (`+2.2 dB` shelf `<160 Hz`, `0 dB` midrange, `-0.85 dB/oct` slope `>2 kHz`). - **Asymmetric Biquad Synthesis**: Synthesizes up to 8 `64-bit RBJ Peaking EQ` bands — aggressively cutting boomy room standing modes (`35–220 Hz`, up to `-9.0 dB`, narrow `Q = 2.0–3.6`), gently filling dips (`<= +3.5 dB`, wide `Q = 1.1–1.6`), and applying automatic negative `Preamp Headroom = -(MaxBoost + 0.5 dB)`. Profiles sync across Macs via iCloud Drive and work simultaneously on USB DACs and `BluOS / DLNA` network streamers. ### 5.3 Audiophile Late-Night Dynamic Range Control (`LateNightDRCService`) - Designed for `DR14–DR20+` orchestral, jazz, and film score recordings at low listening volumes without tape-hiss pumping or crushed transients. - Uses `ITU-R BS.1770 K-Weighting` dual envelopes (`~1.8s` slow upward lift up to `+6.0 dB` in *Gentle* or `+9.5 dB` in *Night Concert* mode + `25 ms` soft-knee `6 dB` crest control), a `-63 dBFS` Hermite S-curve tape-hiss & inter-track pause gate, and a `64-sample` look-ahead `-1.0 dBTP` limiter. --- ## 6. External Amplifier TCP Bridge & Hardware Bit-Perfect Normalization When macOS output is locked at `100% Bit-Perfect (0.0 dBFS)` (or `DoP`, where digital scaling would corrupt `0x05/0xFA` markers), `ExternalAmpTCPController` controls your integrated amplifier or preamplifier directly over persistent TCP sockets: - **Supported Amplifiers**: **Rotel (`:9590`)**, **Denon / Marantz (`:23`)**, **Hegel (`:50001`)**, **NAD (`:30000`)**, and **Lyngdorf (`:84`)**. - **Safety Guards**: Configurable `Max Volume Cap (1–100%)`, Zero-Jump & Max-Volume hardware guards, live bidirectional polling of physical IR remote volume/mute changes, and TV Mode swipe + precision zoom loupe control. - **3-Tier Hardware SoundCheck (`AppleSoundCheckService`)**: 1. Local `iTunNORM` atoms (`.m4a/.mp4/.mp3/.aiff`): `ΔG_SC = -10 * log10(max(v0, v1) / 1000) dB`. 2. Streaming Apple Music `.m4a` HTTP Range header inspection (`bytes=0-98303`) extracting official studio `iTunNORM` in milliseconds. 3. Live `ITU-R BS.1770` K-weighted LUFS measurement (`~2s` fast + `~8s` refined) cached to disk. - **Psychoacoustic Crest Factor Compensation & Double-Attenuation Guard**: - Compensates for Loudness War `PLR / Crest` collapse (`Crest_dB = Peak_dBFS - LUFS`): for brickwalled tracks (`Crest < 10.5 dB`), applies `ΔG_Crest = min(3.5, 0.42 * (10.5 - Crest_dB))` so heavily compressed remasters retain subjective punch alongside `DR14` audiophile masters. - Includes **Smart Low-Volume Curve (`<40%`)** for non-linear attenuators and **`[Music.app SC Guard]`** that detects if `Music.app`'s internal Sound Check is accidentally active to prevent double attenuation. --- ## 7. On-Device Apple Neural Engine AI (`NativeMusicCuratorService` + `Vision`) Runs 100% locally on Apple Silicon's Neural Engine (`FoundationModels`, `NaturalLanguage` `512-D NLEmbedding` & `NLTagger`, `Vision` Saliency; automatically hidden/zero-overhead on Intel Macs): - **✨ AI Prompt Curator**: Generates thematic 20+ track audiophile sessions and album recommendations from natural-language mood, timbre, era, or soundstage prompts, plus a fullscreen monochrome **AI Tag Cloud** in TV Mode. - **🌉 Sonic Bridge (`512-D Geodesic SLERP`)**: Computes a smooth 10-, 12-, or 16-track Spherical Linear Interpolation (`SLERP`) trajectory in 512-dimensional semantic space between any Point A and Point B (e.g., *Miles Davis — Blue in Green* -> *Daft Punk — Veridis Quo*). - **♾️ Infinite AI Wave & Cosine Flow Ordering**: Orders queues along minimum 512-D cosine distance without consecutive same-artist collisions and seamlessly appends ~18–20 fresh tracks 3 songs before the queue ends. - **🎨 Vision Attention Saliency (`VNGenerateAttentionBasedSaliencyImageRequest`)**: Locates the human visual focal point on album covers (ignoring black/white borders) to extract vivid colors for `StandBy TV Mode`, `32-band RTA`, and `16-zone WLED DDP` lighting. --- ## 8. Multi-Room Streaming, TV Mode, Digital Booklets & Smart Home API - **BluOS & DLNA `24/192` Lossless Stream Relay**: Streams pure uncompressed `16/24-bit`, `44.1–192 kHz` LPCM WAV (`/stream/live.wav`) directly to **Bluesound (NODE, NODE NANO, POWERNODE)** and UPnP/DLNA renderers (Eversolo, Wiim, Volumio, Sonos, HEOS) with bidirectional Play/Pause/Seek/Volume sync (automatically suspending local USB `Hog Mode` DSP when streaming to BluOS and resuming upon return). - **StandBy / 4K Living Room TV Mode & `WLED DDP` (`UDP :4048`)**: Fullscreen TV interface with Apple Music HLS Motion Covers, `60fps` 32-band logarithmic RTA (`20 Hz – 96 kHz`), fullscreen Library Grid, iPad/iOS `NoSleep` keep-alive, and `<2 ms` `40 FPS` 16-zone bilinear WLED Ambilight (`γ = 2.4`) with 5 audio-reactive modes (*Static Cover Palette*, *Rhythm Sine Wave*, *3-Band Spectral EQ*, *Symmetric Center VU Pulse*, *Harmonic Resonance*). - **Digital Album Booklets (`DigitalBookletService` + `PDFKit`)**: Multi-page vinyl/CD-style reader combining Apple Music editorial essays, automatic Wikipedia (`EN/RU`) fallback, track-by-track liner notes, full studio musician/producer/mastering credits, and high-DPI rendering of local `.pdf` booklets. - **UPnP MediaRenderer (`:8090`), WebSocket (`:8080`) & REST API**: - `GET /api/status` — Real-time `PlayerStatus` JSON (track, codec, sample rate, bit depth, DAC, spectral verdict, DSP state, amplifier volume). - `POST /api/media` — Transport & library control (`play`, `pause`, `play_pause`, `next`, `previous`, `seek`, `set_volume`, `set_lock_volume_100`, `favorite`, `play_station`, `search_and_play`, `get_queue`, `get_playlists`). - `POST /api/duck` & `POST /api/unduck` — Smooth volume attenuation and restoration for **Home Assistant** voice / TTS announcements. - `GET /api/artwork/track?id=...` — Native resolution cover art via two-tier `ArtworkDiskCache`. --- ## 9. Comparison Summary (AMR v3.0 vs Alternatives) | Capability | AMR v3.0 (macOS) | AirPlay 2 | Apple iTunes Remote | Standalone Rate Switchers | Roon | | :--- | :--- | :--- | :--- | :--- | :--- | | Full Apple Music Catalog & Personal Mixes | Yes (Native) | Yes | Local Library Only | Passive Utility Only | No (Qobuz/Tidal/Local only) | | Auto Hardware DAC Rate Sync (`44.1–192 kHz`) | Yes (`0.0 dBFS`) | No (`44.1/48 kHz` cap, often AAC) | Manual Mac Setup | Yes (No Remote UI) | Yes (No Apple Music) | | Real-Time `4096-pt FFT` Fake Hi-Res Verifier | Yes (5 Verdicts + LSB) | No | No | No | No | | `DSD64–256 DoP` & `768 kHz LNS15 NOS` DSP | Yes (`AMX FP64` + `Metal`) | No | No | No | Yes (`$15/mo` or `$830`) | | `64-Bit` Room Auto-PEQ via iPhone Mic | Yes (Harman Target) | No | No | No | Manual Parametric EQ | | Mastering De-Clipper & Weiss De-Esser | Yes (`64-bit` Pre-DSP) | No | No | No | No | | External Amp TCP + Hardware SoundCheck | Rotel, Hegel, Denon, NAD, Lyngdorf | No | No | No | Partial Partner Devices | | BluOS & DLNA `24-bit / 192 kHz` Relay | Yes (`/stream/live.wav`) | AirPlay Ceiling | No | No | RAAT Only | | On-Device Neural AI & `512-D` Sonic Bridge | Yes (Apple Neural Engine) | No | No | No | Cloud Valence | | `40 FPS` 16-Zone WLED DDP Ambilight | Yes (`UDP :4048`, `<2 ms`) | No | No | No | No | | License & Cost | Free & Open Source (MIT) | Built-in | Free (Legacy) | Free | Paid Subscription |