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
40 changes: 20 additions & 20 deletions static/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -860,10 +860,10 @@
const hadPlayableSong = !!audio.src || !!window._juceAudioUrl || S.isPlaying;
// Snapshot where we were so leaving the player — especially by accident
// — is recoverable instead of dumping the user back at bar 1 next time.
// Must run BEFORE highway.stop()/audio unload, while getSongInfo() and
// Must run BEFORE window.highway.stop()/audio unload, while getSongInfo() and
// the position (stopTime) are still live.
if (hadPlayableSong) _snapshotResumeSession(stopTime);
highway.stop();
window.highway.stop();
// Cancel any queued seeks, in-flight shim closures, AND active
// count-in timers before stopping playback so none of these paths
// can mutate the torn-down session (mirrors the same triple reset
Expand Down Expand Up @@ -1049,7 +1049,7 @@
const demucsEl = document.getElementById('demucs-server-url');
if (demucsEl) demucsEl.value = data.demucs_server_url || '';
const leftyEl = document.getElementById('setting-lefty');
if (leftyEl) leftyEl.checked = highway.getLefty();
if (leftyEl) leftyEl.checked = window.highway.getLefty();
const autoplayExitEl = document.getElementById('setting-autoplay-exit');
if (autoplayExitEl) autoplayExitEl.checked = _autoplayExitEnabled();
const showUpNextEl = document.getElementById('setting-show-upnext');
Expand Down Expand Up @@ -1435,7 +1435,7 @@
// the audio-aligned chart time so plugins (note detection, etc.)
// keep scoring against the real chart clock regardless of visual
// calibration.
if (typeof highway !== 'undefined' && highway?.setAvOffset) highway.setAvOffset(_avOffsetMs);
if (window.highway?.setAvOffset) window.highway.setAvOffset(_avOffsetMs);
// Sync any visible Settings slider
const avSlider = document.getElementById('setting-av-offset');
if (avSlider) {
Expand Down Expand Up @@ -1498,7 +1498,7 @@
const resp = await fetch('/api/settings', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({

Check warning on line 1501 in static/app.js

View workflow job for this annotation

GitHub Actions / ci / lint

File has too many lines (4451). Maximum allowed is 1500
dlc_dir: document.getElementById('dlc-path').value.trim(),
default_arrangement: defaultArrangement,
demucs_server_url: document.getElementById('demucs-server-url').value.trim(),
Expand Down Expand Up @@ -1771,7 +1771,7 @@
window.jucePlayer = jucePlayer;

// ── Engine start/stop → re-route song audio (HTML5 ⇄ JUCE) ──────────────────
// window._juceMode is otherwise decided once, at song-load time (highway.js),
// window._juceMode is otherwise decided once, at song-load time (window.highway.js),
// from isAudioRunning(). If the JUCE audio engine is started or stopped *after*
// a song is already loaded (e.g. the user presses CHAIN / AMP), that decision
// goes stale: the song stays on the HTML5 <audio> element while the engine
Expand Down Expand Up @@ -1907,7 +1907,7 @@
return {
currentTime: Number.isFinite(time) ? time : null,
mediaTime: Number.isFinite(time) ? time : null,
chartTime: (typeof highway !== 'undefined' && highway && typeof highway.getTime === 'function') ? highway.getTime() : null,
chartTime: (typeof window.highway?.getTime === 'function') ? window.highway.getTime() : null,
duration: Number.isFinite(_audioDuration()) ? _audioDuration() : (song && song.duration) || null,
playbackRate: window._juceMode ? (window.jucePlayer && window.jucePlayer._speed || 1) : audio.playbackRate,
isPlaying: S.isPlaying,
Expand Down Expand Up @@ -2587,7 +2587,7 @@
if (artAbortController) artAbortController.abort();
artAbortController = null;

highway.stop();
window.highway.stop();
// Cancel any active count-in: clear timers/RAF and bump the gen so
// delayed callbacks (rewind frames, post-seek then, count-in ticks,
// post-count play) bail before mutating the new session.
Expand Down Expand Up @@ -2618,7 +2618,7 @@
}
audio.pause();
audio.src = '';
// Stale until the incoming song's WS handler (highway.js) sets it again.
// Stale until the incoming song's WS handler (window.highway.js) sets it again.
window._currentSongAudio = null;
// Fresh JUCE routing attempt for whatever song loads next.
window._clearJuceRerouteMemo?.();
Expand Down Expand Up @@ -2655,19 +2655,19 @@

// Wait for previous WebSocket to fully close before opening new one
await new Promise(r => setTimeout(r, 500));
highway.init(document.getElementById('highway'));
window.highway.init(document.getElementById('highway'));

const wsParams = new URLSearchParams();
if (arrangement !== undefined) wsParams.set('arrangement', arrangement);
wsParams.set('naming_mode', _getArrangementNamingMode());
const wsUrl = `${location.protocol === 'https:' ? 'wss:' : 'ws:'}//${location.host}/ws/highway/${decodeURIComponent(filename)}?${wsParams.toString()}`;
highway.connect(wsUrl);
window.highway.connect(wsUrl);
_resetSectionPracticeLog();
_scheduleSectionPracticeRetries();
loadSavedLoops();
document.getElementById('quality-select').value = highway.getRenderScale();
document.getElementById('quality-select').value = window.highway.getRenderScale();
const _minScaleSel = document.getElementById('min-scale-select');
if (_minScaleSel && highway.getMinRenderScale) _minScaleSel.value = String(highway.getMinRenderScale());
if (_minScaleSel && window.highway.getMinRenderScale) _minScaleSel.value = String(window.highway.getMinRenderScale());
}

// Generation token + safety-timeout handle for changeArrangement's
Expand Down Expand Up @@ -2749,7 +2749,7 @@
const clearMyCallback = () => {
// Only null out if the slot still points at us; a newer
// invocation may have replaced it during the await.
if (highway._onReady === myCallback) highway._onReady = null;
if (window.highway._onReady === myCallback) window.highway._onReady = null;
};
const r = await _audioSeek(time, 'arrangement-restore');
// Don't auto-resume on cancel OR off-target landing — same
Expand Down Expand Up @@ -2790,7 +2790,7 @@
clearBusy();
clearMyCallback();
};
highway._onReady = myCallback;
window.highway._onReady = myCallback;

// Reset the Section Practice bar for the incoming arrangement, mirroring
// playSong(): different arrangements have different section markers, so
Expand All @@ -2803,7 +2803,7 @@
_resetSectionPracticeLog();
invalidateParentCount();

highway.reconnect(currentFilename, index);
window.highway.reconnect(currentFilename, index);
window.feedBack.emit('arrangement:changed', { index, filename: currentFilename });
}
}
Expand Down Expand Up @@ -2848,7 +2848,7 @@

