AudioSeparationKit
On-device GPU-accelerated music source separation for Apple platforms, powered by Demucs and MLX.
Separates audio into individual stems (drums, bass, vocals, guitar, piano, etc.) entirely on Apple Silicon — no server required.
Requirements
- macOS 14+ / iOS 17+
- Apple Silicon (M1 or later)
- Swift 6.0+
Installation
Add to your Package.swift:
dependencies: [ .package(url: "https://github.com/Lakr233/AudioSeparationKit", branch: "master"), ]
Quick Start
import AudioSeparationKit let separator = try AudioSeparator(model: .htdemucs) let result = try await separator.separate(fileAt: audioFileURL) try result.writeStems(to: outputDirectory)
With Progress Reporting
let result = try await separator.separate(fileAt: url) { progress in print("\(Int(progress.fraction * 100))% — \(progress.stage)") }
Custom Options
let options = SeparationOptions( shifts: 2, // ensemble averaging for better quality overlap: 0.25, // segment overlap ratio splitEnabled: true // split long audio into segments ) let result = try await separator.separate(fileAt: url, options: options)
Models
| Model | Stems | Description |
|---|---|---|
htdemucs | 4 | HTDemucs — default, good balance of speed and quality |
htdemucs_ft | 4 | HTDemucs Fine-Tuned — best quality |
htdemucs_6s | 6 | HTDemucs 6-Source — adds guitar and piano stems |
hdemucs_mmi | 4 | HDemucs MMI |
mdx | 4 | Music Demixing |
mdx_extra | 4 | MDX with extra training data |
mdx_q | 4 | MDX Quantized — lower memory usage |
mdx_extra_q | 4 | MDX Extra Quantized |
Model weights are automatically downloaded from HuggingFace on first use.
4-stem models output: drums, bass, other, vocals
6-stem models output: drums, bass, other, vocals, guitar, piano
Output Formats
Write separated stems in various formats:
try result.writeStems(to: outputDir, format: .wav()) // default try result.writeStems(to: outputDir, format: .flac) try result.writeStems(to: outputDir, format: .alac) try result.writeStems(to: outputDir, format: .aac)
Testing With Local Assets
Real-model integration tests are designed to use local-only assets:
Models/is ignored and intended for local model weights only.AudioFixtures/is ignored and intended for local test audio only.- Test discovery should enumerate fixture files with
FileManagerrather than hard-coding filenames.
This repository should not be used to redistribute copyrighted evaluation audio.
Licensing And Third-Party Notices
AudioSeparationKit itself is released under the MIT license. See LICENSE.
This repository also contains adapted source code under Sources/DemucsMLX, imported from kylehowells/demucs-mlx-swift. The preserved upstream MIT license text lives in LICENSES/demucs-mlx-swift-LICENSE, with a short notice in LICENSES/README.md.
Model weights downloaded from Hugging Face and any local audio fixtures may be subject to separate licenses, terms, or copyright restrictions from their original authors. If you redistribute weights, derived packages, or test assets, review those upstream terms separately.
License
MIT