Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/fc-spatial-quality-verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
- 'fc/spatial-audio/apply.py'
- 'fc/spatial-audio/source-commit'
- 'fc/spatial-audio/refinement/**'
- 'fc/spatial-audio/headphone-force/**'
- 'fc/branding/**'
- 'canvas-web/public/index.html'
- 'canvas-web/public/api/tg-webhook.js'
Expand Down Expand Up @@ -109,6 +110,9 @@ jobs:
python3 fc/spatial-audio/apply.py
python3 fc/spatial-audio/experimental/apply.py
python3 fc/spatial-audio/refinement/apply.py
python3 -m py_compile fc/spatial-audio/headphone-force/apply.py
python3 -m unittest discover -s fc/spatial-audio/headphone-force -p 'test_*.py'
python3 fc/spatial-audio/headphone-force/apply.py
python3 -m py_compile fc/branding/apply.py fc/branding/makeover.py fc/branding/glass_once.py
python3 -m unittest discover -s fc/branding -p 'test_*.py'
python3 fc/branding/apply.py
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/fc-sync-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,13 @@ jobs:
set -euo pipefail
python3 fc/spatial-audio/refinement/apply.py
echo "enabled=$(sed -n 's/^enabled=//p' fc/spatial-audio/refinement/config.properties)" >> "$GITHUB_OUTPUT"
- name: Enable optional software headphone surround control
if: steps.decision.outputs.should_release == 'true'
run: |
set -euo pipefail
python3 -m py_compile fc/spatial-audio/headphone-force/apply.py
python3 -m unittest discover -s fc/spatial-audio/headphone-force -p 'test_*.py'
python3 fc/spatial-audio/headphone-force/apply.py
- name: Fill missing Android locale fallbacks for this build
if: steps.decision.outputs.should_release == 'true'
run: |
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ It inherits a capable music experience from [Zenith](https://github.com/rezapran
> [!IMPORTANT]
> **Spatial Audio here means stereo soundstage processing**—not Dolby Atmos, object-based surround or personalized HRTF binaural rendering. The experimental limiter checks sample peaks, **not true peaks**. Automated tests establish behavior and numerical safety; they do not prove a subjective sound-quality improvement on every device.

### Headphone surround, even without Dolby hardware

If your phone lacks an E-AC-3/Atmos decoder, the Dolby Atmos switch may remain unavailable. **Settings → Force headphone surround** gives you the existing *software stereo-widening* engine without requiring Dolby hardware. This bypasses only the spatial learner's Auto decision; it still respects speaker, DSP, actual Atmos-stream and bit-perfect safety gates. It is **not Dolby Atmos**, and does not turn a stereo mix into discrete object-based surround.

## What makes brrMusic different

| Focus | What we've built or configured |
Expand Down
42 changes: 31 additions & 11 deletions fc/branding/apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,37 @@ def xml_text(value, path):
value)

def lyrics_card(value, path):
# Remove the ENTIRE watermark block and its bottom gutter, not merely the word.
start, end = " // ── Brand ─", "\n bitmap\n"
if value.count(start) != 1 or value.count(end) != 1:
raise SystemExit("Lyrics card footer changed; refusing unsafe patch")
head, tail = value.split(start, 1)
watermark, rest = tail.split(end, 1)
if "drawLogo(" not in watermark or "canvas.drawText(BRAND" not in watermark:
raise SystemExit("Lyrics card watermark changed; refusing unsafe patch")
value = head + " // No brand, icon or watermark in shared lyrics images.\n" + end + rest
return replace_once(value, "private const val BRAND_BAND = 132f",
"private const val BRAND_BAND = 0f", path)
"""Remove the visible logo/watermark; support both reviewed upstream layouts.

Zenith 2026-11-22 moved the mark from a footer band to the upper-right
header. Do not remove any panel/lyrics/song-drawing code.
"""
marker = " // ── Brand ─"
if value.count(marker) != 1:
raise SystemExit("Lyrics brand section changed; review patch before releasing")
if "private const val BRAND_BAND = 132f" in value:
# Older layout: brand sits below panel and has a dedicated height band.
end = "\n bitmap\n"
if value.count(end) != 1:
raise SystemExit("Legacy lyrics footer layout changed; refusing patch")
head, tail = value.split(marker, 1)
removed, rest = tail.split(end, 1)
if "drawLogo(" not in removed or "canvas.drawText(BRAND" not in removed:
raise SystemExit("Legacy lyrics logo did not match reviewed layout")
value = head + " // No visual watermark on shared lyrics.\\n" + end + rest
return replace_once(value, "private const val BRAND_BAND = 132f",
"private const val BRAND_BAND = 0f", path)
# New layout: brand is a conditional header before the lyrics passage.
end = " // ── The passage ─"
if value.count(end) != 1:
raise SystemExit("New lyrics passage anchor changed; refusing patch")
head, tail = value.split(marker, 1)
removed, rest = tail.split(end, 1)
required = ("if (showLogo)", "drawLogo(canvas, context,", "canvas.drawText(BRAND")
if not all(token in removed for token in required):
raise SystemExit("New lyrics header logo did not match reviewed layout")
return head + " // No visual watermark on shared lyrics.\n" + end + rest


