Skip to content

About

Root module that makes Android play USB DAC audio at each track's own sample rate, with optional bit-perfect. APatch, KernelSU, Magisk are tested on.

Topics

Resources

Contributing

Security policy

Stars

4 stars

Watchers

0 watching

Forks

Latest commit

 

History

15 Commits

Folders and files

Repository files navigation

Auto Samplerate Changer for Android (with Optional Bitperfect)

Your music. Your DAC. No unnecessary resampling.

status: beta version: 0.7.1 license: AGPL-3.0

Download: go to the Releases page, open the newest version at the top, and download the .zip under Assets. Then follow the Quick start.

A root module (APatch, KernelSU, Magisk) that makes Android play music through a USB DAC at each track's own sample rate instead of resampling everything to one fixed rate. It follows the playing track automatically, can pause the player for a moment while the rate changes, and comes with a WebUI and terminal tools so you can see what Android is really doing.

Hobby project, best-effort support. Maintained by ArupEn1 (GitHub) in spare time, for free, with no income and no promises. It works on the devices listed below; everything else is untested. Issues are welcome, but replies and fixes happen when time allows. Use it at your own risk and read Before you install.

Acknowledgements

I'll be honest: this module is stitched together with a lot of AI assistance, and it would not have been possible without two amazing projects that did the hard parts first.

  • USB_SampleRate_Changer by zyhk. This is the heart of the module. It does the real audio-policy work, and his script is included here completely unmodified.
  • BitPerfect-DAC by varunpilankar. The bp* tools (bpstatus, bpcheck and the rest) come from his module, which is where this project started.

Without the two of them this would have been impossible, so a huge thank you. If this module helps you, please go and give their projects a star too.

Who it is for

Rooted phones or tablets with an external USB DAC where the music app's output ends up resampled (for example Apple Music at 96 kHz played as 48 kHz, or a mixer pinned at the DAC's maximum rate).

What it does

  • Auto-follow: a small daemon watches the playing track and switches the mixer to its sample rate on the USB DAC: 44.1, 48, 88.2, 96, 176.4 and 192 kHz, and 352.8 / 384 kHz if the DAC lists them. It can also follow the 3.5 mm jack and switch mode per output (both experimental). It is off after install: turn it on in the Auto tab.
  • Pause while switching (optional): pauses the player just before the switch and resumes right after, so the first moments are not played at the wrong rate.
  • WebUI: every setting as a button or switch, live status, logs and a one-tap sanitized report. Themes: Auto, Day, Night, Retro paper and Retro night, with an animation on/off switch.
  • Truth tools: bpstatus shows mixer rate, source rate, bit depth, digital gain, enabled effects and a rate-matched / RESAMPLED verdict.
  • Boot apply and reset: re-applies your mode at boot; bprate reset removes the policy overlay and turns the automation off.

What it does not do

  • Prove bit-perfect output from inside Android. The module makes Android play each track at its own sample rate, but whether the samples stay untouched also depends on the app (its volume, effects and DRM), and the phone cannot check that for you.
  • Follow the 3.5 mm jack by default. In some modes the jack stays fixed at 48 kHz / 16-bit; there is an experimental switch for the jack, see 3.5 mm jack (experimental).
  • Fix volume or effects inside the music app, or enabled system effects ("Volume listener" and similar).
  • Guarantee Hi-Res delivery; that depends on the service, subscription, track and DAC.
  • Give one app exclusive access to the DAC. Android mixes every app into one stream at one rate. The module only switches the rate when exactly one track is playing; if several tracks are active at once it leaves the rate alone, so something may be resampled until only one is left.

Screenshots