// Leave the player and return to the screen the song was launched from
// (Esc shortcut uses the same origin-aware target). showScreen() owns the
// full teardown: song:stop, audio unload, highway.stop(), count-in cancel.
// full teardown: song:stop, audio unload, window.highway.stop(), count-in cancel.
function closeCurrentSong() {
// A real close (user Escape/✕, or the queue-aware wrapper once the queue is
// exhausted) abandons any play-queue so a stale one can't advance later.
Expand Down Expand Up @@ -3111,8 +3111,8 @@
if (loopA !== null && loopB !== null) return { a: loopA, b: loopB };
const t = _audioTime();
try {
const secs = (highway && typeof highway.getSections === 'function')
? highway.getSections() : [];
const secs = (window.highway && typeof window.highway.getSections === 'function')
? window.highway.getSections() : [];
if (Array.isArray(secs) && secs.length) {
let start = null, end = null;
for (let i = 0; i < secs.length; i++) {
Expand Down Expand Up @@ -3173,7 +3173,7 @@
const region = _resolveEditRegion();
let arrangement = 0;
try {
const si = highway && typeof highway.getSongInfo === 'function' ? highway.getSongInfo() : null;
const si = window.highway && typeof window.highway.getSongInfo === 'function' ? window.highway.getSongInfo() : null;
if (si && typeof si.arrangement_index === 'number' && si.arrangement_index >= 0) {
arrangement = si.arrangement_index;
}
Expand Down Expand Up @@ -3337,7 +3337,7 @@
if (_sectionPracticeBarIsReady() && _sectionPracticeSourceSections().length) {
_updateSectionPracticeHighlight(ct);
}
if (!isCountingIn()) highway.setTime(ct);
if (!isCountingIn()) window.highway.setTime(ct);
}, 1000 / 60);

_installSectionPracticeDrawHook();
Expand Down
14 changes: 7 additions & 7 deletions static/js/count-in.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const _CREDITS_HOLD_MS = 3000;
// Backstop: the overlay's primary dismiss is song:play, but playback can fail
// to start without emitting it (HTML5 autoplay rejection, JUCE start failure,
// a count-in handoff that never plays). This hard cap guarantees the credits
// never linger over the highway. Generous enough to outlast a normal count-in.
// never linger over the window.highway. Generous enough to outlast a normal count-in.
const _CREDITS_MAX_MS = 12000;
export function _cancelCountIn() {
_countInGen++;
Expand Down Expand Up @@ -107,7 +107,7 @@ function _creditLineLabel(role) {
return key.charAt(0).toUpperCase() + key.slice(1) + ' by';
}

// Show the feedpak contributor credits over the highway. `authors` is the
// Show the feedpak contributor credits over the window.highway. `authors` is the
// sanitized [{name, role}] list from window.feedBack.currentSong.authors.
// Anchored to the lower third (bottom-center) so it never collides with the
// vertically-centered count-in number, and pointer-events-none so it never
Expand Down Expand Up @@ -196,7 +196,7 @@ export async function startCountIn(opts = {}) {
return;
}
S.lastAudioTime = loopA;
highway.setTime(loopA);
window.highway.setTime(loopA);
if (window.feedBack) {
window.feedBack.emit('loop:restart', { loopA, loopB, time: loopA });
}
Expand All @@ -217,7 +217,7 @@ export async function startCountIn(opts = {}) {
// Ease out quad
const eased = 1 - (1 - t) * (1 - t);
const currentT = fromTime + (toTime - fromTime) * eased;
highway.setTime(currentT);
window.highway.setTime(currentT);
if (t < 1) {
_countInRaf = requestAnimationFrame(rewindStep);
} else {
Expand Down Expand Up @@ -262,7 +262,7 @@ export async function startCountIn(opts = {}) {
// marker for "new iteration starts at A", not the actual
// audio position.
S.lastAudioTime = r.to;
highway.setTime(r.to);
window.highway.setTime(r.to);
window.feedBack.emit('loop:restart', { loopA, loopB, time: loopA });
beginCount();
});
Expand All @@ -271,7 +271,7 @@ export async function startCountIn(opts = {}) {
_countInRaf = requestAnimationFrame(rewindStep);

function beginCount() {
const bpm = highway.getBPM(loopA);
const bpm = window.highway.getBPM(loopA);
const beatInterval = 60 / bpm;
let count = 0;

Expand Down Expand Up @@ -339,7 +339,7 @@ export async function startSongCountIn() {
}
if (gen !== _countInGen) return; // teardown during pause
const startT = S.lastAudioTime || 0;
let bpm = highway.getBPM(startT);
let bpm = window.highway.getBPM(startT);
// Pre-chart / malformed-tempo fallback: 4 beats at 120 BPM (500 ms each).
if (!Number.isFinite(bpm) || bpm <= 0) bpm = 120;
const beatInterval = 60 / bpm;
Expand Down
2 changes: 1 addition & 1 deletion static/js/highway-colors.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ function _hwcSlotKeysForChart(sc, isBass) {
return ['low8', 'low7', 'lowE', 'A', 'D', 'G', 'B', 'highE'];
}

// Current arrangement shape (string count + bass-vs-guitar) from the 2D highway.
// Current arrangement shape (string count + bass-vs-guitar) from the 2D window.highway.
function _hwcChartShape() {
let sc = 6, arr = '';
try { sc = window.highway?.getStringCount?.() || 6; } catch (_) {}
Expand Down
4 changes: 2 additions & 2 deletions static/js/juce-audio.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ import { S } from './player-state.js';
return false;
}
}
// highway.js's initial song-load routing consults this for the same
// window.highway.js's initial song-load routing consults this for the same
// feedpak-under-exclusive decision the watcher makes below.
window._juceOutputIsExclusive = _outputIsExclusive;
// Returns true when window._currentSongAudio no longer references the exact
Expand Down Expand Up @@ -383,7 +383,7 @@ import { S } from './player-state.js';
// the stem mixer / WebAudio path keeps working. Sloppak stem URLs
// are never routable (per-stem mix can't ride a single transport).
if (!songAudio || (!songAudio.juceEligible && !songAudio.feedpakFullMix)) return;
// Don't race highway.js's own initial song-load routing: it owns
// Don't race window.highway.js's own initial song-load routing: it owns
// _juceMode until _juceRoutingPromise settles. Re-running our switch
// concurrently would double-call loadBackingTrack for the same URL.
if (window._highwayJuceRoutingPending) return;
Expand Down
4 changes: 2 additions & 2 deletions static/js/player-controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ export function _resetPlaybackSpeedForNewSong() {
//
// Debounced trailing-edge (300ms) so dragging the slider — which fires
// oninput per pixel — doesn't flood the server with concurrent writes
// to config.json. highway.setMastery() still fires every oninput so
// to config.json. window.highway.setMastery() still fires every oninput so
// the chart re-filters in real time; only disk persistence waits.
let _masteryPersistTimer = null;
function _persistMastery(pct) {
Expand Down Expand Up @@ -209,7 +209,7 @@ export function _applyMastery(v, opts = {}) {
// unlike #mastery-label above, whose markup carries no trailing unit.
const setLabel = document.getElementById('setting-highway-speed-val');
if (setLabel) setLabel.textContent = pct;
highway.setMastery(pct / 100);
window.highway.setMastery(pct / 100);
if (!opts.skipPersist) _persistMastery(pct);
}
// Reflect phrase-data availability on the slider after every `ready`.
Expand Down
6 changes: 3 additions & 3 deletions static/js/resume-session.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ const _RESUME_END_GUARD_S = 5; // ignore basically-finished
let _resumePillDismissed = false; // per-session: user waved off the current snapshot

// Snapshot the live session. Called from showScreen()'s teardown before
// highway.stop()/audio unload, while getSongInfo() + position are still valid.
// window.highway.stop()/audio unload, while getSongInfo() + position are still valid.
export function _snapshotResumeSession(position) {
try {
if (!host.currentFilename()) return;
const si = (window.highway && typeof highway.getSongInfo === 'function')
? (highway.getSongInfo() || {}) : {};
const si = (window.highway && typeof window.highway.getSongInfo === 'function')
? (window.highway.getSongInfo() || {}) : {};
const dur = Number(si.duration) || 0;
const pos = Number(position) || 0;
// Only worth resuming a song you were genuinely mid-way through — not a
Expand Down
4 changes: 2 additions & 2 deletions static/js/section-practice.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export function _sectionPracticeBarContains(el) {
}

// ── Section Practice Bar ────────────────────────────────────────────────
// One-click looping over song section markers (highway.getSections —
// One-click looping over song section markers (window.highway.getSections —
// same array as 3D highway bundle.sections / "Now / Up Next").
// Reuses setLoop() so manual A/B controls and saved loops stay canonical.
let _sectionPracticeRanges = [];
Expand Down Expand Up @@ -127,7 +127,7 @@ export function _resetSectionPracticeLog() {
}

function _sectionPracticeHighway() {
return window.highway || (typeof highway !== 'undefined' ? highway : null);
return window.highway || null;
}

function _sectionPracticeDuration() {
Expand Down
6 changes: 3 additions & 3 deletions static/js/transport.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ export function _songEventPayload() {
return {
time: audioT,
audioT,
chartT: highway.getTime(),
chartT: window.highway.getTime(),
perfNow: performance.now(),
};
}
Expand Down Expand Up @@ -289,8 +289,8 @@ export async function _audioSeek(s, reason) {
// _audioSeek resolves (e.g. the auto-resume song:play in
// changeArrangement) sees an in-sync chartT via _songEventPayload.
// Without this, chartT lags by one 60Hz tick after a seek.
if (typeof highway !== 'undefined' && highway && typeof highway.setTime === 'function') {
highway.setTime(to);
if (window.highway && typeof window.highway.setTime === 'function') {
window.highway.setTime(to);
}
window.feedBack.emit('song:seek', { from, to, reason: reason || null });
return { completed: true, from, to };
Expand Down
Loading
Loading