@@ -6,7 +6,7 @@ import { setAlbumArtInCache } from "../hooks/useAlbumArt";
66export async function importAudioFiles (
77 audioFiles : Array < { file : File } | File > ,
88 addSong : ( song : Song , file : File ) => Promise < void > ,
9- t : any ,
9+ t : any
1010) {
1111 if ( ! audioFiles || audioFiles . length === 0 ) return ;
1212
@@ -32,31 +32,36 @@ export async function importAudioFiles(
3232 let processedMimeType = file . type ;
3333
3434 const isFlo =
35- file . name . toLowerCase ( ) . endsWith ( ' .flo' ) ||
36- metadata . encoding ?. codec === ' flo' ;
35+ file . name . toLowerCase ( ) . endsWith ( " .flo" ) ||
36+ metadata . encoding ?. codec === " flo" ;
3737
3838 if ( isFlo ) {
3939 try {
4040 const arrayBuffer = await file . arrayBuffer ( ) ;
41- const isSafari = / ^ ( (? ! c h r o m e | a n d r o i d ) .) * s a f a r i / i. test ( navigator . userAgent ) ;
41+ const isSafari = / ^ ( (? ! c h r o m e | a n d r o i d ) .) * s a f a r i / i. test (
42+ navigator . userAgent
43+ ) ;
4244
4345 if ( isSafari ) {
4446 // Safari: Pre-decode to WAV for compatibility
4547 const { decodeFloToWav } = await import ( "./refloWavHelper" ) ;
4648 const wavBytes = await decodeFloToWav ( arrayBuffer ) ;
47- const wavBlob = new Blob ( [ wavBytes ] , { type : ' audio/wav' } ) ;
49+ const wavBlob = new Blob ( [ wavBytes ] , { type : " audio/wav" } ) ;
4850 processedFile = new File (
4951 [ wavBlob ] ,
50- file . name . replace ( / \. f l o $ / i, ' .wav' ) ,
51- { type : ' audio/wav' }
52+ file . name . replace ( / \. f l o $ / i, " .wav" ) ,
53+ { type : " audio/wav" }
5254 ) ;
53- processedMimeType = ' audio/wav' ;
55+ processedMimeType = " audio/wav" ;
5456 console . log ( `Pre-decoded flo to WAV for Safari: ${ file . name } ` ) ;
5557 } else {
5658 // Non-Safari: Pre-decode to PCM for Web Audio API
5759 const { decodeFloToAudioBuffer } = await import ( "./floProcessor" ) ;
5860 const audioContext = new AudioContext ( ) ;
59- const audioBuffer = await decodeFloToAudioBuffer ( arrayBuffer , audioContext ) ;
61+ const audioBuffer = await decodeFloToAudioBuffer (
62+ arrayBuffer ,
63+ audioContext
64+ ) ;
6065
6166 // Store as interleaved Float32Array PCM
6267 const frameCount = audioBuffer . length ;
@@ -66,25 +71,26 @@ export async function importAudioFiles(
6671 // Interleave channels
6772 for ( let i = 0 ; i < frameCount ; i ++ ) {
6873 for ( let ch = 0 ; ch < channels ; ch ++ ) {
69- pcmData [ i * channels + ch ] = audioBuffer . getChannelData ( ch ) [ i ] ;
74+ pcmData [ i * channels + ch ] =
75+ audioBuffer . getChannelData ( ch ) [ i ] ;
7076 }
7177 }
7278
73- const pcmBlob = new Blob ( [ pcmData . buffer ] , { type : ' audio/pcm' } ) ;
79+ const pcmBlob = new Blob ( [ pcmData . buffer ] , { type : " audio/pcm" } ) ;
7480 processedFile = new File (
7581 [ pcmBlob ] ,
76- file . name . replace ( / \. f l o $ / i, ' .pcm' ) ,
77- { type : ' audio/pcm' }
82+ file . name . replace ( / \. f l o $ / i, " .pcm" ) ,
83+ { type : " audio/pcm" }
7884 ) ;
79- processedMimeType = ' audio/pcm' ;
85+ processedMimeType = " audio/pcm" ;
8086
8187 // Store AudioBuffer properties for reconstruction
8288 metadata . encoding = {
8389 ...metadata . encoding ,
8490 sampleRate : audioBuffer . sampleRate ,
8591 channels : audioBuffer . numberOfChannels ,
8692 bitsPerSample : 32 , // Float32
87- codec : ' pcm-float32' ,
93+ codec : " pcm-float32" ,
8894 } ;
8995
9096 // Close the temporary AudioContext
@@ -93,9 +99,12 @@ export async function importAudioFiles(
9399 console . log ( `Pre-decoded flo to PCM: ${ file . name } ` ) ;
94100 }
95101 } catch ( error ) {
96- console . warn ( "Failed to pre-decode flo file, storing original:" , error ) ;
102+ console . warn (
103+ "Failed to pre-decode flo file, storing original:" ,
104+ error
105+ ) ;
97106 // Keep original file if pre-decoding fails
98- processedMimeType = ' audio/x-flo' ;
107+ processedMimeType = " audio/x-flo" ;
99108 }
100109 }
101110
@@ -110,7 +119,9 @@ export async function importAudioFiles(
110119 id : songId ,
111120 title : metadata . title ,
112121 artist : metadata . artist ,
113- album : metadata . album || t ( "songInfo.album" , { title : t ( "common.unknownAlbum" ) } ) ,
122+ album :
123+ metadata . album ||
124+ t ( "songInfo.album" , { title : t ( "common.unknownAlbum" ) } ) ,
114125 duration : metadata . duration ,
115126 url : "" , // Will be set by addSong
116127 albumArt : metadata . albumArt , // Keep for immediate display
0 commit comments