A macOS utility that automatically matches your system output device to the sample rate and bit depth of the audio currently playing in Apple Music.
LosslessSwitcher is designed for listeners using external DACs, audio interfaces, or hi-res-capable output devices. Instead of manually opening Audio MIDI Setup every time a track changes from 44.1 kHz to 96 kHz, 192 kHz, or another supported rate, the app detects the playback format and switches the default output device automatically when possible.
Example: Apple Music starts playing a 24-bit / 96 kHz track while your DAC is currently set to 16-bit / 44.1 kHz. LosslessSwitcher detects the source format and switches the DAC output to 96 kHz with the selected bit-depth behavior.
This project was inspired by the idea and functionality of vincentneo/LosslessSwitcher, with custom implementation details around live Console log monitoring, CoreAudio device control, Apple Music metadata detection, and a SwiftUI interface.
LosslessSwitcher releases include automated VirusTotal scanning during the release process to help improve user safety and peace of mind.
Release builds are automatically checked before distribution so users can verify downloaded builds with greater confidence.
The recommended way to install LosslessSwitcher is from the GitHub Releases page.
- Open the repository on GitHub.
- Click Releases on the right side of the repository page.
- Download the latest release asset.
- Open the downloaded app or archive.
- Move LosslessSwitcher.app to your Applications folder.
- Launch the app and allow any required macOS permissions.
If macOS blocks the app because it is from an unidentified developer:
- Open System Settings.
- Go to Privacy & Security.
- Scroll to the security warning for LosslessSwitcher.
- Click Open Anyway.
Developers can also build the project from source using Xcode. See Build from Source below.
-
Automatic sample-rate switching
- Detects the currently playing Apple Music track.
- Switches the default macOS output device to the detected sample rate when supported.
-
Bit-depth preference control
- Preserve detected bit depth when available.
- Or force 16-bit, 24-bit, or 32-bit output when supported by the device.
-
Live CoreAudio format detection
- Monitors Apple Music, CoreAudio, and CoreMedia log output for real playback format information.
- Useful for Apple Music streaming tracks where metadata alone may be unreliable.
-
Manual sample-rate switching
- Shows supported sample-rate modes for the current default output device.
- Allows one-click manual switching.
-
Menu bar mode
- Optional menu bar item.
- Optional menu-bar-only mode.
- Quick access to Auto mode, Match Now, current source, current output format, and settings.
-
Launch at login
- Optional login item support.
-
Track format cache
- Remembers reliable detected formats for previously played songs.
- Cached song formats persist across app restarts.
- Includes an option to clear remembered song formats.
-
Activity log
- Shows recent detections, switches, unsupported rates, and error messages.
LosslessSwitcher combines three detection paths:
-
Apple Music metadata detection
- Uses AppleScript automation to read the current Apple Music player state, track name, artist, album, kind, cloud status, persistent ID, sample rate, and bit rate.
-
Live Console format detection
- Runs macOS
log streamwith predicates for:com.apple.Musiccom.apple.coreaudiocom.apple.coremedia
- Parses recent decoder and AudioQueue messages to detect the actual sample rate and bit depth being used by Apple Music/CoreAudio.
- Runs macOS
-
CoreAudio output switching
- Reads the current default output device.
- Reads supported nominal sample-rate ranges.
- Applies the target sample rate using CoreAudio.
- Attempts to select the best matching physical output format for the preferred bit depth when available.
The app can display and switch to rates reported by the current default output device. It also checks common hi-res sample rates, including:
- 44.1 kHz
- 48 kHz
- 88.2 kHz
- 96 kHz
- 176.4 kHz
- 192 kHz
- 352.8 kHz
- 384 kHz
- 705.6 kHz
- 768 kHz
Actual support depends on your DAC, audio interface, or output device.
- macOS with SwiftUI menu bar app support
- Apple Music app
- A DAC, audio interface, or output device with multiple supported sample rates
- Apple Music Automation permission
- Console log access may be required for the most accurate live stream format detection
- Xcode, only if building from source
Because the app uses AppleScript automation and system audio APIs, permissions may be requested by macOS the first time the app tries to read Apple Music or monitor audio behavior.
LosslessSwitcher needs permission to control/read Apple Music metadata.
If detection fails with an automation permission error:
- Open System Settings
- Go to Privacy & Security
- Open Automation
- Find LosslessSwitcher
- Enable access to Music
The live format monitor uses /usr/bin/log stream to read relevant Apple Music/CoreAudio/CoreMedia messages. Depending on your macOS privacy settings, the app may need additional permission to access log data.
- Connect your DAC or audio interface.
- Set it as the default macOS output device.
- Open LosslessSwitcher.
- Enable Auto.
- Play a track in Apple Music.
- The app will detect the source format and switch the output device when the target format is supported.
For manual control, use the Manual Rate section to switch to any supported rate reported by the current default output device.
For normal users, download the latest app from the Releases tab instead. These steps are for developers who want to build the project manually.
-
Clone the repository:
git clone https://github.com/YOUR_USERNAME/YOUR_REPOSITORY_NAME.git cd YOUR_REPOSITORY_NAME -
Open the project in Xcode.
-
Select the LosslessSwitcher scheme.
-
Build and run:
Command + R
-
Start playing music in Apple Music.
-
Click Request Music Access or Match Now if the app does not detect the current track immediately.
The main window includes:
-
Source
- Current track title
- Artist
- Detected sample rate / bit depth
- Format source, such as Music metadata, CoreAudio decoder, CoreMedia AudioQueue, or cached format
-
Output
- Current default output device
- Current device sample rate / bit depth
- Number of reported sample-rate modes
- Bit-depth preference selector
-
Manual Rate
- One-click buttons for supported sample rates
-
Settings
- Show Menu Bar Item
- Menu Bar Only
- Launch at Login
- Remembered song count
- Clear Song Memory
-
Activity
- Recent detection and switching events
The menu bar window provides quick access to:
- Auto mode toggle
- Current source format
- Current output device format
- Bit-depth preference
- Match Now
- Main window
- Settings
- Quit
LosslessSwitcher/
├── AudioModels.swift
├── ConsoleAudioFormatDetector.swift
├── ContentView.swift
├── CoreAudioDeviceManager.swift
├── LiveConsoleAudioFormatMonitor.swift
├── LosslessSwitcher.entitlements
├── LosslessSwitcherApp.swift
├── LosslessSwitcherController.swift
├── MusicSourceDetector.swift
└── TrackFormatCache.swift
| File | Purpose |
|---|---|
LosslessSwitcherApp.swift |
App entry point, menu bar item, settings scene, and main window presentation. |
LosslessSwitcherController.swift |
Main app state, detection loop, auto-switch logic, settings, launch-at-login support, and logging. |
CoreAudioDeviceManager.swift |
Reads CoreAudio output devices, supported sample rates, current bit depth, and applies sample-rate / physical-format changes. |
MusicSourceDetector.swift |
Uses AppleScript to detect Apple Music playback metadata and sample-rate information. |
ConsoleAudioFormatDetector.swift |
Parses recent macOS Console entries for CoreAudio/CoreMedia/Music format messages. |
LiveConsoleAudioFormatMonitor.swift |
Streams live Console output and reports newly detected audio formats. |
ContentView.swift |
SwiftUI main window, settings UI, activity log, and menu bar interface. |
TrackFormatCache.swift |
Saves reliable detected song formats to Application Support for reuse across app launches. |
AudioModels.swift |
Shared models and formatting helpers for devices, sources, sample rates, bit-depth preferences, and logs. |
- The app currently focuses on Apple Music.
- Sample-rate switching only works when the default output device reports support for the target rate.
- Some streaming tracks may not expose reliable sample-rate metadata immediately; in those cases, the app waits for CoreAudio decoder information.
- Bit-depth switching depends on the physical formats exposed by the output stream.
- macOS, Apple Music, and CoreAudio logging behavior may change over time.
- The app does not improve the quality of the source audio; it only attempts to align the output device format with the detected playback format.
- Make sure Apple Music is open.
- Start playback.
- Click Request Music Access.
- Check System Settings > Privacy & Security > Automation and allow LosslessSwitcher to access Music.
- Confirm the DAC or audio interface is the default output device.
- Confirm the device supports the target sample rate.
- Try clicking Refresh Devices.
- Try using Manual Rate to confirm that CoreAudio allows switching.
The detected source sample rate is not reported as supported by the current output device. Choose a different output device or use a DAC that supports that rate.
Not all devices expose settable physical formats. The app will still attempt to switch sample rate, but bit-depth behavior depends on the device driver and CoreAudio-reported formats.
Inspired by vincentneo/LosslessSwitcher.
This implementation is built as a SwiftUI macOS app using Apple Music automation, CoreAudio device APIs, live Console log parsing, and local track-format caching.
This project is experimental audio utility software. Use it at your own risk. Audio device switching behavior depends on macOS, Apple Music, CoreAudio, and your specific DAC or audio interface.