def home(value, path):
old = """ Wordmark(
Expand Down
2 changes: 1 addition & 1 deletion fc/branding/config.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Keep package name, signing certificate, account/storage IDs and internal APIs unchanged.
# Increase brandingRevision whenever visible branding or identity assets change.
enabled=true
brandingRevision=3
brandingRevision=4
# One-release touch-elasticity trial. CI changes this to false after a signed
# APK has been verified, before committing release metadata to main.
# Future upstream updates will not re-apply the experimental patch.
Expand Down
5 changes: 5 additions & 0 deletions fc/spatial-audio/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ generated application edits before committing the upstream sync.
(“Auto · On” or “Auto · Off”), not as a third toggle.
- Phone speaker is blocked by default. Dolby Atmos and unavailable DSP are hard
bypasses. Profiles are capped at 400 records and excluded from settings export.
- **Force headphone surround** is an opt-in software stereo mode in Settings.
It sets the persistent global spatial policy to On instead of Auto, overriding
learned Auto decisions only. Disabling it returns to Auto; the overall spatial
switch still provides Off. The option never enables an unsupported E-AC-3/JOC
decoder, Dolby processing, phone speakers by default, or bit-perfect DSP.
- Only explicit per-track On/Off choices train the learner. Metadata, likes,
scrobbles and playlists are not treated as preference evidence.

Expand Down
17 changes: 17 additions & 0 deletions fc/spatial-audio/SpatialAudioLearningTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,23 @@ class SpatialAudioLearningTest {
assertEquals(SpatialAudioDecisionReason.DSP_UNAVAILABLE, decide(mode = SpatialAudioMode.ON, dsp = false).reason)
}

@Test
fun headphoneForceOverridesAutoLearningButNeverAudioSafety() {
val negative = listOf(
example("one", SpatialAudioFeedback.OFF),
example("two", SpatialAudioFeedback.OFF),
example("three", SpatialAudioFeedback.OFF),
example("four", SpatialAudioFeedback.OFF),
)
assertFalse(decide(mode = SpatialAudioMode.AUTO, examples = negative).enabled)
val forced = decide(mode = SpatialAudioMode.ON, examples = negative)
assertTrue(forced.enabled)
assertEquals(SpatialAudioDecisionReason.GLOBAL_ON, forced.reason)
assertFalse(decide(mode = SpatialAudioMode.ON, examples = negative, speaker = true).enabled)
assertFalse(decide(mode = SpatialAudioMode.ON, examples = negative, atmos = true).enabled)
assertFalse(decide(mode = SpatialAudioMode.ON, examples = negative, dsp = false).enabled)
}

@Test
fun disablingLearningStopsProfilingButKeepsEffectOn() {
assertTrue(decide(learning = false).enabled)
Expand Down
6 changes: 1 addition & 5 deletions fc/spatial-audio/apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,7 @@ def copy_asset(name: str, destination: str) -> None:
" } else {\n"
" SpatialAudioMode.OFF\n"
" }\n"
" if (spatialAudioMode.value == SpatialAudioMode.ON) {\n"
" spatialAudioMode.value = SpatialAudioMode.AUTO\n"
" prefs.edit().putString(KEY_SPATIAL_AUDIO_MODE, SpatialAudioMode.AUTO.name).apply()\n"
" }\n"
" spatialAudio.value = spatialAudioMode.value != SpatialAudioMode.OFF\n"
" spatialAudio.value = spatialAudioMode.value != SpatialAudioMode.OFF\n"
" spatialAudioByTrack.value = readSpatialAudioByTrack()\n"
" spatialAudioRecords.value = readSpatialAudioRecords()\n"
" spatialAudioTrackPreferences.value = readSpatialAudioTrackPreferences()\n"
Expand Down
68 changes: 68 additions & 0 deletions fc/spatial-audio/headphone-force/apply.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#!/usr/bin/env python3
"""Build-only UI for explicit software headphone surround.

