Skip to content

Commit 6c8e629

Browse files
author
NellowTCS
committed
more fixes
1 parent 838ffec commit 6c8e629

4 files changed

Lines changed: 341 additions & 66 deletions

File tree

Build/src/core/ARCHITECTURE.md

Lines changed: 240 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,240 @@
1+
# Komorebi Architecture - Complete Feature Map
2+
3+
## Current Status (Built & TypeScript Clean)
4+
5+
### Core Engine (src/core/engine/)
6+
7+
- State machine (idle, loading, ready, playing, paused, transitioning, error)
8+
- QueueManager with smart shuffle and history tracking
9+
- Smart shuffle with PointPerSong integration (weighted random selection)
10+
- CrossfadeScheduler (linear, equalpower curves)
11+
- GaplessScheduler (ITUNSMPB offset handling)
12+
- KomorebiEvents emitter (no deps)
13+
- KomorebiEngine main class
14+
15+
### Platform Audio (src/platform/audio/)
16+
17+
- IAudioBackend interface (with off* methods for event unsubscribe)
18+
- BaseAudioBackend abstract class (inheritance base for all backends)
19+
- HTMLAudioBackend (HTML5 Audio wrapper)
20+
- WebAudioBackend (Web Audio API)
21+
- FloBackend (flo decoder wrapper)
22+
- HybridBackend (HTML5 + WebAudio switch)
23+
- PitchBackend (Tone.js wrapper, lazy-loaded)
24+
- Equalizer (10-band with presets)
25+
- PreloadManager (smart caching)
26+
- ReplayGainAnalyzer (loudness analysis)
27+
28+
### Tests (Build/tests/) - 181 passing
29+
30+
- engine.test.ts
31+
- queue.test.ts
32+
- library.test.ts
33+
- settings.test.ts
34+
- audio.test.ts
35+
- scoring.test.ts
36+
- smartPlaylist.test.ts
37+
- providers.test.ts
38+
- replayGain.test.ts
39+
40+
---
41+
42+
## Full Feature Scope
43+
44+
### 1. Playback Engine (Core) - DONE
45+
46+
**Implemented:**
47+
48+
- State machine with valid transitions
49+
- Queue with smart shuffle and play history
50+
- Crossfade scheduler with curves
51+
- Gapless scheduler with offset handling
52+
- Volume, tempo, pitch controls
53+
- Repeat modes (off, one, all)
54+
- Commands: load, play, pause, stop, next, prev, seek
55+
56+
**Wiring Required:**
57+
58+
- [ ] Wire to React hook (useKomorebi)
59+
60+
---
61+
62+
### 2. Library Management (Platform) - DONE
63+
64+
**Implemented:**
65+
66+
- Track CRUD operations
67+
- Playlist/folder management
68+
- Favorites
69+
- Search (title, artist, album)
70+
- IndexedDB persistence
71+
- PointPerSongEngine (scoring, weighted random)
72+
- DuplicateDetector (hash + metadata)
73+
- SmartPlaylistEngine (rules-based)
74+
- Integrate PointPerSong into queue shuffle
75+
76+
**Wiring Required:**
77+
78+
- [ ] Add manual boost UI to SongActionsDropdown
79+
- [ ] "Choose for me" auto-play button
80+
81+
---
82+
83+
### 3. Settings (Platform) - DONE
84+
85+
**Implemented:**
86+
87+
- All settings state with defaults
88+
- Theme/wallpaper settings
89+
- Crossfade, gapless, shuffle settings
90+
- Language setting
91+
- Tempo, pitch settings
92+
- Session restore setting
93+
94+
**Wiring Required:**
95+
96+
- [ ] Wire to React useSettings hook
97+
98+
---
99+
100+
### 4. Audio Backends (Platform) - DONE
101+
102+
**Implemented:**
103+
104+
- IAudioBackend interface (with offTimeUpdate, offEnded, offError)
105+
- BaseAudioBackend abstract class
106+
- HTMLAudioBackend
107+
- WebAudioBackend
108+
- FloBackend (flo decoder wrapper)
109+
- HybridBackend (HTML5 + WebAudio switch)
110+
- PitchBackend (Tone.js wrapper, lazy-loaded)
111+
- Equalizer (10-band with presets)
112+
- PreloadManager (smart caching)
113+
114+
**Wiring Required:**
115+
116+
- [ ] Wire to React hook
117+
118+
---
119+
120+
### 5. Metadata (Platform) - DONE
121+
122+
**Implemented:**
123+
124+
- BaseMetadataExtractor abstract class
125+
- MetadataExtractor using music-metadata
126+
- Album art extraction (embedded)
127+
- Embedded lyrics (SYLT, USLT, LRC)
128+
- Gapless info extraction
129+
- Batch metadata extraction
130+
- FloMetadataExtractor (flo audio info)
131+
132+
**Wiring Required:**
133+
134+
- [ ] Wire external lyrics providers to UI
135+
- [ ] Wire album art providers to UI
136+
137+
**Future:**
138+
139+
- [ ] Metadata editor
140+
- [x] ReplayGain support (in platform/audio/replayGain.ts)
141+
142+
---
143+
144+
### 6. Providers (Platform) - DONE
145+
146+
**Implemented:**
147+
148+
- BaseProvider abstract class
149+
- LyricsOvhProvider (lyrics.ovh API)
150+
- LRCLyricsProvider (LRC file parser)
151+
- LyricsManager (multi-provider fetching)
152+
- MusicBrainzProvider (Cover Art Archive)
153+
- DiscogsProvider (Discogs API)
154+
- AlbumArtManager (multi-provider fetching)
155+
156+
**Future:**
157+
158+
- [ ] Add more lyrics providers (KSoft, etc.)
159+
- [ ] Add Spotify cover art lookup
160+
- [ ] Last.fm scrobbling provider
161+
162+
---
163+
164+
### 7. Integrations - DONE
165+
166+
**Implemented:**
167+
168+
- BaseIntegration abstract class
169+
- DiscordIntegration (RPC interface)
170+
- MediaSessionIntegration (system media controls)
171+
172+
**Future:**
173+
174+
- [ ] Subsonic API support
175+
- [ ] Last.fm scrobbling
176+
- [ ] Whisper-based live lyrics
177+
- [ ] HTMLPlayer Store
178+
179+
---
180+
181+
### 8. Storage & Platform - DONE
182+
183+
**Implemented:**
184+
185+
- BaseStorageBackend abstract class
186+
- WebStorageBackend (file picker, showDirectoryPicker)
187+
- DesktopStorageBackend (Tauri dialog, fs)
188+
- SessionManager (save/restore state)
189+
190+
**Future:**
191+
192+
- [ ] Tauri desktop build
193+
- [ ] PiP (Picture-in-Picture)
194+
- [ ] Safari fallback fixes
195+
196+
---
197+
198+
### 9. UI Components (App) - Existing
199+
200+
**Current Components:**
201+
202+
- Player, Miniplayer, Visualizer, Lyrics
203+
- Home, MainContent, Sidebar
204+
- Playlist, SongActionsDropdown
205+
- Settings, HelpGuide, UpdatePrompt
206+
- UI primitives (Button, Input, Slider, etc.)
207+
208+
**Future:**
209+
210+
- [ ] Global search modal (Spotlight-style)
211+
- [ ] Queue visualization
212+
- [ ] Animated album art transitions
213+
- [ ] Dynamic theming (album art colors)
214+
- [ ] List virtualization (react-window)
215+
- [ ] Drag/drop to playlist from Home
216+
- [ ] Help menu per-context
217+
- [ ] Mobile responsive fixes
218+
219+
---
220+
221+
### 10. Performance (Bugs)
222+
223+
**Future:**
224+
225+
- [ ] RAM optimization (target 200MB)
226+
- [ ] List virtualization for large libraries
227+
- [ ] Debounce rapid control clicks
228+
- [ ] Lazy load playlist art
229+
230+
---
231+
232+
## Testing Strategy
233+
234+
- [x] Unit tests for engine
235+
- [x] Unit tests for library
236+
- [x] Unit tests for settings
237+
- [x] Unit tests for audio backends
238+
- [x] Unit tests for scoring
239+
- [ ] Integration tests for backends
240+
- [ ] E2E tests for critical flows

Build/src/helpers/filePickerHelper.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,8 @@ export async function extractAudioMetadata(file: File): Promise<AudioMetadata> {
502502
// Process album art if available
503503
let albumArt: string | undefined = undefined;
504504
if (cover && cover.data && cover.data.length > 0) {
505-
const blob = new Blob([cover.data], { type: cover.mime_type });
505+
const uint8Array = new Uint8Array(cover.data);
506+
const blob = new Blob([uint8Array], { type: cover.mime_type });
506507
albumArt = await new Promise<string>((resolve, reject) => {
507508
const reader = new FileReader();
508509
reader.onloadend = () => resolve(reader.result as string);
@@ -569,14 +570,14 @@ export async function extractAudioMetadata(file: File): Promise<AudioMetadata> {
569570
}
570571
}
571572
// Fallback to original (music-metadata) for all other formats
572-
let MetadataWorkerType: typeof Worker;
573+
let MetadataWorkerType: new () => Worker;
573574
if (typeof __IS_SINGLE_FILE__ !== "undefined" && __IS_SINGLE_FILE__) {
574575
MetadataWorkerType = (
575576
await import("../workers/metadataWorker.ts?worker&inline")
576-
).default;
577+
).default as new () => Worker;
577578
} else {
578-
MetadataWorkerType = (await import("../workers/metadataWorker.ts?worker"))
579-
.default;
579+
MetadataWorkerType = ((await import("../workers/metadataWorker.ts?worker"))
580+
.default as new () => Worker);
580581
}
581582
const worker = new MetadataWorkerType();
582583

Build/src/helpers/importAudioFiles.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ export async function importAudioFiles(
4646
// Safari: Pre-decode to WAV for compatibility
4747
const { decodeFloToWav } = await import("./refloWavHelper");
4848
const wavBytes = await decodeFloToWav(arrayBuffer);
49-
const wavBlob = new Blob([wavBytes], { type: "audio/wav" });
49+
const wavArray = new Uint8Array(wavBytes);
50+
const wavBlob = new Blob([wavArray], { type: "audio/wav" });
5051
processedFile = new File(
5152
[wavBlob],
5253
file.name.replace(/\.flo$/i, ".wav"),

0 commit comments

Comments
 (0)