Files
SoulStream/src-tauri/src/lib.rs
T
KeelrLeek 793f78370e feat: crossfade preview suite, loudness normalization, debug overlay
Preview modal audio, five rounds:
- True track-change crossfade: scheduleSettle no longer silences the
  outgoing clip at t=0; preview_load's equal-power fade owns both ramps,
  gated on the incoming voice's first Playing event (audible_marks), with
  failure/overstay fallbacks. CROSSFADE_MS = 340 — locked to the reel's
  card-slide so audio and visuals land together.
- Two-neighbour lease prefetch + a 15-min on-disk clip byte-cache
  (recent_clips): steps in BOTH directions crossfade in ~15 ms; revisits
  never re-download.
- Adaptive settle (isolated steps fire immediately, bursts coalesce) and
  anticipatory auto-advance (step at clip end minus 400 ms) so auto-play
  crossfades over the tail instead of gapping.
- Session resume memory: revisited tracks continue where they left off
  (decoder-level start offset via play_local_from/resume_at); finished
  tracks restart from the top.
- Open/close crossfades with the MAIN player: fade-pause with the
  desired-paused latch landing at ramp end, fade-resume from the paused
  position; MAIN_FADE_GEN guards; focus handshake relaxation documented
  in focusBridge.

Volume normalization (Settings > Playback, default on):
- Dependency-free BS.1770/EBU R128 meter in the player crate (K-weighting,
  400 ms gated blocks, incremental) + analyzer that reads the same growing
  file playback streams from — first plays are measured at download speed.
- Gain layered under user volume; audible start GATED on a preliminary
  measurement (10 s of audio or 800 ms budget) so the level is right from
  the first sample and never changes mid-track; prelim boosts capped 3 dB,
  peak-aware clipping guard, persistent loudness-cache.json.
- Gapless boundaries get their own sample-accurate gain via
  SetNextNormGainDb, fed by preload analysis.

Debug overlay (Ctrl+Shift+D): process-tree CPU / PDH GPU / working-set +
private-commit RAM / network rates / FPS / current-track download progress
read from the backend's own StreamProgress / live normalization state /
preview session phase. Polls only while visible.

131 JS + player + app tests green; every path verified live over CDP.
2026-07-23 16:05:14 -05:00

142 lines
5.4 KiB
Rust

mod commands;
mod config;
mod cover_logo;
mod diagnostics;
mod hero_crop;
mod hero_detector;
mod loudness;
mod pipeline;
mod playback;
mod preview;
mod state;
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
tauri::Builder::default()
.manage(state::AppState::default())
.setup(|app| {
app.handle().plugin(
tauri_plugin_log::Builder::default()
.level(log::LevelFilter::Info)
.clear_targets()
.target(tauri_plugin_log::Target::new(
tauri_plugin_log::TargetKind::Stdout,
))
.build(),
)?;
app.handle().plugin(tauri_plugin_dialog::init())?;
// Must run before anything touches the app-data dir.
config::migrate_app_data(app.handle());
// Prepare the small local vision model while the user is still on
// the app shell, so a first artist visit pays only warm inference.
hero_detector::warm_up(app.handle().clone());
playback::init(app.handle());
playback::prune_cache(app.handle());
preview::init(app.handle());
loudness::init(app.handle());
diagnostics::init(app.handle());
if let Err(e) = pipeline::init(app.handle()) {
log::error!("library init failed: {e}");
}
Ok(())
})
.invoke_handler(tauri::generate_handler![
commands::app_status,
commands::excluded_search_phrases,
commands::get_credentials,
commands::connect_and_login,
commands::connect_stored,
commands::disconnect,
commands::start_search,
commands::stop_search,
commands::download_file,
commands::copy_stream_to_folder,
commands::save_to_library,
commands::cancel_download,
commands::show_in_folder,
commands::refresh_artist_art,
commands::play_stream,
commands::play_local,
commands::preload_local,
commands::player_control,
commands::waveform,
commands::library_albums,
commands::album_tracks,
commands::album_art,
commands::refresh_album_art,
commands::refresh_all_album_art,
commands::get_settings,
commands::set_settings,
commands::forget_credentials,
commands::pick_folder,
commands::open_external,
commands::record_play,
commands::add_play_seconds,
commands::artist_play_stats,
commands::list_playlists,
commands::create_playlist,
commands::delete_playlist,
commands::playlist_tracks,
commands::add_to_playlist,
commands::remove_from_playlist,
commands::catalog_search,
commands::catalog_artist,
commands::catalog_artist_art,
commands::catalog_artist_logos,
commands::catalog_artist_identity,
commands::catalog_artist_socials,
commands::catalog_artist_bio,
commands::catalog_cached_cover_logo,
commands::catalog_cover_logo,
commands::catalog_cover_logo_debug,
commands::catalog_ocr_experiment,
commands::catalog_artist_hero_seed,
commands::catalog_artist_overview,
commands::pick_artist_hero,
commands::clear_artist_hero,
commands::catalog_related,
commands::catalog_album,
commands::catalog_album_info,
commands::catalog_art,
commands::catalog_cover,
commands::invalidate_catalog_cover,
commands::catalog_hero_preview,
commands::catalog_hero_gpu_source,
commands::catalog_cached_hero_art,
commands::catalog_hero_art,
commands::preload_stream,
commands::preload_cached_stream,
commands::stream_waveform,
preview::preview_resolve,
preview::preview_load,
preview::preview_control,
preview::preview_dispose,
preview::player_pause_acked,
preview::player_fade_pause_acked,
preview::player_fade_resume,
diagnostics::debug_stats,
])
.run({
#[allow(unused_mut)]
let mut context = tauri::generate_context!();
// Debug builds expose CDP on 9222 for instrumentation (see HANDOFF.md).
// wry always sets AdditionalBrowserArguments programmatically, so the
// WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS env var is ignored; the flag has
// to go through the window config. Explicit args replace wry's defaults,
// so those are restated here.
#[cfg(debug_assertions)]
{
for window in &mut context.config_mut().app.windows {
window.additional_browser_args = Some(
"--disable-features=msWebOOUI,msPdfOOUI,msSmartScreenProtection \
--autoplay-policy=no-user-gesture-required \
--remote-debugging-port=9222"
.into(),
);
}
}
context
})
.expect("error while running tauri application");
}