Not an Atmos decoder or an Atmos entitlement. Uses existing SpatialAudioMode.ON
to bypass Auto learning only; keep device codec, JOC, speaker, bit-perfect and DSP
safety checks in the existing service.
"""
from pathlib import Path
ROOT = Path(__file__).resolve().parents[3]
UI = ROOT / "app/src/main/java/com/music/zenith/ui/screens/SettingsSheet.kt"

def once(source: str, before: str, after: str) -> str:
matches = source.count(before)
if matches != 1:
raise SystemExit(f"Headphone surround UI changed upstream: expected one anchor, got {matches}")
return source.replace(before, after, 1)

def patch(value: str) -> str:
# The permanent spatial-audio adapter has already installed this mode.
value = once(
value,
" val spatialAudioOnPhoneSpeaker by AppSettings.spatialAudioOnPhoneSpeaker.collectAsStateWithLifecycle()\n",
" val spatialAudioOnPhoneSpeaker by AppSettings.spatialAudioOnPhoneSpeaker.collectAsStateWithLifecycle()\n"
" val headphoneSurroundMode by AppSettings.spatialAudioMode.collectAsStateWithLifecycle()\n",
)
added = ''' // Software headphone surround: a manual override of Auto learning.
// This is deliberately NOT an attempt to unlock Dolby Atmos decoding.
val forceHeadphoneSurround = headphoneSurroundMode == com.music.zenith.playback.SpatialAudioMode.ON
row("Force headphone surround", "stereo", "headphones", "spatial audio") {
BypassedByBitPerfect(bitPerfectReady) {
SettingsRow(
icon = SfIcons.SurroundSound,
title = "Force headphone surround",
subtitle = "Software stereo widening, not Dolby Atmos. Bypassed on phone speakers, Atmos tracks and incompatible outputs.",
trailing = {
IosSwitch(
checked = forceHeadphoneSurround,
onCheckedChange = { force ->
AppSettings.setSpatialAudioMode(
if (force) com.music.zenith.playback.SpatialAudioMode.ON
else com.music.zenith.playback.SpatialAudioMode.AUTO,
)
},
)
},
onClick = {
AppSettings.setSpatialAudioMode(
if (forceHeadphoneSurround) com.music.zenith.playback.SpatialAudioMode.AUTO
else com.music.zenith.playback.SpatialAudioMode.ON,
)
},
)
}
}
'''
return once(
value,
" val spatialLearningTitle = stringResource(R.string.spatial_audio_learning_enabled)\n",
added + " val spatialLearningTitle = stringResource(R.string.spatial_audio_learning_enabled)\n",
)

if __name__ == "__main__":
if not UI.is_file():
raise SystemExit("Expected Settings UI missing; refusing unsafe integration")
before = UI.read_text(encoding="utf-8")
after = patch(before)
UI.write_text(after, encoding="utf-8")
print("Headphone surround: optional manual stereo override added; Dolby decoder gate untouched")
29 changes: 29 additions & 0 deletions fc/spatial-audio/headphone-force/test_apply.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"""Regression tests for safe, explicitly labeled headphone surround."""
import importlib.util
import unittest
from pathlib import Path

spec = importlib.util.spec_from_file_location("headphone_force", Path(__file__).with_name("apply.py"))
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)

class HeadphoneForceTests(unittest.TestCase):
def test_settings_only_adds_software_mode(self):
sample = (
" val spatialAudioOnPhoneSpeaker by AppSettings.spatialAudioOnPhoneSpeaker.collectAsStateWithLifecycle()\n"
" val spatialLearningTitle = stringResource(R.string.spatial_audio_learning_enabled)\n"
)
altered = module.patch(sample)
self.assertIn("Force headphone surround", altered)
self.assertIn("not Dolby Atmos", altered)
self.assertIn("SpatialAudioMode.ON", altered)
self.assertIn("SpatialAudioMode.AUTO", altered)
self.assertNotIn("DeviceCodecs.forced", altered)
self.assertNotIn("setDolbyAtmos", altered)

def test_missing_upstream_anchor_aborts(self):
with self.assertRaises(SystemExit):
module.patch("unrecognized layout")

if __name__ == "__main__":
unittest.main()
Loading