First run: Auto-follow nudge
First run: Auto-follow nudge
No USB output
No USB output
Apple Music, 96 kHz track
Apple Music, 96 kHz track
Status, 96 kHz rate-matched
Status, 96 kHz rate-matched
Apple Music, 44.1 kHz track
Apple Music, 44.1 kHz track
Status, 44.1 kHz rate-matched
Status, 44.1 kHz rate-matched
Apple Music, 192 kHz track
Apple Music, 192 kHz track
Status, 192 kHz rate-matched
Status, 192 kHz rate-matched
Rate tab
Rate tab
Auto tab, per-output profiles off
Auto tab: profiles off
Auto tab, per-output profiles on
Auto tab: profiles on
Audio tab
Audio tab
Audio: which mode should I pick
Audio: which mode should I pick
Audio: mode list
Audio: mode list
Audio: bit depth list
Audio: bit depth list
Tools, Night theme
Tools, Night theme
Tools: diagnostics and report
Tools: diagnostics and report
Day theme
Day theme
Retro paper theme
Retro paper theme
Retro night theme
Retro night theme
Wavelet equalizer on
Wavelet equalizer on
Status with sound effects on
Status with sound effects on
Wavelet idle, nothing applied
Wavelet idle, nothing applied
Status, 192 kHz clean
Status, 192 kHz clean

Tap an image for full size.

How it knows the track's sample rate

It does not read the player's metadata. The follower polls Android's audio server (dumpsys media.audio_flinger), finds the active track in the track table and takes the rate that track is opened at, so it follows what is really being played whatever the app claims.

  • It polls about every 0.4 s and needs a second poll to confirm a new rate before switching, so a brief glitch does not trigger a restart. The optional fast mode skips the confirmation and polls about every 0.12 s.
  • When the rate changes it asks the backend to set the mixer to that rate on the USB DAC, or to a x2 / x4 / x8 multiple if the DAC does not list it. On the jack (experimental) it uses the track rate, halved once above 192 kHz unless extended rates are unlocked. It then waits for the audio server to come back before carrying on.
  • More than 6 switches in 2 minutes turns auto-follow off, and two failed backend calls do the same, so a misbehaving source cannot loop forever.
  • In testing with many Apple Music songs, the rate never changed in the middle of a song, so switches happen when a new track starts. A mid-stream rate change (some radio streams, for example) should be caught on the next poll, but it has not been tested.

How it is built

The audio-policy rewrite is done by the bundled, unmodified USB_SampleRate_Changer by zyhk (AGPL-3.0, license in module/usbsrc/LICENSE). This module adds the follower daemon, pause/resume, boot apply, the WebUI and the diagnostic tools. The bp* tools come from the GPL-3.0 BitPerfect-DAC module by varunpilankar, which this project started from and has changed and extended since; the record is in docs/HISTORY.md and credits are in NOTICE.

Tested setups

Device ROM / Android Root Result
Moto Edge 30 Fusion LineageOS 24 / Android 17 APatch + Hybrid Mount Works: rate-matched, auto-follow, pause/resume
Samsung Galaxy Tab S9 One UI 7 / Android 15 (R/W) KernelSU Next + Hybrid Mount Works (reported)
LG V30+ (H930DS) LineageOS 22.2 / Android 15 Magisk USB DAC works in safest mode. Jack: in bypass-offload the mixer and the kernel audio stream follow a rate set by hand (experimental, see below)

Details and evidence: docs/COMPATIBILITY.md. Other devices, ROMs, DACs and apps are untested, and Spotify has not been tried.

Before you install

  • You need a rooted device and an external USB DAC.
  • Mounting: on KernelSU and APatch, module files (including the bp* tools) are made visible by your mount metamodule. The setups above used Hybrid Mount. If the commands are missing after install, check your mount setup; the WebUI and the module folder work either way.
  • WebUI on Magisk: Magisk has no built-in WebUI; open it with WebUI X or MMRL.
  • Know how to recover (safe mode, recovery, or deleting the module folder from a root shell). See docs/INSTALL.md.
  • Remove other modules that edit audio policy or effects (HiFi SRC Bypass, NLSound, Ainur Silmaril and similar); they edit the same files.
  • For bit-exact / bit-perfect playback, set media volume to maximum and turn off EQ, loudness, crossfade and volume normalisation in your music app. An EQ still works if you want one; see Using an equalizer.

