Could this be faster?

new topic     » topic index » view thread      » older message » newer message

Hi All,

I am trying to speed up how I scan a audio folder and add it to a Playlist.
It works fast if there is only a few hundred files, but if there is 500
or more files it can get to be slow. I scan the folder using walk_dir
and add each file into the database. Do any of you guys think I can do
this without using walk_dir? I have pasted a bit of the code below.


function ScanDir(sequence path_name, sequence ItemEntry)
sequence addaudio,streamtime,filecount,filetitle
atom len,tempstream

streamtime={}
addaudio={}
filecount={}
doEvents(0)


if equal(ItemEntry[D_ATTRIBUTES], "d") then  ----If directory do nothing

  else
if match("aac", get_file_ext(lower(ItemEntry[D_NAME]))) or   ---- If
         supported file add to the Playlist
         match("mp4", get_file_ext(lower(ItemEntry[D_NAME]))) or
         match("mp3", get_file_ext(lower(ItemEntry[D_NAME]))) or
         match("mp2", get_file_ext(lower(ItemEntry[D_NAME]))) or
         match("mp1", get_file_ext(lower(ItemEntry[D_NAME]))) or
         match("ogg", get_file_ext(lower(ItemEntry[D_NAME]))) or
         match("wav", get_file_ext(lower(ItemEntry[D_NAME])))
  then

tempstream = BASS_StreamCreateFile(0, path_name & "\\" & ItemEntry[D_NAME],
    0, 0, BASS_STREAM_AUTOFREE) ---Create a temp file to get the file length
len = BASS_ChannelBytes2Seconds(tempstream, 
      BASS_ChannelGetLength(tempstream))
streamtime = sprintf("               %d:%02d", {len / 60, remainder(len,
       60)})
        filetitle = get_file_title(ItemEntry[D_NAME])

if mdb_insert(appdir&"\\Playlist.dat","Playlist",convertCase(replace
         (filetitle,"_"," ")),{path_name & "\\" & ItemEntry[D_NAME],streamtime}) = -1
            then
               else
addaudio &= addLVItem(Playlist,listicon2,{" 
                "&convertCase(replace (filetitle,"_"," "))," "&streamtime})
                end if
               setIndex(Playlist, 1)
              getCount()
            end if
          end if
        doEvents(0)
     return 0
end function



VOID = walk_dir(audiofolder, routine_id("ScanDir"), 1)

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu