Commit graph

27 commits

Author SHA1 Message Date
Dallas Groot
346b3ef378 quick fix 2026-04-11 19:28:18 -07:00
Dallas Groot
282eb5d80c Fixed idle visualizer bug
AudioPlayer.swift — startRadioSimulation() replaces
startLevelSimulation() for radio streams. It generates two overlapping
sine waves with a slow breathing amplitude envelope. The key property:
it’s driven by an internal radioPhase counter that increments at a
fixed rate, completely independent of currentTime. Buffer seeks, HLS
restarts, and stream reconnects have zero visual effect.
MitsuhaVisualizerView.swift — Two fixes:
	1.	TimelineView(.periodic(from: .distantPast, by: tickInterval)) —
using .distantPast as the stable schedule origin instead of .now.
Previously, any recalculation of tickInterval (triggered by
isRenderingActive flipping during a radio buffer hiccup) would reset
the origin to the current moment, deferring the next tick by a full
interval — the visible stall.
	2.	songId parameter with .onChange(of: songId) that resets
peakFollower, levelHistoryBuf, and lastTickTime on song change. This
prevents the outgoing song’s simulation spike from “raising” the wave
at the start of the next song.
NowPlayingView.swift and MainTabView.swift — Pass songId:
audioPlayer.currentSong?.id through to MitsuhaVisualizerView and
CompactVisualizerView at all call sites.
2026-04-11 19:01:10 -07:00
Dallas Groot
f3b9483b23 overhaul
AUDIT-036 — Slider/button fixes (direct Liquid Glass cause)
scheduleFlush() now runs Task { @MainActor } instead of bare Task. The
pendingSaves dictionary is now only ever read/written on the main
thread. Before this fix, a UserDefaults write could race with a slider
didSet, causing values to snap back or write the wrong value — which
is exactly why buttons were switching state unexpectedly.
AUDIT-034 — 60fps idle Canvas (direct Liquid Glass cause)
TimelineView now uses isRenderingActive ? settings.effectiveFPS : 2.0.
When paused or not visible, the Canvas drops from 60fps to 2fps. This
stops the continuous GPU wakeups that were fighting Liquid Glass
gesture tracking, which is why sliders needed multiple attempts.
AUDIT-001 — FFT real-time heap allocation
processFFT no longer allocates any heap memory. The Hann window is
computed once in init(). All four scratch buffers (fftWindow,
fftWindowed, fftRealp/fftImagp, fftMagnitudes) are pre-allocated and
reused every render callback — zero allocations on the real-time audio
thread.
AUDIT-002 — WatchOfflineStore data race
taskToSongId and pendingSongs now protected by a dedicated serial
storeQueue. URLSession delegate reads and main thread writes are
serialised.
AUDIT-019 — URLSession per AsyncCoverArt render
CompanionAPIService() no longer instantiated per render. Companion
cover art URLs now built directly from
CompanionSettings.shared.baseURL — no URLSession created.
AUDIT-020 — Synchronous disk read on main thread
CachedImageLoader now uses memoryOnlyImage (sync, no I/O) for the
first check, then cachedImageAsync (disk read on ioQueue) for the
second. Main thread never blocks on disk I/O.
AUDIT-033 — Lost star/unstar actions offline
Star/unstar now routes through OptimisticActionQueue — actions survive
Tailscale reconnection and are retried automatically.
AUDIT-035 — OptimisticActionQueue flush race
flush() Task is now @MainActor — pendingActions only ever touched on
main thread, no more race between rapid taps and in-flight flushes.
AUDIT-038 — O(n²) deduplication
deduplicateAlbums now O(n) using a frequency dictionary. For 843
albums: ~7.1M string comparisons/second during playback → ~1,700.
AUDIT-026, AUDIT-015 — Duplicate setResourceValue removed, cacheSize
now uses totalSize directly
2026-04-11 11:17:40 -07:00
Dallas Groot
454d169a11 pause fix on visualizer 2026-04-10 19:20:27 -07:00
Dallas Groot
a4103c8250 bug fixes and ready to upload to testflight 2026-04-10 19:05:45 -07:00
Dallas Groot
2bdac607b4 bug fixes
Songs Tab (SearchView.swift)
Default state now loads all songs alphabetically from the library via
getAlbumList2 → per-album song fetch, cached under "all_songs_sorted"
so subsequent opens are instant. The Download All banner shows song
count + already-downloaded count and queues only non-downloaded songs.
Every row uses .contextMenu (the long-press menu) with Play Now, Play
Next, Add to Queue, Download/Remove, Send to Watch, and Add to
Playlist — same pattern as Favourites. Watch and download badges
appear on each row. Searching ≥2 chars runs the server search and
shows artists/albums/songs in sections, then clears back to the full
list when the field is empty.
Keyboard Done Button
A single keyboardDoneButton() View extension in AsyncCoverArt.swift
calls UIApplication.shared.sendAction(resignFirstResponder:...)
globally — no @FocusState needed. Applied to: LoginView (all 4
fields), CompanionSettingsView (host/port), TrackEditorView
(checkField helper covers all tag fields), BatchAlbumEditorSheet
(editField helper), RadioView (name/URL), PlaylistsView (name fields),
MyMusicView (search), SearchView (via @FocusState + toolbar directly).
ShazamKit MTAudioProcessingTap
Primary path: MTAudioProcessingTap installed on AVPlayerItem.audioMix
— works for HLS, radio, and any AVPlayer stream without touching the
microphone. The prepare callback captures the source format and builds
an AVAudioConverter to 16kHz mono. The C-style shazamTapProcess free
function (required by the API) calls
MTAudioProcessingTapGetSourceAudio then dispatches to a serial
analysisQueue — the render thread is never blocked. convertAndMatch
wraps the raw AudioBufferList in an AVAudioPCMBuffer, converts it, and
feeds SHSession.matchStreamingBuffer. Fallback to microphone
(AVAudioEngine) is kept for the local engine path where no
AVPlayerItem exists. NSMicrophoneUsageDescription is only needed if
the mic fallback is ever hit.
2026-04-10 16:55:09 -07:00
Dallas Groot
00ffd7970e Performance Improvements
Phase 1 — VisualizerStorageManager.swift
VisFrameBuffer is a flat ContiguousArray<Float> with frameCount and
pointsPerFrame. All frame data for a track lives in one contiguous
allocation rather than a [[Float]] array-of-arrays. loadCache now uses
Data(contentsOf:options:.alwaysMapped) — the OS maps the file into
virtual memory and faults pages in on demand rather than reading the
whole file into heap. copyFrame(at:into:) copies a frame slice
directly into _audioLevels using initialize(from:) — no intermediate
[Float] created.
Phase 2 — MitsuhaVisualizerView.swift + AudioPlayer.swift
VisualizerLevelBox now pre-allocates targetLevels, displayLevels,
idleLevels, and the full 16-slot history ring on first use via
resizeIfNeeded. This only triggers when numberOfPoints changes (rare —
settings slider). updateDisplayLevels writes directly into
box.targetLevels throughout — no var targetLevels = [Float](), no map,
no append. The history ring buffer now copies in-place into
pre-allocated slots, eliminating the COW trigger on every frame.
drawIdleState uses box.idleLevels — no Array(repeating:). The Canvas
body no longer falls back to Array(repeating:) since displayLevels is
always pre-allocated. The timer in AudioPlayer now calls
buf.copyFrame(at:into:&_audioLevels) directly — no intermediate
[Float] copy.
Phase 3 — View invalidation + drawBars fix
fillColors hoisted out of the drawBars per-bar loop — it was
allocating a new [Color] array count times per frame (8–24 allocations
per draw call at 60fps). Now computed once before the loop.
@ObservedObject var settings and @StateObject private var box are
correct — box has zero @Published properties so it never triggers
parent redraws. The Canvas closure only captures tickDate which
changes every tick, ensuring per-tick re-execution without touching
SwiftUI’s diffing engine.
2026-04-10 16:25:49 -07:00
Dallas Groot
1bee53531c quick fix for visualizer heating up device 2026-04-10 13:16:12 -07:00
Dallas Groot
07ef5bc8e8 bug fixes 2026-04-10 07:00:30 -07:00
d0cfb4053a revert 63114f02fb
revert fixed project info
2026-04-10 00:31:29 -07:00
Dallas Groot
63114f02fb fixed project info 2026-04-10 00:22:17 -07:00
Dallas Groot
b1101a6ea3 More Fixes and Radio improvements 2026-04-09 23:39:52 -07:00
Dallas Groot
9bf94c90b7 Imrpved Nowplaying/Visualizer 2026-04-09 23:11:40 -07:00
Dallas Groot
26771bc99e is this the fix i'm looking for? 2026-04-05 22:47:57 -07:00
Dallas Groot
32ab1a0e9a Update from NavidromePlayer.zip (2026-04-05 12:12) 2026-04-05 12:12:53 -07:00
Dallas Groot
75a4343ad1 more fixes 2026-04-05 12:05:20 -07:00
Dallas Groot
bbb7faf488 ... 2026-04-05 09:02:56 -07:00
Dallas Groot
920eab741d ... 2026-04-05 08:51:26 -07:00
Dallas Groot
0df9057add lol more fixes 2026-04-05 08:43:08 -07:00
Dallas Groot
2b879fd153 Mitsuha pause fixes and other bugs 2026-04-05 08:33:00 -07:00
Dallas Groot
989412fda5 improvong the settings tab 2026-04-05 08:23:07 -07:00
Dallas Groot
f1f98fbf7d Finaly fixed Visualizer tweaks to make it more jello-y 2026-04-04 23:17:47 -07:00
Dallas Groot
899e9e7c2f Update from NavidromePlayer.zip (2026-04-04 07:05) 2026-04-04 07:05:25 -07:00
Dallas Groot
c3bce4a997 Update from NavidromePlayer.zip (2026-04-04 06:58) 2026-04-04 06:58:58 -07:00
Dallas Groot
4787e2a5d4 Update from NavidromePlayer.zip (2026-04-04 00:14) 2026-04-04 00:14:41 -07:00
Dallas Groot
b1b7d4b695 Favourites tab, artist cover change, ArtistCoverStore 2026-03-31 11:35:42 -07:00
Dallas Groot
d8041c0019 NavidromePlayer: iOS + watchOS Navidrome/Subsonic music player
Features:
- Dual-AVPlayer Smart DJ crossfade with LUFS normalization
- Mitsuha-style FFT visualizer (real-time + offline pre-computed)
- Companion API integration (Smart DJ, tag editing, vis frames)
- Offline-first SyncEngine with delta sync and album detail pre-caching
- Audio pre-fetcher for gapless queue playback
- Optimistic action queue (star/unstar with background retry)
- ShazamKit recognition with MusicKit preview playback
- Radio streaming with HLS/PLS/M3U support and buffer seek
- Watch app with Crown Sequencer and Ultra speaker support
- Batch metadata editing with album_artist fix for split albums
- Cache-first UI pattern across all views
- NWPathMonitor offline detection with reactive song greying
2026-03-28 20:49:47 +00:00