Quick start

You only need your phone. No terminal, no typing commands.

1. Install

  1. Download Auto-Samplerate-Changer-<version>.zip from Releases (the .sha256 file lets you check it), or build it yourself with sh scripts/build.sh.
  2. Open your root manager (Magisk, KernelSU or APatch), go to Modules, choose Install from storage and pick the ZIP.
  3. Reboot when it finishes.

2. Open the WebUI

The WebUI is the module's control panel, with buttons and switches for everything.

  • KernelSU / APatch: go to Modules and tap the WebUI / Open button on this module.
  • Magisk: Magisk has no built-in WebUI, so install WebUI X or MMRL, give it root, and open this module from there.

3. Turn it on

Important: Auto-follow is OFF after installing. The module does not change sample rates by itself until you switch on Auto-follow track rate in the Auto tab (step 3 below). If you skip this it will look like nothing works.

  1. Plug in your USB DAC and play a song in your music app.
  2. In the WebUI, look at the Status tab. A green Rate-matched badge means the music is playing at its own sample rate.
  3. Open the Auto tab and switch on Auto-follow track rate. Leave Apply at boot on too.
  4. Play tracks with different sample rates, for example 44.1 kHz and 96 kHz. The rate follows each track by itself. By default the player pauses for a moment while it switches and resumes right after; you can change that on the same tab.

For bit-exact / bit-perfect playback, set the media volume to maximum and turn off EQ, loudness and effects in your music app. (An EQ still works if you want one, see below.)

The WebUI tabs

Tab What it is for
Status Live status of the audio path, the badge, and your current settings
Rate Pick a sample rate by hand (you rarely need this with Auto-follow on)
Auto Auto-follow, apply at boot, pause and resume while switching
Audio Output mode, bit depth and DRC, with a short guide to picking a mode
Tools Checks and logs, the one-tap report for bug reports, and Reset

The WebUI also has a ? Help button in the top corner that opens these steps on your phone. You can change the look under Tools → Appearance (Auto, Day, Night, Retro and Retro night themes, plus an animations switch).

If something is wrong

  • No sound, or the speaker went silent: in the WebUI press Tools → Reset, then go to Audio → Mode and choose safest. This fixed an LG V30.
  • The badge says Resampled: make sure Auto-follow is on and a song is playing through the DAC, then check the Status tab again. If it stays that way, try another mode on the Audio tab.
  • Still stuck: open Tools → Save full report to Downloads while music is playing, review the file, and attach it to a GitHub issue.

Prefer a terminal? Every command is listed in docs/TERMINAL.md.

Using an equalizer (EQ or parametric EQ)

EQ and parametric EQ (the system equalizer, Wavelet and similar apps, or an EQ inside your music app) still work. The module does not disable or bypass effects, and it does not force them off.

  • Resampling is still stopped: the track keeps playing at its own sample rate.
  • It is no longer bit-exact / bit-perfect while an EQ is on, because an EQ changes the samples. Turn the EQ off if you want bit-exact / bit-perfect playback.
  • Confirmed working by the maintainer; other ROMs and EQ apps may behave differently. bpstatus lists any enabled effects, so you can see what is active.

If tracks above 96 kHz are still resampled

If the WebUI says Resampled for a 192 kHz track (for example "Mixer 96 kHz, Source 192 kHz") even though the module asked for 192 kHz, your phone's USB audio driver is probably locked to 96 kHz. The WebUI report then shows the backend warning about the "96kHz lock". Seen on a Moto Edge 30 Fusion (LineageOS 24, bypass-offload-safer).

zyhk's separate modules lift that limit:

  1. On APatch, and on recent Magisk (the installer asks for it), install Compatible Magisk-mirroring first and reboot. Without it, the unlocker's installer stops with "no magisk-mirrors".
  2. Install usb-samplerate-unlocker and reboot. It patches vendor libraries, so read its page first.
  3. In the WebUI, turn Auto-follow off and on once so the follower restarts, then play a 192 kHz track.

