loukai-app 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +558 -0
- package/bin/loukai.js +32 -0
- package/package.json +243 -0
- package/src/main/appState.js +250 -0
- package/src/main/audioEngine.js +478 -0
- package/src/main/creator/conversionService.js +503 -0
- package/src/main/creator/downloadManager.js +1128 -0
- package/src/main/creator/ffmpegService.js +487 -0
- package/src/main/creator/installLogger.js +51 -0
- package/src/main/creator/keyDetection.js +212 -0
- package/src/main/creator/llmService.js +370 -0
- package/src/main/creator/lrclibService.js +340 -0
- package/src/main/creator/python/crepe_runner.py +189 -0
- package/src/main/creator/python/demucs_runner.py +158 -0
- package/src/main/creator/python/whisper_runner.py +172 -0
- package/src/main/creator/pythonRunner.js +268 -0
- package/src/main/creator/stemBuilder.js +491 -0
- package/src/main/creator/systemChecker.js +474 -0
- package/src/main/handlers/appHandlers.js +45 -0
- package/src/main/handlers/audioHandlers.js +33 -0
- package/src/main/handlers/autotuneHandlers.js +28 -0
- package/src/main/handlers/canvasHandlers.js +84 -0
- package/src/main/handlers/creatorHandlers.js +159 -0
- package/src/main/handlers/editorHandlers.js +98 -0
- package/src/main/handlers/effectsHandlers.js +100 -0
- package/src/main/handlers/fileHandlers.js +45 -0
- package/src/main/handlers/index.js +78 -0
- package/src/main/handlers/libraryHandlers.js +96 -0
- package/src/main/handlers/mixerHandlers.js +64 -0
- package/src/main/handlers/playerHandlers.js +39 -0
- package/src/main/handlers/preferencesHandlers.js +46 -0
- package/src/main/handlers/queueHandlers.js +81 -0
- package/src/main/handlers/rendererHandlers.js +63 -0
- package/src/main/handlers/settingsHandlers.js +42 -0
- package/src/main/handlers/webServerHandlers.js +105 -0
- package/src/main/main.js +2351 -0
- package/src/main/preload.js +252 -0
- package/src/main/settingsManager.js +139 -0
- package/src/main/statePersistence.js +193 -0
- package/src/main/utils/pathValidator.js +112 -0
- package/src/main/webServer.js +2535 -0
- package/src/native/autotune.js +417 -0
- package/src/renderer/adapters/ElectronBridge.js +677 -0
- package/src/renderer/canvas.html +80 -0
- package/src/renderer/components/App.jsx +303 -0
- package/src/renderer/components/AppRoot.jsx +37 -0
- package/src/renderer/components/AudioDeviceSettings.jsx +145 -0
- package/src/renderer/components/EffectsPanelWrapper.jsx +267 -0
- package/src/renderer/components/MixerTab.jsx +233 -0
- package/src/renderer/components/MixerTabWrapper.jsx +31 -0
- package/src/renderer/components/PortalSelect.jsx +239 -0
- package/src/renderer/components/QueueTab.jsx +116 -0
- package/src/renderer/components/RequestsListWrapper.jsx +78 -0
- package/src/renderer/components/ServerTab.jsx +472 -0
- package/src/renderer/components/SongInfoBarWrapper.jsx +77 -0
- package/src/renderer/components/StatusBar.jsx +92 -0
- package/src/renderer/components/TabNavigation.jsx +77 -0
- package/src/renderer/components/TransportControlsWrapper.jsx +69 -0
- package/src/renderer/components/creator/CreateTab.jsx +1236 -0
- package/src/renderer/dist/assets/kaiPlayer-CoMx__a_.js +2 -0
- package/src/renderer/dist/assets/kaiPlayer-CoMx__a_.js.map +1 -0
- package/src/renderer/dist/assets/microphoneEngine-BaCUhhQc.js +2 -0
- package/src/renderer/dist/assets/microphoneEngine-BaCUhhQc.js.map +1 -0
- package/src/renderer/dist/assets/player-DVrqp7N5.js +3 -0
- package/src/renderer/dist/assets/player-DVrqp7N5.js.map +1 -0
- package/src/renderer/dist/assets/songLoaders-BaTgGib4.js +2 -0
- package/src/renderer/dist/assets/songLoaders-BaTgGib4.js.map +1 -0
- package/src/renderer/dist/assets/webrtcManager-BhCHWceK.js +2 -0
- package/src/renderer/dist/assets/webrtcManager-BhCHWceK.js.map +1 -0
- package/src/renderer/dist/js/autoTuneWorklet.js +224 -0
- package/src/renderer/dist/js/micPitchDetectorWorklet.js +137 -0
- package/src/renderer/dist/js/musicAnalysisWorklet.js +216 -0
- package/src/renderer/dist/js/phaseVocoderWorklet.js +341 -0
- package/src/renderer/dist/js/soundtouch-worklet.js +1395 -0
- package/src/renderer/dist/renderer.css +1 -0
- package/src/renderer/dist/renderer.js +62 -0
- package/src/renderer/dist/renderer.js.map +1 -0
- package/src/renderer/dist/renderer.woff2 +0 -0
- package/src/renderer/hooks/useKeyboardShortcuts.js +154 -0
- package/src/renderer/index.html +24 -0
- package/src/renderer/index.html.backup +372 -0
- package/src/renderer/js/PlayerInterface.js +267 -0
- package/src/renderer/js/autoTuneWorklet.js +224 -0
- package/src/renderer/js/butterchurnVerify.js +46 -0
- package/src/renderer/js/canvas-app.js +114 -0
- package/src/renderer/js/cdgPlayer.js +685 -0
- package/src/renderer/js/kaiPlayer.js +1200 -0
- package/src/renderer/js/karaokeRenderer.js +3392 -0
- package/src/renderer/js/micPitchDetectorWorklet.js +137 -0
- package/src/renderer/js/microphoneEngine.js +656 -0
- package/src/renderer/js/musicAnalysisWorklet.js +216 -0
- package/src/renderer/js/phaseVocoderWorklet.js +341 -0
- package/src/renderer/js/player.js +232 -0
- package/src/renderer/js/referencePitchTracker.js +130 -0
- package/src/renderer/js/songLoaders.js +334 -0
- package/src/renderer/js/soundtouch-worklet.js +1395 -0
- package/src/renderer/js/webrtcManager.js +511 -0
- package/src/renderer/lib/butterchurn.min.js +6739 -0
- package/src/renderer/lib/butterchurnPresets.min.js +1 -0
- package/src/renderer/lib/cdgraphics-wrapper.js +16 -0
- package/src/renderer/lib/cdgraphics.js +299 -0
- package/src/renderer/public/js/autoTuneWorklet.js +224 -0
- package/src/renderer/public/js/micPitchDetectorWorklet.js +137 -0
- package/src/renderer/public/js/musicAnalysisWorklet.js +216 -0
- package/src/renderer/public/js/phaseVocoderWorklet.js +341 -0
- package/src/renderer/public/js/soundtouch-worklet.js +1395 -0
- package/src/renderer/react-entry.jsx +44 -0
- package/src/renderer/styles/tailwind.css +106 -0
- package/src/renderer/utils/qrCodeGenerator.js +98 -0
- package/src/renderer/vite.config.js +31 -0
- package/src/shared/adapters/BridgeInterface.js +195 -0
- package/src/shared/components/EffectsPanel.jsx +177 -0
- package/src/shared/components/LibraryPanel.jsx +701 -0
- package/src/shared/components/LineDetailCanvas.jsx +167 -0
- package/src/shared/components/LyricLine.jsx +505 -0
- package/src/shared/components/LyricRejection.jsx +84 -0
- package/src/shared/components/LyricSuggestion.jsx +80 -0
- package/src/shared/components/LyricsEditorCanvas.jsx +271 -0
- package/src/shared/components/MixerPanel.jsx +94 -0
- package/src/shared/components/PlayerControls.jsx +206 -0
- package/src/shared/components/PortalSelect.jsx +239 -0
- package/src/shared/components/QueueList.jsx +365 -0
- package/src/shared/components/QuickSearch.jsx +126 -0
- package/src/shared/components/RequestsList.jsx +121 -0
- package/src/shared/components/SongEditor.jsx +1362 -0
- package/src/shared/components/SongInfoBar.jsx +81 -0
- package/src/shared/components/ThemeToggle.jsx +106 -0
- package/src/shared/components/Toast.jsx +30 -0
- package/src/shared/components/VisualizationSettings.jsx +243 -0
- package/src/shared/constants.js +95 -0
- package/src/shared/context/BridgeContext.jsx +32 -0
- package/src/shared/contexts/AudioContext.jsx +37 -0
- package/src/shared/contexts/PlayerContext.jsx +66 -0
- package/src/shared/contexts/SettingsContext.jsx +50 -0
- package/src/shared/defaults.js +158 -0
- package/src/shared/formatUtils.js +59 -0
- package/src/shared/formatUtils.test.js +207 -0
- package/src/shared/hooks/useAppState.js +97 -0
- package/src/shared/hooks/useAudioEngine.js +264 -0
- package/src/shared/hooks/usePlayer.js +89 -0
- package/src/shared/hooks/useSettingsPersistence.js +74 -0
- package/src/shared/hooks/useWebRTC.js +118 -0
- package/src/shared/ipcContracts.js +299 -0
- package/src/shared/package.json +3 -0
- package/src/shared/services/creatorService.js +373 -0
- package/src/shared/services/creatorService.test.js +413 -0
- package/src/shared/services/editorService.js +213 -0
- package/src/shared/services/editorService.test.js +219 -0
- package/src/shared/services/effectsService.js +271 -0
- package/src/shared/services/effectsService.test.js +418 -0
- package/src/shared/services/libraryService.js +438 -0
- package/src/shared/services/libraryService.test.js +474 -0
- package/src/shared/services/mixerService.js +172 -0
- package/src/shared/services/mixerService.test.js +399 -0
- package/src/shared/services/playerService.js +221 -0
- package/src/shared/services/playerService.test.js +357 -0
- package/src/shared/services/preferencesService.js +219 -0
- package/src/shared/services/queueService.js +226 -0
- package/src/shared/services/queueService.test.js +430 -0
- package/src/shared/services/requestsService.js +155 -0
- package/src/shared/services/requestsService.test.js +362 -0
- package/src/shared/services/serverSettingsService.js +151 -0
- package/src/shared/services/settingsService.js +257 -0
- package/src/shared/services/settingsService.test.js +295 -0
- package/src/shared/state/StateManager.js +263 -0
- package/src/shared/utils/audio.js +42 -0
- package/src/shared/utils/format.js +32 -0
- package/src/shared/utils/lyricsUtils.js +162 -0
- package/src/test/setup.js +40 -0
- package/src/utils/cdgLoader.js +180 -0
- package/src/utils/m4aLoader.js +333 -0
- package/src/web/App.jsx +578 -0
- package/src/web/adapters/WebBridge.js +428 -0
- package/src/web/components/PlayerSettingsPanel.jsx +231 -0
- package/src/web/components/SongSearch.jsx +180 -0
- package/src/web/dist/assets/index-0H-RnRrV.js +51 -0
- package/src/web/dist/assets/index-0H-RnRrV.js.map +1 -0
- package/src/web/dist/assets/index-DYW2zB0u.css +1 -0
- package/src/web/dist/index.html +15 -0
- package/src/web/index.html +14 -0
- package/src/web/main.jsx +10 -0
- package/src/web/package-lock.json +1765 -0
- package/src/web/pages/SongRequestPage.jsx +619 -0
- package/src/web/styles/tailwind.css +68 -0
- package/src/web/vite.config.js +27 -0
- package/static/fonts/material-icons.woff2 +0 -0
- package/static/images/butterchurn-screenshots/Aderrasi - Potion of Spirits.png +0 -0
- package/static/images/butterchurn-screenshots/Aderrasi - Songflower _Moss Posy_.png +0 -0
- package/static/images/butterchurn-screenshots/Aderrasi - Storm of the Eye _Thunder_ - mash0000 - quasi pseudo meta concentrics.png +0 -0
- package/static/images/butterchurn-screenshots/Aderrasi _ Geiss - Airhandler _Kali Mix_ - Canvas Mix.png +0 -0
- package/static/images/butterchurn-screenshots/An AdamFX n Martin Infusion 2 flexi - Why The Sky Looks Diffrent Today - AdamFx n Martin Infusion - Tack Tile Disfunction B.png +0 -0
- package/static/images/butterchurn-screenshots/Cope - The Neverending Explosion of Red Liquid Fire.png +0 -0
- proton lights __Krash_s beat code_ _Phat_remix02b.png +0 -0
- package/static/images/butterchurn-screenshots/Eo_S_ _ Phat - cubetrace - v2.png +0 -0
- package/static/images/butterchurn-screenshots/Eo_S_ _ Zylot - skylight _Stained Glass Majesty mix_.png +0 -0
- package/static/images/butterchurn-screenshots/Flexi - alien fish pond.png +0 -0
- package/static/images/butterchurn-screenshots/Flexi - area 51.png +0 -0
- package/static/images/butterchurn-screenshots/Flexi - infused with the spiral.png +0 -0
- package/static/images/butterchurn-screenshots/Flexi - mindblob _shiny mix_.png +0 -0
- package/static/images/butterchurn-screenshots/Flexi - mindblob mix.png +0 -0
- package/static/images/butterchurn-screenshots/Flexi - predator-prey-spirals.png +0 -0
- package/static/images/butterchurn-screenshots/Flexi - smashing fractals _acid etching mix_.png +0 -0
- package/static/images/butterchurn-screenshots/Flexi - truly soft piece of software - this is generic texturing _Jelly_ .png +0 -0
- package/static/images/butterchurn-screenshots/Flexi _ Martin - astral projection.png +0 -0
- package/static/images/butterchurn-screenshots/Flexi _ Martin - cascading decay swing.png +0 -0
- package/static/images/butterchurn-screenshots/Flexi _ amandio c - piercing 05 - Kopie _2_ - Kopie.png +0 -0
- package/static/images/butterchurn-screenshots/Flexi _ stahlregen - jelly showoff parade.png +0 -0
- package/static/images/butterchurn-screenshots/Flexi_ fishbrain_ Geiss _ Martin - tokamak witchery.png +0 -0
- package/static/images/butterchurn-screenshots/Flexi_ martin _ geiss - dedicated to the sherwin maxawow.png +0 -0
- package/static/images/butterchurn-screenshots/Fumbling_Foo _ Flexi_ Martin_ Orb_ Unchained - Star Nova v7b.png +0 -0
- package/static/images/butterchurn-screenshots/Geiss - Cauldron - painterly 2 _saturation remix_.png +0 -0
- package/static/images/butterchurn-screenshots/Geiss - Reaction Diffusion 2.png +0 -0
- package/static/images/butterchurn-screenshots/Geiss - Spiral Artifact.png +0 -0
- package/static/images/butterchurn-screenshots/Geiss - Thumb Drum.png +0 -0
- package/static/images/butterchurn-screenshots/Geiss _ Flexi _ Martin - disconnected.png +0 -0
- package/static/images/butterchurn-screenshots/Geiss_ Flexi _ Stahlregen - Thumbdrum Tokamak _crossfiring aftermath jelly mashup_.png +0 -0
- package/static/images/butterchurn-screenshots/Goody - The Wild Vort.png +0 -0
- package/static/images/butterchurn-screenshots/Idiot - Star Of Annon.png +0 -0
- package/static/images/butterchurn-screenshots/Krash _ Illusion - Spiral Movement.png +0 -0
- package/static/images/butterchurn-screenshots/Martin - QBikal - Surface Turbulence IIb.png +0 -0
- package/static/images/butterchurn-screenshots/Martin - acid wiring.png +0 -0
- package/static/images/butterchurn-screenshots/Martin - charisma.png +0 -0
- package/static/images/butterchurn-screenshots/Martin - liquid arrows.png +0 -0
- package/static/images/butterchurn-screenshots/Milk Artist At our Best - FED - SlowFast Ft AdamFX n Martin - HD CosmoFX.png +0 -0
- package/static/images/butterchurn-screenshots/ORB - Waaa.png +0 -0
- package/static/images/butterchurn-screenshots/Phat_fiShbRaiN_Eo_S_Mandala_Chasers_remix.png +0 -0
- package/static/images/butterchurn-screenshots/Rovastar - Oozing Resistance.png +0 -0
- package/static/images/butterchurn-screenshots/Rovastar _ Loadus _ Geiss - FractalDrop _Triple Mix_.png +0 -0
- package/static/images/butterchurn-screenshots/TonyMilkdrop - Leonardo Da Vinci_s Balloon _Flexi - merry-go-round _ techstyle_.png +0 -0
- package/static/images/butterchurn-screenshots/TonyMilkdrop - Magellan_s Nebula _Flexi - you enter first _ multiverse_.png +0 -0
- package/static/images/butterchurn-screenshots/Unchained - Rewop.png +0 -0
- package/static/images/butterchurn-screenshots/Unchained - Unified Drag 2.png +0 -0
- package/static/images/butterchurn-screenshots/Unchained _ Rovastar - Wormhole Pillars _Hall of Shadows mix_.png +0 -0
- package/static/images/butterchurn-screenshots/Zylot - Paint Spill _Music Reactive Paint Mix_.png +0 -0
- package/static/images/butterchurn-screenshots/Zylot - Star Ornament.png +0 -0
- package/static/images/butterchurn-screenshots/Zylot - True Visionary _Final Mix_.png +0 -0
- package/static/images/butterchurn-screenshots/_Aderrasi - Wanderer in Curved Space - mash0000 - faclempt kibitzing meshuggana schmaltz _Geiss color mix_.png +0 -0
- package/static/images/butterchurn-screenshots/_Geiss - Artifact 01.png +0 -0
- package/static/images/butterchurn-screenshots/_Geiss - Desert Rose 2.png +0 -0
- package/static/images/butterchurn-screenshots/_Geiss - untitled.png +0 -0
- package/static/images/butterchurn-screenshots/_Mig_049.png +0 -0
- package/static/images/butterchurn-screenshots/_Mig_085.png +0 -0
- package/static/images/butterchurn-screenshots/_Rovastar _ Geiss - Hurricane Nightmare _Posterize Mix_.png +0 -0
- package/static/images/butterchurn-screenshots/___ Royal - Mashup _197_.png +0 -0
- package/static/images/butterchurn-screenshots/___ Royal - Mashup _220_.png +0 -0
- package/static/images/butterchurn-screenshots/___ Royal - Mashup _431_.png +0 -0
- package/static/images/butterchurn-screenshots/cope _ martin - mother-of-pearl.png +0 -0
- package/static/images/butterchurn-screenshots/fiShbRaiN _ Flexi - witchcraft 2_0.png +0 -0
- package/static/images/butterchurn-screenshots/flexi - bouncing balls _double mindblob neon mix_.png +0 -0
- package/static/images/butterchurn-screenshots/flexi - mom_ why the sky looks different today.png +0 -0
- package/static/images/butterchurn-screenshots/flexi - patternton_ district of media_ capitol of the united abstractions of fractopia.png +0 -0
- package/static/images/butterchurn-screenshots/flexi - swing out on the spiral.png +0 -0
- package/static/images/butterchurn-screenshots/flexi - what is the matrix.png +0 -0
- package/static/images/butterchurn-screenshots/flexi _ amandio c - organic _random mashup_.png +0 -0
- package/static/images/butterchurn-screenshots/flexi _ amandio c - organic12-3d-2_milk.png +0 -0
- package/static/images/butterchurn-screenshots/flexi _ fishbrain - neon mindblob grafitti.png +0 -0
- package/static/images/butterchurn-screenshots/flexi _ geiss - pogo cubes vs_ tokamak vs_ game of life _stahls jelly 4_5 finish_.png +0 -0
- package/static/images/butterchurn-screenshots/high-altitude basket unraveling - singh grooves nitrogen argon nz_.png +0 -0
- package/static/images/butterchurn-screenshots/martin - The Bridge of Khazad-Dum.png +0 -0
- package/static/images/butterchurn-screenshots/martin - angel flight.png +0 -0
- package/static/images/butterchurn-screenshots/martin - another kind of groove.png +0 -0
- package/static/images/butterchurn-screenshots/martin - bombyx mori.png +0 -0
- package/static/images/butterchurn-screenshots/martin - castle in the air.png +0 -0
- package/static/images/butterchurn-screenshots/martin - chain breaker.png +0 -0
- package/static/images/butterchurn-screenshots/martin - disco mix 4.png +0 -0
- package/static/images/butterchurn-screenshots/martin - extreme heat.png +0 -0
- package/static/images/butterchurn-screenshots/martin - frosty caves 2.png +0 -0
- package/static/images/butterchurn-screenshots/martin - fruit machine.png +0 -0
- package/static/images/butterchurn-screenshots/martin - ghost city.png +0 -0
- package/static/images/butterchurn-screenshots/martin - glass corridor.png +0 -0
- package/static/images/butterchurn-screenshots/martin - infinity _2010 update_.png +0 -0
- package/static/images/butterchurn-screenshots/martin - mandelbox explorer - high speed demo version.png +0 -0
- package/static/images/butterchurn-screenshots/martin - mucus cervix.png +0 -0
- package/static/images/butterchurn-screenshots/martin - reflections on black tiles.png +0 -0
- package/static/images/butterchurn-screenshots/martin - stormy sea _2010 update_.png +0 -0
- package/static/images/butterchurn-screenshots/martin - witchcraft reloaded.png +0 -0
- package/static/images/butterchurn-screenshots/martin _ flexi - diamond cutter _prismaticvortex_com_ - camille - i wish i wish i wish i was constrained.png +0 -0
- package/static/images/butterchurn-screenshots/martin _shadow harlequins shape code_ - fata morgana.png +0 -0
- package/static/images/butterchurn-screenshots/martin_ flexi_ fishbrain _ sto - enterstate _random mashup_.png +0 -0
- package/static/images/butterchurn-screenshots/sawtooth grin roam.png +0 -0
- package/static/images/butterchurn-screenshots/shifter - dark tides bdrv mix 2.png +0 -0
- package/static/images/butterchurn-screenshots/suksma - Rovastar - Sunflower Passion _Enlightment Mix__Phat_edit _ flexi und martin shaders - circumflex in character classes in regular expression.png +0 -0
- package/static/images/butterchurn-screenshots/suksma - heretical crosscut playpen.png +0 -0
- package/static/images/butterchurn-screenshots/suksma - uninitialized variabowl _hydroponic chronic_.png +0 -0
- package/static/images/butterchurn-screenshots/suksma - vector exp 1 - couldn_t not.png +0 -0
- package/static/images/butterchurn-screenshots/yin - 191 - Temporal singularities.png +0 -0
- package/static/images/logo-512.png +0 -0
- package/static/images/logo.png +0 -0
- package/static/loukai-logo.png +0 -0
- package/static/screenshot-generator.html +610 -0
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IPC Contracts - Central definition of all IPC channels
|
|
3
|
+
*
|
|
4
|
+
* This file defines all IPC communication channels between:
|
|
5
|
+
* - Main process (Node.js)
|
|
6
|
+
* - Renderer process (Electron UI)
|
|
7
|
+
*
|
|
8
|
+
* Benefits:
|
|
9
|
+
* - Single source of truth for all IPC channels
|
|
10
|
+
* - Easy to see all available APIs at a glance
|
|
11
|
+
* - Prevents typos in channel names
|
|
12
|
+
* - Makes refactoring safer
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
// ============================================================================
|
|
16
|
+
// APP CHANNELS
|
|
17
|
+
// ============================================================================
|
|
18
|
+
|
|
19
|
+
export const APP_CHANNELS = {
|
|
20
|
+
GET_VERSION: 'app:getVersion',
|
|
21
|
+
GET_STATE: 'app:getState',
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
// ============================================================================
|
|
25
|
+
// FILE CHANNELS
|
|
26
|
+
// ============================================================================
|
|
27
|
+
|
|
28
|
+
export const FILE_CHANNELS = {
|
|
29
|
+
OPEN_KAI: 'file:openKai',
|
|
30
|
+
LOAD_KAI_FROM_PATH: 'file:loadKaiFromPath',
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
// ============================================================================
|
|
34
|
+
// AUDIO CHANNELS
|
|
35
|
+
// ============================================================================
|
|
36
|
+
|
|
37
|
+
export const AUDIO_CHANNELS = {
|
|
38
|
+
GET_DEVICES: 'audio:getDevices',
|
|
39
|
+
ENUMERATE_DEVICES: 'audio:enumerateDevices',
|
|
40
|
+
SET_DEVICE: 'audio:setDevice',
|
|
41
|
+
|
|
42
|
+
// Events (main → renderer)
|
|
43
|
+
XRUN: 'audio:xrun',
|
|
44
|
+
LATENCY: 'audio:latency',
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
// ============================================================================
|
|
48
|
+
// MIXER CHANNELS
|
|
49
|
+
// ============================================================================
|
|
50
|
+
|
|
51
|
+
export const MIXER_CHANNELS = {
|
|
52
|
+
SET_MASTER_GAIN: 'mixer:setMasterGain',
|
|
53
|
+
TOGGLE_MASTER_MUTE: 'mixer:toggleMasterMute',
|
|
54
|
+
|
|
55
|
+
// Events (main → renderer)
|
|
56
|
+
STATE_CHANGE: 'mixer:state',
|
|
57
|
+
SET_MASTER_MUTE: 'mixer:setMasterMute',
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
// ============================================================================
|
|
61
|
+
// PLAYER CHANNELS
|
|
62
|
+
// ============================================================================
|
|
63
|
+
|
|
64
|
+
export const PLAYER_CHANNELS = {
|
|
65
|
+
PLAY: 'player:play',
|
|
66
|
+
PAUSE: 'player:pause',
|
|
67
|
+
SEEK: 'player:seek',
|
|
68
|
+
RESTART: 'player:restart',
|
|
69
|
+
NEXT: 'player:next',
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
// ============================================================================
|
|
73
|
+
// AUTOTUNE CHANNELS
|
|
74
|
+
// ============================================================================
|
|
75
|
+
|
|
76
|
+
export const AUTOTUNE_CHANNELS = {
|
|
77
|
+
SET_ENABLED: 'autotune:setEnabled',
|
|
78
|
+
SET_SETTINGS: 'autotune:setSettings',
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
// ============================================================================
|
|
82
|
+
// SONG CHANNELS
|
|
83
|
+
// ============================================================================
|
|
84
|
+
|
|
85
|
+
export const SONG_CHANNELS = {
|
|
86
|
+
GET_CURRENT_SONG: 'song:getCurrentSong',
|
|
87
|
+
|
|
88
|
+
// Events (main → renderer)
|
|
89
|
+
LOADED: 'song:loaded',
|
|
90
|
+
DATA: 'song:data',
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
// ============================================================================
|
|
94
|
+
// EDITOR CHANNELS
|
|
95
|
+
// ============================================================================
|
|
96
|
+
|
|
97
|
+
export const EDITOR_CHANNELS = {
|
|
98
|
+
SAVE_KAI: 'editor:saveKai',
|
|
99
|
+
RELOAD_KAI: 'editor:reloadKai',
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
// ============================================================================
|
|
103
|
+
// WINDOW CHANNELS
|
|
104
|
+
// ============================================================================
|
|
105
|
+
|
|
106
|
+
export const WINDOW_CHANNELS = {
|
|
107
|
+
OPEN_CANVAS: 'window:openCanvas',
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
// ============================================================================
|
|
111
|
+
// CANVAS CHANNELS
|
|
112
|
+
// ============================================================================
|
|
113
|
+
|
|
114
|
+
export const CANVAS_CHANNELS = {
|
|
115
|
+
START_STREAMING: 'canvas:startStreaming',
|
|
116
|
+
STOP_STREAMING: 'canvas:stopStreaming',
|
|
117
|
+
SEND_IMAGE_DATA: 'canvas:sendImageData',
|
|
118
|
+
SEND_ICE_CANDIDATE: 'canvas:sendICECandidate',
|
|
119
|
+
TOGGLE_FULLSCREEN: 'canvas:toggleFullscreen',
|
|
120
|
+
SEND_FRAME: 'canvas:sendFrame',
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
// ============================================================================
|
|
124
|
+
// LIBRARY CHANNELS
|
|
125
|
+
// ============================================================================
|
|
126
|
+
|
|
127
|
+
export const LIBRARY_CHANNELS = {
|
|
128
|
+
GET_SONGS_FOLDER: 'library:getSongsFolder',
|
|
129
|
+
SET_SONGS_FOLDER: 'library:setSongsFolder',
|
|
130
|
+
SCAN_FOLDER: 'library:scanFolder',
|
|
131
|
+
SYNC_LIBRARY: 'library:syncLibrary',
|
|
132
|
+
GET_CACHED_SONGS: 'library:getCachedSongs',
|
|
133
|
+
GET_SONG_INFO: 'library:getSongInfo',
|
|
134
|
+
|
|
135
|
+
// Events (main → renderer)
|
|
136
|
+
FOLDER_SET: 'library:folderSet',
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
// ============================================================================
|
|
140
|
+
// WEB SERVER CHANNELS
|
|
141
|
+
// ============================================================================
|
|
142
|
+
|
|
143
|
+
export const WEB_SERVER_CHANNELS = {
|
|
144
|
+
GET_PORT: 'webServer:getPort',
|
|
145
|
+
GET_URL: 'webServer:getUrl',
|
|
146
|
+
GET_SETTINGS: 'webServer:getSettings',
|
|
147
|
+
UPDATE_SETTINGS: 'webServer:updateSettings',
|
|
148
|
+
GET_SONG_REQUESTS: 'webServer:getSongRequests',
|
|
149
|
+
APPROVE_REQUEST: 'webServer:approveRequest',
|
|
150
|
+
REJECT_REQUEST: 'webServer:rejectRequest',
|
|
151
|
+
REFRESH_CACHE: 'webServer:refreshCache',
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
// ============================================================================
|
|
155
|
+
// SETTINGS CHANNELS
|
|
156
|
+
// ============================================================================
|
|
157
|
+
|
|
158
|
+
export const SETTINGS_CHANNELS = {
|
|
159
|
+
GET: 'settings:get',
|
|
160
|
+
SET: 'settings:set',
|
|
161
|
+
GET_ALL: 'settings:getAll',
|
|
162
|
+
UPDATE_BATCH: 'settings:updateBatch',
|
|
163
|
+
|
|
164
|
+
// Events (main → renderer)
|
|
165
|
+
UPDATE: 'settings:update',
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
// ============================================================================
|
|
169
|
+
// QUEUE CHANNELS
|
|
170
|
+
// ============================================================================
|
|
171
|
+
|
|
172
|
+
export const QUEUE_CHANNELS = {
|
|
173
|
+
ADD_SONG: 'queue:addSong',
|
|
174
|
+
REMOVE_SONG: 'queue:removeSong',
|
|
175
|
+
GET: 'queue:get',
|
|
176
|
+
CLEAR: 'queue:clear',
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
// ============================================================================
|
|
180
|
+
// EFFECT CHANNELS
|
|
181
|
+
// ============================================================================
|
|
182
|
+
|
|
183
|
+
export const EFFECT_CHANNELS = {
|
|
184
|
+
// Events (main → renderer)
|
|
185
|
+
NEXT: 'effect:next',
|
|
186
|
+
PREVIOUS: 'effect:previous',
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
// ============================================================================
|
|
190
|
+
// ADMIN CHANNELS (web admin → renderer)
|
|
191
|
+
// ============================================================================
|
|
192
|
+
|
|
193
|
+
export const ADMIN_CHANNELS = {
|
|
194
|
+
PLAY: 'admin:play',
|
|
195
|
+
NEXT: 'admin:next',
|
|
196
|
+
RESTART: 'admin:restart',
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
// ============================================================================
|
|
200
|
+
// RENDERER CHANNELS (renderer → main, one-way sends)
|
|
201
|
+
// ============================================================================
|
|
202
|
+
|
|
203
|
+
export const RENDERER_CHANNELS = {
|
|
204
|
+
PLAYBACK_STATE: 'renderer:playbackState',
|
|
205
|
+
UPDATE_PLAYBACK_STATE: 'renderer:updatePlaybackState',
|
|
206
|
+
SONG_LOADED: 'renderer:songLoaded',
|
|
207
|
+
UPDATE_MIXER_STATE: 'renderer:updateMixerState',
|
|
208
|
+
UPDATE_EFFECTS_STATE: 'renderer:updateEffectsState',
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
// ============================================================================
|
|
212
|
+
// SHELL CHANNELS
|
|
213
|
+
// ============================================================================
|
|
214
|
+
|
|
215
|
+
export const SHELL_CHANNELS = {
|
|
216
|
+
OPEN_EXTERNAL: 'shell:openExternal',
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
// ============================================================================
|
|
220
|
+
// CREATOR CHANNELS
|
|
221
|
+
// ============================================================================
|
|
222
|
+
|
|
223
|
+
export const CREATOR_CHANNELS = {
|
|
224
|
+
CHECK_COMPONENTS: 'creator:checkComponents',
|
|
225
|
+
INSTALL_COMPONENTS: 'creator:installComponents',
|
|
226
|
+
GET_STATUS: 'creator:getStatus',
|
|
227
|
+
CANCEL_INSTALL: 'creator:cancelInstall',
|
|
228
|
+
SEARCH_LYRICS: 'creator:searchLyrics',
|
|
229
|
+
PREPARE_WHISPER_CONTEXT: 'creator:prepareWhisperContext',
|
|
230
|
+
SELECT_FILE: 'creator:selectFile',
|
|
231
|
+
START_CONVERSION: 'creator:startConversion',
|
|
232
|
+
CANCEL_CONVERSION: 'creator:cancelConversion',
|
|
233
|
+
|
|
234
|
+
// LLM settings
|
|
235
|
+
GET_LLM_SETTINGS: 'creator:getLLMSettings',
|
|
236
|
+
SAVE_LLM_SETTINGS: 'creator:saveLLMSettings',
|
|
237
|
+
TEST_LLM_CONNECTION: 'creator:testLLMConnection',
|
|
238
|
+
|
|
239
|
+
// Events (main → renderer)
|
|
240
|
+
INSTALL_PROGRESS: 'creator:installProgress',
|
|
241
|
+
INSTALL_CONSOLE: 'creator:installConsole',
|
|
242
|
+
INSTALL_ERROR: 'creator:installError',
|
|
243
|
+
CONVERSION_PROGRESS: 'creator:conversionProgress',
|
|
244
|
+
CONVERSION_CONSOLE: 'creator:conversionConsole',
|
|
245
|
+
CONVERSION_COMPLETE: 'creator:conversionComplete',
|
|
246
|
+
CONVERSION_ERROR: 'creator:conversionError',
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
// ============================================================================
|
|
250
|
+
// ALL CHANNELS (for validation)
|
|
251
|
+
// ============================================================================
|
|
252
|
+
|
|
253
|
+
export const ALL_CHANNELS = {
|
|
254
|
+
...APP_CHANNELS,
|
|
255
|
+
...FILE_CHANNELS,
|
|
256
|
+
...AUDIO_CHANNELS,
|
|
257
|
+
...MIXER_CHANNELS,
|
|
258
|
+
...PLAYER_CHANNELS,
|
|
259
|
+
...AUTOTUNE_CHANNELS,
|
|
260
|
+
...SONG_CHANNELS,
|
|
261
|
+
...EDITOR_CHANNELS,
|
|
262
|
+
...WINDOW_CHANNELS,
|
|
263
|
+
...CANVAS_CHANNELS,
|
|
264
|
+
...LIBRARY_CHANNELS,
|
|
265
|
+
...WEB_SERVER_CHANNELS,
|
|
266
|
+
...SETTINGS_CHANNELS,
|
|
267
|
+
...QUEUE_CHANNELS,
|
|
268
|
+
...EFFECT_CHANNELS,
|
|
269
|
+
...ADMIN_CHANNELS,
|
|
270
|
+
...RENDERER_CHANNELS,
|
|
271
|
+
...SHELL_CHANNELS,
|
|
272
|
+
...CREATOR_CHANNELS,
|
|
273
|
+
};
|
|
274
|
+
|
|
275
|
+
// ============================================================================
|
|
276
|
+
// CHANNEL GROUPS (for handler organization)
|
|
277
|
+
// ============================================================================
|
|
278
|
+
|
|
279
|
+
export const CHANNEL_GROUPS = {
|
|
280
|
+
APP: Object.values(APP_CHANNELS),
|
|
281
|
+
FILE: Object.values(FILE_CHANNELS),
|
|
282
|
+
AUDIO: Object.values(AUDIO_CHANNELS),
|
|
283
|
+
MIXER: Object.values(MIXER_CHANNELS),
|
|
284
|
+
PLAYER: Object.values(PLAYER_CHANNELS),
|
|
285
|
+
AUTOTUNE: Object.values(AUTOTUNE_CHANNELS),
|
|
286
|
+
SONG: Object.values(SONG_CHANNELS),
|
|
287
|
+
EDITOR: Object.values(EDITOR_CHANNELS),
|
|
288
|
+
WINDOW: Object.values(WINDOW_CHANNELS),
|
|
289
|
+
CANVAS: Object.values(CANVAS_CHANNELS),
|
|
290
|
+
LIBRARY: Object.values(LIBRARY_CHANNELS),
|
|
291
|
+
WEB_SERVER: Object.values(WEB_SERVER_CHANNELS),
|
|
292
|
+
SETTINGS: Object.values(SETTINGS_CHANNELS),
|
|
293
|
+
QUEUE: Object.values(QUEUE_CHANNELS),
|
|
294
|
+
EFFECT: Object.values(EFFECT_CHANNELS),
|
|
295
|
+
ADMIN: Object.values(ADMIN_CHANNELS),
|
|
296
|
+
RENDERER: Object.values(RENDERER_CHANNELS),
|
|
297
|
+
SHELL: Object.values(SHELL_CHANNELS),
|
|
298
|
+
CREATOR: Object.values(CREATOR_CHANNELS),
|
|
299
|
+
};
|
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creator Service - Shared service for karaoke file creation
|
|
3
|
+
*
|
|
4
|
+
* Used by both:
|
|
5
|
+
* - IPC handlers (Electron renderer)
|
|
6
|
+
* - HTTP routes (Web admin)
|
|
7
|
+
*
|
|
8
|
+
* Progress callbacks support both IPC (mainApp.sendToRenderer) and
|
|
9
|
+
* Socket.IO (io.emit) for real-time updates.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import {
|
|
13
|
+
checkAllComponents,
|
|
14
|
+
getCacheDir,
|
|
15
|
+
getPythonPath,
|
|
16
|
+
} from '../../main/creator/systemChecker.js';
|
|
17
|
+
import { installAllComponents } from '../../main/creator/downloadManager.js';
|
|
18
|
+
import { searchLyrics, prepareWhisperContext } from '../../main/creator/lrclibService.js';
|
|
19
|
+
import { getAudioInfo, isVideoFile } from '../../main/creator/ffmpegService.js';
|
|
20
|
+
import {
|
|
21
|
+
runConversion,
|
|
22
|
+
cancelConversion,
|
|
23
|
+
isConversionInProgress,
|
|
24
|
+
} from '../../main/creator/conversionService.js';
|
|
25
|
+
import { repairStemFile, repairStemFiles } from '../../main/creator/stemBuilder.js';
|
|
26
|
+
import { basename } from 'path';
|
|
27
|
+
import { Atoms as M4AAtoms } from 'm4a-stems';
|
|
28
|
+
|
|
29
|
+
// Track installation state
|
|
30
|
+
let installationInProgress = false;
|
|
31
|
+
let installationCancelled = false;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Check all components status
|
|
35
|
+
* @returns {Promise<Object>} Component status
|
|
36
|
+
*/
|
|
37
|
+
export async function checkComponents() {
|
|
38
|
+
try {
|
|
39
|
+
const result = await checkAllComponents();
|
|
40
|
+
return {
|
|
41
|
+
success: true,
|
|
42
|
+
...result,
|
|
43
|
+
};
|
|
44
|
+
} catch (error) {
|
|
45
|
+
console.error('Failed to check components:', error);
|
|
46
|
+
return {
|
|
47
|
+
success: false,
|
|
48
|
+
error: error.message,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Get installation status
|
|
55
|
+
* @returns {Object} Status info
|
|
56
|
+
*/
|
|
57
|
+
export function getStatus() {
|
|
58
|
+
return {
|
|
59
|
+
installing: installationInProgress,
|
|
60
|
+
cancelled: installationCancelled,
|
|
61
|
+
converting: isConversionInProgress(),
|
|
62
|
+
cacheDir: getCacheDir(),
|
|
63
|
+
pythonPath: getPythonPath(),
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Install all components
|
|
69
|
+
* @param {Function} onProgress - Progress callback (progress, message)
|
|
70
|
+
* @returns {Promise<Object>} Installation result
|
|
71
|
+
*/
|
|
72
|
+
export async function installComponents(onProgress) {
|
|
73
|
+
if (installationInProgress) {
|
|
74
|
+
return { success: false, error: 'Installation already in progress' };
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
installationInProgress = true;
|
|
78
|
+
installationCancelled = false;
|
|
79
|
+
|
|
80
|
+
try {
|
|
81
|
+
onProgress?.({
|
|
82
|
+
step: 'starting',
|
|
83
|
+
message: 'Starting installation...',
|
|
84
|
+
progress: 0,
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
const result = await installAllComponents((progress, message) => {
|
|
88
|
+
if (installationCancelled) {
|
|
89
|
+
throw new Error('Installation cancelled');
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
onProgress?.({
|
|
93
|
+
step: 'installing',
|
|
94
|
+
message,
|
|
95
|
+
progress,
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
if (result.success) {
|
|
100
|
+
onProgress?.({
|
|
101
|
+
step: 'complete',
|
|
102
|
+
message: 'Installation complete',
|
|
103
|
+
progress: 100,
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
installationInProgress = false;
|
|
108
|
+
return result;
|
|
109
|
+
} catch (error) {
|
|
110
|
+
installationInProgress = false;
|
|
111
|
+
return { success: false, error: error.message };
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Cancel installation
|
|
117
|
+
* @returns {Object} Result
|
|
118
|
+
*/
|
|
119
|
+
export function cancelInstall() {
|
|
120
|
+
if (!installationInProgress) {
|
|
121
|
+
return { success: false, error: 'No installation in progress' };
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
installationCancelled = true;
|
|
125
|
+
return { success: true };
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Search for lyrics
|
|
130
|
+
* @param {string} title - Song title
|
|
131
|
+
* @param {string} artist - Artist name
|
|
132
|
+
* @returns {Promise<Object>} Lyrics result
|
|
133
|
+
*/
|
|
134
|
+
export async function findLyrics(title, artist) {
|
|
135
|
+
try {
|
|
136
|
+
const result = await searchLyrics(title, artist);
|
|
137
|
+
if (result) {
|
|
138
|
+
return { success: true, ...result };
|
|
139
|
+
}
|
|
140
|
+
return { success: false, error: 'No lyrics found' };
|
|
141
|
+
} catch (error) {
|
|
142
|
+
console.error('Lyrics search failed:', error);
|
|
143
|
+
return { success: false, error: error.message };
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Prepare Whisper context with vocabulary hints
|
|
149
|
+
* @param {string} title - Song title
|
|
150
|
+
* @param {string} artist - Artist name
|
|
151
|
+
* @param {string} existingLyrics - Reference lyrics
|
|
152
|
+
* @returns {Promise<Object>} Context result
|
|
153
|
+
*/
|
|
154
|
+
export async function getWhisperContext(title, artist, existingLyrics) {
|
|
155
|
+
try {
|
|
156
|
+
const result = await prepareWhisperContext(title, artist, existingLyrics);
|
|
157
|
+
return { success: true, ...result };
|
|
158
|
+
} catch (error) {
|
|
159
|
+
console.error('Whisper context preparation failed:', error);
|
|
160
|
+
return { success: false, error: error.message };
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Get file info for a path
|
|
166
|
+
* Reads ID3 tags if available, falls back to filename parsing.
|
|
167
|
+
* Auto-searches LRCLIB for lyrics if artist and title are found.
|
|
168
|
+
* Detects M4A files with existing stems but no karaoke lyrics.
|
|
169
|
+
*
|
|
170
|
+
* @param {string} filePath - Path to audio/video file
|
|
171
|
+
* @returns {Promise<Object>} File info with optional lyrics
|
|
172
|
+
*/
|
|
173
|
+
export async function getFileInfo(filePath) {
|
|
174
|
+
try {
|
|
175
|
+
const fileName = basename(filePath);
|
|
176
|
+
const audioInfo = await getAudioInfo(filePath);
|
|
177
|
+
const isVideo = await isVideoFile(filePath);
|
|
178
|
+
const lowerPath = filePath.toLowerCase();
|
|
179
|
+
|
|
180
|
+
// Prefer ID3 tags, fall back to filename parsing
|
|
181
|
+
let title = audioInfo.title || '';
|
|
182
|
+
let artist = audioInfo.artist || '';
|
|
183
|
+
const album = audioInfo.album || '';
|
|
184
|
+
|
|
185
|
+
// If no ID3 tags, try to parse from filename (Artist - Title format)
|
|
186
|
+
if (!title) {
|
|
187
|
+
title = fileName.replace(/\.[^.]+$/, '');
|
|
188
|
+
const dashMatch = title.match(/^(.+?)\s*-\s*(.+)$/);
|
|
189
|
+
if (dashMatch) {
|
|
190
|
+
artist = artist || dashMatch[1].trim();
|
|
191
|
+
title = dashMatch[2].trim();
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// Check for M4A with existing stems (NI Stems format has 5 audio streams: master + 4 stems)
|
|
196
|
+
let hasStems = false;
|
|
197
|
+
let hasLyrics = false;
|
|
198
|
+
let stemNames = [];
|
|
199
|
+
let vocalsTrackIndex = null;
|
|
200
|
+
|
|
201
|
+
if (lowerPath.endsWith('.m4a') || lowerPath.endsWith('.mp4')) {
|
|
202
|
+
// Check for multiple audio streams (stems)
|
|
203
|
+
if (audioInfo.audioStreamCount >= 4) {
|
|
204
|
+
hasStems = true;
|
|
205
|
+
stemNames = audioInfo.audioStreams.map((s) => s.title);
|
|
206
|
+
|
|
207
|
+
// Find vocals track index
|
|
208
|
+
const vocalsStream = audioInfo.audioStreams.find((s) => s.title.toLowerCase() === 'vocals');
|
|
209
|
+
if (vocalsStream) {
|
|
210
|
+
vocalsTrackIndex = vocalsStream.index;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
console.log(
|
|
214
|
+
`🎵 Detected stem file: ${audioInfo.audioStreamCount} tracks [${stemNames.join(', ')}]`
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// Check for existing kara atom with lyrics
|
|
219
|
+
if (hasStems) {
|
|
220
|
+
try {
|
|
221
|
+
const karaData = await M4AAtoms.readKaraAtom(filePath);
|
|
222
|
+
if (karaData && karaData.lines && karaData.lines.length > 0) {
|
|
223
|
+
hasLyrics = true;
|
|
224
|
+
console.log(`📝 Found existing lyrics: ${karaData.lines.length} lines`);
|
|
225
|
+
}
|
|
226
|
+
} catch {
|
|
227
|
+
// No kara atom - that's fine, we'll add one
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
const result = {
|
|
233
|
+
success: true,
|
|
234
|
+
file: {
|
|
235
|
+
path: filePath,
|
|
236
|
+
name: fileName,
|
|
237
|
+
title,
|
|
238
|
+
artist,
|
|
239
|
+
album,
|
|
240
|
+
duration: audioInfo.duration,
|
|
241
|
+
sampleRate: audioInfo.sampleRate,
|
|
242
|
+
channels: audioInfo.channels,
|
|
243
|
+
codec: audioInfo.codec,
|
|
244
|
+
isVideo,
|
|
245
|
+
hasId3Tags: Boolean(audioInfo.title || audioInfo.artist),
|
|
246
|
+
// Preserve ALL original tags for inclusion in output file
|
|
247
|
+
tags: audioInfo.tags || {},
|
|
248
|
+
// Stem detection info
|
|
249
|
+
hasStems,
|
|
250
|
+
hasLyrics,
|
|
251
|
+
stemNames,
|
|
252
|
+
vocalsTrackIndex,
|
|
253
|
+
audioStreamCount: audioInfo.audioStreamCount,
|
|
254
|
+
},
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
// Auto-search LRCLIB if we have both artist and title
|
|
258
|
+
if (artist && title) {
|
|
259
|
+
try {
|
|
260
|
+
const lyricsResult = await searchLyrics(title, artist);
|
|
261
|
+
if (lyricsResult) {
|
|
262
|
+
result.lyrics = lyricsResult;
|
|
263
|
+
}
|
|
264
|
+
} catch (e) {
|
|
265
|
+
// Non-fatal - lyrics lookup failed
|
|
266
|
+
console.log('Auto lyrics lookup failed:', e.message);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
return result;
|
|
271
|
+
} catch (error) {
|
|
272
|
+
console.error('Failed to get file info:', error);
|
|
273
|
+
return { success: false, error: error.message };
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Start conversion
|
|
279
|
+
* @param {Object} options - Conversion options
|
|
280
|
+
* @param {Function} onProgress - Progress callback
|
|
281
|
+
* @param {Function} onConsoleOutput - Console output callback
|
|
282
|
+
* @param {Object} settingsManager - Settings manager for LLM settings
|
|
283
|
+
* @returns {Promise<Object>} Conversion result
|
|
284
|
+
*/
|
|
285
|
+
export async function startConversion(
|
|
286
|
+
options,
|
|
287
|
+
onProgress,
|
|
288
|
+
onConsoleOutput = null,
|
|
289
|
+
settingsManager = null
|
|
290
|
+
) {
|
|
291
|
+
if (isConversionInProgress()) {
|
|
292
|
+
return { success: false, error: 'Conversion already in progress' };
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
try {
|
|
296
|
+
onProgress?.({
|
|
297
|
+
step: 'starting',
|
|
298
|
+
message: 'Starting conversion...',
|
|
299
|
+
progress: 0,
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
const result = await runConversion(
|
|
303
|
+
options,
|
|
304
|
+
(step, message, progress) => {
|
|
305
|
+
onProgress?.({
|
|
306
|
+
step,
|
|
307
|
+
message,
|
|
308
|
+
progress,
|
|
309
|
+
});
|
|
310
|
+
},
|
|
311
|
+
onConsoleOutput,
|
|
312
|
+
settingsManager
|
|
313
|
+
);
|
|
314
|
+
|
|
315
|
+
return result;
|
|
316
|
+
} catch (error) {
|
|
317
|
+
console.error('Conversion failed:', error);
|
|
318
|
+
return { success: false, error: error.message };
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* Cancel conversion
|
|
324
|
+
* @returns {Object} Result
|
|
325
|
+
*/
|
|
326
|
+
export function stopConversion() {
|
|
327
|
+
const cancelled = cancelConversion();
|
|
328
|
+
return { success: cancelled };
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* Repair a stem file to fix NI Stems metadata
|
|
333
|
+
* @param {string} filePath - Path to .stem.m4a file
|
|
334
|
+
* @returns {Promise<Object>} Repair result
|
|
335
|
+
*/
|
|
336
|
+
export async function repairStem(filePath) {
|
|
337
|
+
try {
|
|
338
|
+
const result = await repairStemFile(filePath);
|
|
339
|
+
return result;
|
|
340
|
+
} catch (error) {
|
|
341
|
+
console.error('Failed to repair stem file:', error);
|
|
342
|
+
return { success: false, error: error.message };
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
/**
|
|
347
|
+
* Batch repair multiple stem files
|
|
348
|
+
* @param {string[]} filePaths - Array of paths to .stem.m4a files
|
|
349
|
+
* @returns {Promise<Object>} Batch repair results
|
|
350
|
+
*/
|
|
351
|
+
export async function repairStems(filePaths) {
|
|
352
|
+
try {
|
|
353
|
+
const result = await repairStemFiles(filePaths);
|
|
354
|
+
return result;
|
|
355
|
+
} catch (error) {
|
|
356
|
+
console.error('Failed to batch repair stem files:', error);
|
|
357
|
+
return { success: false, error: error.message };
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
export default {
|
|
362
|
+
checkComponents,
|
|
363
|
+
getStatus,
|
|
364
|
+
installComponents,
|
|
365
|
+
cancelInstall,
|
|
366
|
+
findLyrics,
|
|
367
|
+
getWhisperContext,
|
|
368
|
+
getFileInfo,
|
|
369
|
+
startConversion,
|
|
370
|
+
stopConversion,
|
|
371
|
+
repairStem,
|
|
372
|
+
repairStems,
|
|
373
|
+
};
|