mirror of
https://github.com/got-feedBack/feedBack.git
synced 2026-07-22 12:52:29 +00:00
fix(sloppak/ws_highway): drums stay in picker and show correct hit count
Problem:
The editor strips drum arrangements from the sloppak manifest, converting
them to a drum_tab sidecar. This left two visible bugs:
1. "Drums (0)" — drum-only packs showed zero notes in the arrangement
picker even though the drum highway displayed thousands of hits. The
sloppak loader synthesized a placeholder Arrangement(name="Drums")
with no notes whenever the arrangements list was empty, and the
WebSocket highway always reported that placeholder's note count (0).
2. Drums disappear alongside other arrangements — when a drum+bass or
drum+guitar pack was loaded, the placeholder was never created because
the arrangements list was not empty (the other instrument was present).
The drum arrangement had been removed by the editor during drum_tab
conversion, so drums vanished entirely from the arrangement picker.
Fix (sloppak.py):
Replaced the "arrangements list is empty" trigger with "no drum
arrangement exists". The loader now checks whether any arrangement name
contains 'drum' or 'percussion' (case-insensitive substring match using
_DRUM_KEYWORDS) and synthesizes the placeholder when a drum_tab is
present but no matching arrangement is found. This ensures drums appear
in the picker even alongside bass, guitar, or other pitched instruments.
Fix (ws_highway.py):
When building the arrangement list for the song_info WebSocket message,
the highway now reads the drum_tab hit count from the loaded sloppak and
substitutes it for any empty arrangement whose name matches the drum
keywords. The placeholder has no notes of its own (it exists only to
carry the drum_tab through to the drum highway), so the real hit count
from drum_tab is surfaced instead — e.g. "Drums (1922)" instead of
"Drums (0)".
Guard against false positives:
The hit-count override is scoped to drum/percussion arrangements only.
Without this guard, an empty "Vocals" or "Keys" track in the same
pack would incorrectly inherit the drum hit count. The same keyword set
_DRUM_KEYWORDS = ('drum', 'percussion') is used in both sloppak.py and
ws_highway.py to keep the detection consistent.
Signed-off-by: =Scr4tch= <305609711+0-Scr4tch-0@users.noreply.github.com>
This commit is contained in:
parent
a9be210f77
commit
196008a98e
@ -478,12 +478,24 @@ async def highway_ws(websocket: WebSocket, filename: str, arrangement: int = -1,
|
||||
_evict_audio_cache()
|
||||
|
||||
# Send song metadata
|
||||
# For drum-only sloppaks the placeholder arrangement has 0 notes
|
||||
# (drum_tab hits live separately). Surface the real hit count so
|
||||
# the UI shows e.g. "Drums (1922)" instead of "Drums (0)".
|
||||
_DRUM_KEYWORDS = ("drum", "percussion")
|
||||
_dt_hit_count = 0
|
||||
if is_slop and loaded_slop is not None and loaded_slop.drum_tab is not None:
|
||||
_dt_hit_count = len(loaded_slop.drum_tab.get("hits") or [])
|
||||
arr_list = [
|
||||
{
|
||||
"index": i,
|
||||
"name": a.name,
|
||||
"smart_name": smart_names[i],
|
||||
"notes": len(a.notes) + sum(len(c.notes) for c in a.chords),
|
||||
"notes": (
|
||||
_dt_hit_count
|
||||
if (len(a.notes) == 0 and not a.chords and _dt_hit_count > 0
|
||||
and any(kw in (a.name or "").lower() for kw in _DRUM_KEYWORDS))
|
||||
else len(a.notes) + sum(len(c.notes) for c in a.chords)
|
||||
),
|
||||
}
|
||||
for i, a in enumerate(song.arrangements)
|
||||
]
|
||||
|
||||
@ -895,16 +895,21 @@ def load_song(
|
||||
log.warning("sloppak: drum_tab %r failed validation: %s",
|
||||
drum_tab_rel, reason)
|
||||
|
||||
# Drum-only sloppak: every GP track was percussion, so it ships a
|
||||
# drum_tab but no pitched arrangements. The highway WS rejects an empty
|
||||
# arrangements list with "No arrangements found" *before* it serves the
|
||||
# drum_tab, leaving the drums unplayable even in the drum highway.
|
||||
# Synthesize a minimal placeholder arrangement so the stream proceeds and
|
||||
# the drum_tab reaches the drum highway. It carries no notes (the guitar
|
||||
# highway just shows an empty board) and, when the manifest omits a
|
||||
# Drum sloppak: when a drum_tab is present but no existing arrangement is
|
||||
# a drum part, synthesize a minimal placeholder so the drums appear in the
|
||||
# arrangement picker and the drum_tab reaches the drum highway. The editor
|
||||
# strips drum arrangements out of the manifest (converting them to
|
||||
# drum_tab), so without this a drum+bass sloppak would show only Bass in
|
||||
# the picker with no way to reach the drums. It carries no notes (the
|
||||
# guitar highway just shows an empty board) and, when the manifest omits a
|
||||
# duration, derives a song length from the last drum hit so the timeline
|
||||
# isn't zero-length.
|
||||
if not song.arrangements and drum_tab_data is not None:
|
||||
_DRUM_KEYWORDS = ("drum", "percussion")
|
||||
_has_drum_arr = any(
|
||||
any(kw in (getattr(a, "name", "") or "").lower() for kw in _DRUM_KEYWORDS)
|
||||
for a in song.arrangements
|
||||
)
|
||||
if not _has_drum_arr and drum_tab_data is not None:
|
||||
if song.song_length <= 0:
|
||||
# validate_drum_tab() intentionally does NOT type-check individual
|
||||
# hits (they're sanitized at WS-stream time), so a hit may carry a
|
||||
|
||||
Loading…
Reference in New Issue
Block a user