Confirmed on the Moto above (192 kHz works afterwards); other phones are untested. Details in docs/COMPATIBILITY.md.

3.5 mm jack (experimental)

By default only a USB DAC is followed. The Auto tab has a switch, Follow 3.5 mm jack (experimental) (bprate jack on), that makes the follower treat the headphone jack as an output too when no USB DAC is used.

  • It needs a mode that changes the jack's rate. bypass-offload worked on the tested phone. In bypass-offload-safer, offload-safer, safe, safest and safest-auto the jack stays at 48 kHz, so the follower leaves it alone and writes a note in the follow log.
  • What was tested: an LG V30+ (H930DS) on LineageOS 22.2 in bypass-offload. With a rate set by hand, the headset output thread and the kernel audio stream both ran at 96 kHz and then at 44.1 kHz (details in docs/COMPATIBILITY.md). Following each track automatically on the jack then worked on the same phone: the follow log shows 44.1, 48 and 192 kHz switches, and at 192 kHz the headphone output thread and the kernel stream both ran at 192000 Hz. No other phone has been tested.
  • Extended sample rates on the jack (352.8 / 384 kHz): off by default, so the jack is never asked for more than 192 kHz. Turn on Unlock extended sample rates (jack) on the Auto tab (bprate extended on) to allow them; it also shows the 352.8 and 384 kHz buttons on the Rate tab. The jack lists no rates, so this is a trial: on the LG V30+ the jack ran at 384 kHz (headphone output thread and kernel stream both at 384000 Hz) with normal sound, but other phones may not accept it. If the sound goes silent or noisy, run bprate extended off. With it off, a track above 192 kHz is followed at half its rate, once. USB DACs are not affected: they use the rates the DAC lists.
  • The speaker may change with the jack in these modes, and a vendor effect on the path can still alter the signal. bpstatus shows what is enabled.
  • The "set media volume to MAX" advice is for USB DACs only. On the jack the status line just reports the volume, and you should keep headphones at a comfortable level. A volume below max is applied by the mixer, so the signal is not bit-exact there.

Per-output profiles (experimental)

Off by default. With Per-output profiles on (Auto tab, or bprate profiles on; it needs Auto-follow on), each output gets its own mode and bit depth, and the module switches when the output changes:

Output How it is detected
USB DAC a USB audio card is present
3.5 mm jack a wired headset or headphone is listed as an available output device
Bluetooth headphones an A2DP, LE Audio or hearing-aid device is listed as an available output device. Wins over the jack. safest does not play on Bluetooth (Moto Edge 30 Fusion, LG V30+), so give Bluetooth its own mode, e.g. bypass-offload-safer
Speaker / other none of the above

Nothing is preset. An output left on "keep current mode" is not touched. Set them in the WebUI or with bprate profile usb|jack|bt|other <mode> [bits], for example bprate profile jack bypass-offload, bprate profile bt bypass-offload-safer and bprate profile other safest. bprate profile lists them, bprate profile jack clear removes one.

  • The output has to stay the same for two checks (about 3 seconds) before anything switches, and an unreadable dump counts as "no change", so an audio server restart does not look like an unplug.
  • A switch restarts the audio server, the same as a rate switch. If music is playing it is paused first and resumed afterwards (the same pause setting as rate switches).
  • If the output or profile changes more than 4 times in 2 minutes, or the backend fails twice, profiles turn themselves off and the follow log says why.
  • While profiles are on, the mode shown on the Audio tab is the one in effect right now. Change it per output, or the profile switches it back.
  • A jack profile also makes the follower follow the jack. The jack still needs a mode that changes its rate (see above).
  • Tested on an LG V30+ (LineageOS 22.2): jack profile bypass-offload, speaker/other profile safest. Plugging in headphones switched to the jack profile in about 5 seconds and unplugging switched back, and the speaker played normally afterwards. The USB DAC profile has not been tried on a phone yet.

