A commercial-grade macOS desktop application built with SwiftUI to scan, detect, and manage duplicate audio tracks in your Apple Music library.
- Music Library: Scan your Music.app (iTunes) library
- Folder Scanning: Select any folder to scan for audio files (MP3, M4A, WAV, AAC, FLAC, AIFF)
- Flexible Metadata Detection: User-selectable criteria including:
- Track Title
- Artist
- Album
- Duration (with tolerance slider ±10 seconds)
Detect duplicates regardless of file format, bitrate, or metadata differences using perceptual audio analysis.
- FFT Spectral Analysis: Uses Apple's Accelerate framework for efficient frequency analysis
- Encoding Agnostic: Detects duplicates even when:
- Different bitrates (128kbps vs 320kbps)
- Different formats (MP3 vs M4A)
- Trimmed/edited versions (handles up to ~10 seconds offset)
- Configurable Settings:
- Sample Duration: Choose 10s, 30s, 60s, or Full Track analysis
- Similarity Threshold: Adjustable slider (50% - 100%)
- Parallel Processing: Fingerprints generated concurrently for speed
Listen to tracks directly in the app to verify duplicates before deletion.
- Auto-Play on Select: Click any track to instantly play it (enabled by default)
- Visual Indicator: Speaker icon shows which track is currently playing
- Stop Control: Stop button appears in sidebar during playback
- Seamless Switching: Click another track to switch playback instantly
Automatically identify songs and fix incorrect metadata using audio fingerprinting.
- Audio Fingerprinting: Uses Chromaprint/AcoustID for song identification
- MusicBrainz Integration: Fetches correct title, artist, album, year from MusicBrainz database
- Album Artwork: Automatically downloads and embeds cover art from Cover Art Archive
- Auto-Write: Automatically updates MP3 files with correct metadata when match confidence ≥70%
- Independent Workflow: Works separately from duplicate scanning
- No External Dependencies: fpcalc binary bundled with app - no Homebrew required
Multiple strategies to automatically select which copy to keep:
- Highest Bitrate
- Longest Duration
- Oldest/Latest Added
- Preferred Format (MP3/M4A)
- Moves duplicates to Trash (reversible via Finder)
- Removes entries from Music.app library
- Launch the app
- Select detection criteria in the sidebar:
- Metadata matching: Title, Artist, Album, Duration
- Audio Fingerprint: Enable for encoding-agnostic detection
- Click Scan Library or Scan Folder... to choose a custom folder
- Review detected duplicates in the main view
- Click tracks to preview audio (if Auto-Play enabled)
- Select tracks to remove (click the circle icon)
- Click Remove Selected to move to Trash
- Lower threshold (70-80%): Catches more duplicates, but may have false positives
- Higher threshold (90-100%): Stricter matching, fewer false positives
- Sample Duration: Longer samples = more accurate but slower
- Best for finding same songs encoded at different bitrates
- macOS 13.0+
- Swift 5.9+
- Xcode 15.0+ (for development)
# Build the project
swift build
# Create macOS app bundle
./bundle_app.sh
# Launch the app
open DuplicateMusicFinder.app
# Run with debug output visible in terminal
./DuplicateMusicFinder.app/Contents/MacOS/DuplicateMusicFinderThe app uses MVVM architecture with the following components:
TrackModel- Audio track metadata and fingerprintDuplicateGroup- Group of duplicate tracksDuplicateCriteria- User-selected matching criteriaAutoSelectionRule- Auto-selection strategyAudioFingerprint- Spectral peak data for perceptual matchingFingerprintSettings- User-configurable fingerprint parameters
MusicScanner- Reads Music.app library and scans foldersDuplicateEngine- Duplicate detection logicSelectionManager- Auto-selection rulesFileTrashHandler- Safe file deletionAudioFingerprintService- FFT spectral analysis using AVFoundation + AccelerateAudioPlayerService- Audio preview playbackChromaprintService- Generates Chromaprint fingerprints using bundled fpcalcAcoustIDService- Looks up songs via AcoustID APIMusicBrainzService- Fetches detailed metadata from MusicBrainzCoverArtService- Downloads album artwork from Cover Art ArchiveMetadataWriterService- Writes ID3 tags and artwork to MP3 files
AppViewModel- Central state management
- SwiftUI-based UI with NavigationSplitView
The app requires:
- Music Library access (
NSAppleMusicUsageDescriptionin Info.plist) - File system access for audio playback
- Audio Decoding: Uses AVAudioFile to decode any supported format to PCM
- Mono Conversion: Mixes stereo channels for consistent analysis
- FFT Analysis: 2048-sample windows with 50% overlap using vDSP
- Peak Extraction: Extracts top 5 frequencies (300Hz - 3000Hz) per window
- Hash Generation: Creates condensed hash for fast pre-filtering
- Similarity Comparison: Sliding window comparison with ±50Hz tolerance
- Parallel fingerprint generation using Swift TaskGroup
- Hash-based pre-filtering before detailed comparison
- Sampled window comparison (every 10th window)
- Early exit on high-confidence matches
TBD
- Audio fingerprinting
- Audio preview playback
- Folder scanning support
- Smart Tag - auto-fix metadata
- M4A/AAC metadata writing
- Batch export reports (CSV/JSON)
- Missing artwork detection - to be tested
- Music statistics dashboard