Volume steps (experimental)

Android has 15 media volume steps on most phones, which is coarse on headphones. Finer volume steps (Audio tab, or bprate volsteps <16-150>) raises the number, up to 150, by setting ro.config.media_vol_steps at boot. It is meant to make life easier: Bluetooth headphones, or a USB DAC without a volume control of its own, can only be turned down with the phone's volume, so finer steps help. Off is the default and changes nothing.

  • It takes effect after a reboot. bprate volsteps off and a reboot go back to Android's own number.
  • It is a standard Android property, but some ROMs ignore it. It worked on the Moto Edge 30 Fusion (LineageOS 24) with 75 and 150 steps. Other phones are untested; Samsung One UI has its own volume step setting in Good Lock.
  • bpstatus and the Status tab show the media volume as a number, for example Media volume: 45 / 100. The module cannot add a number to Android's own volume panel; that is part of the system UI.
  • It does not touch the sample rate, the mode or anything else the module does.

Known limitations

  • Each rate switch restarts the audio server, so there is a short interruption and the first moments of a track may use the old rate.
  • DACs without 88.2 / 176.4 kHz still force resampling for those tracks.
  • On some phones the USB audio driver is locked to 96 kHz, so tracks above that stay resampled. See If tracks above 96 kHz are still resampled.
  • AIDL devices are not supported for now, for example the Samsung Galaxy Z Fold8. Their audio policy comes from the AIDL audio HAL, which is a current limitation of the bundled backend, zyhk's USB_SampleRate_Changer (it stops with "Recent AIDL only devices are not supported!"). Check with su -c "dumpsys media.audio_policy | grep -i -A2 'config source'": a file path is fine, AIDL HAL is not. See docs/COMPATIBILITY.md.
  • Digital volume below maximum and enabled effects break bit-exactness. On LG phones the vendor "Volume listener" effect may show up as enabled.
  • bpstatus confirms Android is playing at the track's own rate. While USB offload is active, Android can't show the final rate sent over USB; a DAC with a display or indicator can confirm the output sampling rate.

Documentation

Doc For
INSTALL Install, update, uninstall, recovery
TERMINAL Every terminal command
TROUBLESHOOTING Reading bpverify / bpstatus
TESTER_GUIDE · TESTING How to test and what the checks prove
COMPATIBILITY Tested configurations
ARCHITECTURE · DECISIONS How it works, design choices
HISTORY · CHANGELOG Origin and version history

Some older docs were written for earlier versions and may mention outdated details; the README and module README are the current reference.

Reporting issues

Use GitHub Issues, or ask and share DAC reports on the Discord server (SampleRate Support Group). In the WebUI, open Tools → Save full report to Downloads while music is playing and attach bitperfect-report.txt (review it first). Please include device, ROM, Android version, root solution and manager, DAC, app, and the track's format. For security problems see SECURITY.md.

Contributing

Help is welcome: compatibility reports, device-specific findings, fixes and reviews. Read CONTRIBUTING.md and run sh tests/run.sh before sending changes.

Credits

Disclaimer

Independent community project. Not affiliated with or endorsed by Apple, Spotify, Google, Magisk, KernelSU or APatch. Apple Music and Spotify are trademarks of their owners. Root modifications can affect stability, audio and device security; back up your device and understand the risks. Provided as is, with no warranty.

License

AGPL-3.0 (see LICENSE). The project combines the GPL-3.0 BitPerfect-DAC base (its license text is in LICENSES/GPL-3.0.txt) with the AGPL-3.0 USB_SampleRate_Changer backend, which GPL-3.0 section 13 allows; the combined work is offered under the AGPL-3.0. The bundled module/usbsrc/ backend keeps its own license file. If you redistribute the module, keep the license and credit notices; see NOTICE.

About

Root module that makes Android play USB DAC audio at each track's own sample rate, with optional bit-perfect. APatch, KernelSU, Magisk are tested on.

Topics

Resources

Contributing

Security policy

Stars

4 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages