mIRC Home    About    Download    Register    News    Help

Print Thread
Page 1 of 2 1 2
#55567 17/10/03 08:08 PM
Joined: Feb 2003
Posts: 3,432
S
sparta Offline OP
Hoopy frood
OP Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
I have this in my mp3 player:
Code:
alias mp3.addlist {
  if (%mp3.dir == $null) { return }  
  set %mp3.num $findfile(%mp3.dir, *.mp3, 0)  
  set %mp3.loop 1
  :loop
  if (%mp3.loop <= %mp3.num) { 
    write mp3.list.txt $findfile(%mp3.dir,*.mp3,%mp3.loop)
    inc %mp3.loop
    goto loop
  }
  else { mp3.list }
}

but this is realy slow.. any one that know a faster way to load the mp3's ? if i load up to 50 it works great, but if i lode more it start to get slow, and when im up to 300 it can take up to 5 minutes to load the list.. and i dont know how i can make this faster


if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
#55568 17/10/03 08:10 PM
Joined: May 2003
Posts: 2,265
P
Hoopy frood
Offline
Hoopy frood
P
Joined: May 2003
Posts: 2,265
.echo -q $findfile(<dir>,*.mp3,0,write mp3.list.txt $1-)


new username: tidy_trax
#55569 17/10/03 08:14 PM
Joined: Feb 2003
Posts: 3,432
S
sparta Offline OP
Hoopy frood
OP Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
echo ? why?? "i using mirc 6.03"


if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
#55570 17/10/03 08:18 PM
Joined: May 2003
Posts: 2,265
P
Hoopy frood
Offline
Hoopy frood
P
Joined: May 2003
Posts: 2,265
.echo -q doesnt echo. it avoids you getting an error message from starting the line with an $identifier.


new username: tidy_trax
#55571 17/10/03 08:19 PM
Joined: Jan 2003
Posts: 3,012
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
correct. var %a = $findfile(...) works also


-KingTomato
#55572 17/10/03 08:26 PM
Joined: May 2003
Posts: 2,265
P
Hoopy frood
Offline
Hoopy frood
P
Joined: May 2003
Posts: 2,265
indeed. i would think its slower though.

edit: i just benched it
var = 60ms
echo = 100ms
;\
i used:
Code:
benchmp3 {
  var %ticks $ticks
  if ($1 == echo) {
    .echo -q $findfile($hget(playlist,dir),*.mp3,0,echo -s $1-)
    echo -a $calc($ticks - %ticks)
  }
  elseif ($1 == var) {
    var %a $findfile($hget(playlist,dir),*.mp3,0,echo -s $1-)
    echo -a $calc($ticks - %ticks)
  }
}


new username: tidy_trax
#55573 17/10/03 08:47 PM
Joined: Jan 2003
Posts: 3,012
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
Its wierd, i broke it down so there is both reuslts but spaced apart, and got diff answers:

Benching Echo vs Var methods
Echo Result: 63
Var Result: 32

Benching Echo vs Var methods...
Echo Result: 47
Var Result: 63

Benching Echo vs Var methods...
Echo Result: 47
Var Result: 47

Code:
alias benchmp3 {
  var %mp3dir = C:\progra~1\Apache~1\Apache2\htdocs\Music

  /echo -s 
  /echo -s Benching Echo vs Var methods...

  .timer 1 3 /b1 %mp3dir
  .timer 1 6 /b2 %mp3dir
}

alias b1 {
  var %ticks = $ticks
  .echo -q $findfile($1-,*.mp3,0,var %b)
  echo -s Echo Result: $calc($ticks - %ticks)
}

alias b2 {
  var %ticks = $ticks
  var %a $findfile($1-,*.mp3,0,var %b)
  echo -s Var Result: $calc($ticks - %ticks)
}


Wierd >:D


-KingTomato
#55574 17/10/03 10:50 PM
Joined: Feb 2003
Posts: 3,432
S
sparta Offline OP
Hoopy frood
OP Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
I just replyed to somone! smile

you didnt find any faster way to list the mp3 files? cos i cant make it list fast smirk if i using winamp, then i list 500 mp3's in like 10 sec.. and with mirc it takes minutes smirk and thats wierd cos it shouldent take so long.. confused


if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
#55575 17/10/03 10:51 PM
Joined: May 2003
Posts: 2,265
P
Hoopy frood
Offline
Hoopy frood
P
Joined: May 2003
Posts: 2,265
mircscript is most probably a lot slower than whatever winamp is made in. winamp ownz all audio players anyway ;o


new username: tidy_trax
#55576 18/10/03 12:08 AM
Joined: Feb 2003
Posts: 3,432
S
sparta Offline OP
Hoopy frood
OP Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
OPs. i saw i added this in the wrong section of this forum wink but still, mirc should be able to get 500 lines pretty fast, it shouldent take minutes to get them.. all i do is get a list to a dialog so it's nothing heavy mirc have to do.. it can write down the lines fast to a txt file "or what formate you use". but then read it back takes ages.. mirc dont have to play al files, just list them.. and i cant get it to work any faster, have been trying allot of diffrent codes, but still the same.. and mirc script editor can list a remote file with 500+ lines realy fast.. so why not a txt file? it saves the stuff in the memory, but still it should be able to handle txt files in secconds not in minutes, i can stand wait for 20 sec.. but when it takes 2 minutes then i only get anoyed.. :tongue:


if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
#55577 18/10/03 05:12 AM
Joined: Feb 2003
Posts: 810
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Feb 2003
Posts: 810
That's because /write opens, writes and closes a file everytime it's called. You could use the file handling commands (/fopen etc.) to open it once, do all the writing through $findfile and closing it after. It should be faster then.

Or you could use an @window and /savebuf. Make $findfile() aline everything to the @window, then just /savebuf it. Maybe this method is even faster than the former...? I didn't compare the speeds of both methods yet, but I've always used this one and it's currently the fastest method I know of.


* cold edits his posts 24/7
#55578 18/10/03 05:20 AM
Joined: Feb 2003
Posts: 26
M
MRN Offline
Ameglian cow
Offline
Ameglian cow
M
Joined: Feb 2003
Posts: 26
I'm not sure, but I think I use 3 minutes or so for 2000 mp3s.

Anyway, I got this "aha"-feeling. You write a new line to a textfile (/write) each time it finds a new mp3. For each time, mIRC opens, writes and closes the file.

The solution is to find the files ($findfile) and add files (/aline?)into a @window ehich is hidden and sorted (/window -hs @window), then take a /savebuf and save it to a txtfile. That is what I'm using smile

[It seems Cold and I agrees. I just used 8 minutes to say the same thing]

Last edited by MRN; 18/10/03 05:23 AM.
#55579 18/10/03 05:22 AM
Joined: May 2003
Posts: 2,265
P
Hoopy frood
Offline
Hoopy frood
P
Joined: May 2003
Posts: 2,265
Code:
on *:dialog:amp:*:*:{
  if ($devent == init) {
    mdx SetMircVersion $version
    mdx MarkDialog $dname
    mdx SetFont $dname 4,5,6,7,8,9 Default 20 40 WebDings
    if ($fopen(playlist)) { .fclose playlist }
    if ($isfile(" $+ $scriptdirplaylist.txt $+ ")) { .remove " $+ $scriptdirplaylist.txt $+ " }
    if (!$hget(playlist,dir)) { .hadd -m playlist dir $+(",$$sdir(c:,choose an mp3 directory),") }
    if (!$fopen(playlist)) { .fopen -n playlist " $+ $scriptdirplaylist.txt $+ " }
    .echo -q $findfile($hget(playlist,dir),*.mp3,0,.fwrite -n playlist $+(",$1-,"))
    .hadd -m playlist total $findfile($hget(playlist,dir),*.mp3,0)
    var %g 1
    while (!$feof) {
      .fseek -l playlist %g
      did -a $dname 10 $remove($nopath($fread(playlist)),.mp3)
      inc %g
    }
    if ($inmp3) { 
      did -a $dname 3 $remove($nopath($inmp3.fname),.mp3) $+ , $asctime($calc($inmp3.length / 1000),n:ss) 
      did -c $dname 10 %i
    }
  }


yuh, that takes around 2s. i have 238 mp3's


new username: tidy_trax
#55580 18/10/03 06:04 AM
Joined: Feb 2003
Posts: 810
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Feb 2003
Posts: 810
I have a feeling that this could be faster, but I'm not sure, since you use MDX. Try this (I won't test it because I don't want to get the DLL, create a dialog, blah blah etc):
Code:
if ($devent == init) {
  var %dname = $dname, %| = |, %file = $+(",$scriptdir,playlist.txt"), $&amp;
    %dir = $iif($hget(playlist,dir),  $ifmatch,  $+(",$sdir(c:,choose an mp3 directory),")  )
  if ($$isdir(%dir)) { hadd -m playlist dir %dir }
  if ($isfile(%file)) { .remove %file }
  mdx SetMircVersion $version
  mdx MarkDialog %dname
  mdx SetFont %dname 4,5,6,7,8,9 Default 20 40 WebDings
  if ($fopen(playlist)) { .fclose playlist }
  .fopen -n playlist %file

  [color:green]; Maybe the commands inside $findfile() could be faster if put inside an alias.
  ; I didn't bother to check which method would be faster.
  ; Check it yourself, it's worth it, since this is the most important part of the code..
  ; P.S.: Remove the $&amp;, this is just to avoid messing up the board.[/color]
  .echo -q $findfile(%dir,*.mp3,0,  $&amp;
    .fwrite -n playlist $+(",$1-,") [ %| ] did -a %dname 10 $left($nopath($1-),-4)  )

  [color:green]; This $findfile() below could be $did(%dname,10).lines,
  ; but I'm not sure since you're using MDX.[/color]
  hadd -m playlist total $findfile(%dir,*.mp3,0)
  if ($inmp3) { 
    did -a %dname 3 $left($nopath($inmp3.fname),-4) $+ , $asctime($calc($inmp3.length / 1000),n:ss) 
    did -c %dname 10 %i
  }
}


I've also improved some things.
Some tips:
- Using quotes (") for long filenames isn't needed in an identifier.
- Khaled has discouraged the use of identifiers like $scriptdir joint to plain text (like $scriptdirplaylist.txt), I guess mIRC won't support this anymore in the future (versions.txt, mIRC 5.7, item 100)..
- In most cases, using variables is faster than using identifiers, specially when they're repeatedly used. At least the stuff I benchmarked became faster. Always test different methods when speed is an important issue.


* cold edits his posts 24/7
#55581 18/10/03 02:10 PM
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
Instead of
Code:
.echo -q $findfile(%dir,*.mp3,0,  $&amp;
  .fwrite -n playlist $+(",$1-,") [ %| ] did -a %dname 10 $left($nopath($1-),-4)  )
hadd -m playlist total $findfile(%dir,*.mp3,0)
you could use this
Code:
.hadd -m playlist total $findfile(%dir,*.mp3,0,  $&amp;
  .fwrite -n playlist $+(",$1-,") [ %| ] did -a %dname 10 $left($nopath($1-),-4)  )
This way you call $findfile(%dir,*.mp3,0) only once, which speeds up the process considerably.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
#55582 18/10/03 03:01 PM
Joined: Feb 2003
Posts: 810
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Feb 2003
Posts: 810
There, that's right. Although $findfile(blah,blah,0) is slow here only when it's first called. After that, it takes less than a second. What you suggested is better anyway, it's the method I was searching for in my scripts when I was trying to remember some way to drop that $did() suggestion..


* cold edits his posts 24/7
#55583 18/10/03 03:10 PM
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
Correct, the 2nd $findfile call is much faster (because of caching). Although "considerably" might have sounded as "quite a lot", I actually meant it as "something you can consider" smile


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
#55584 18/10/03 03:23 PM
Joined: Feb 2003
Posts: 810
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Feb 2003
Posts: 810
Indeed, I hate $findfile(). The more I can avoid it, the better :tongue:
BTW, I'm surprised I haven't seen any kind of DLL replacement for it yet.. maybe because it wouldn't be possible to make anything significantly faster? I have no clue.


* cold edits his posts 24/7
#55585 18/10/03 07:24 PM
Joined: Aug 2003
Posts: 1,831
I
Hoopy frood
Offline
Hoopy frood
I
Joined: Aug 2003
Posts: 1,831
While you're improving things, since v6.0 $inmp3 and $mp3() are also deprecated in favour of $insong and $sound(). smile

#55586 19/10/03 12:46 AM
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
There is a dll alternative to $findfile() but I'm not sure if it's faster (although the author claims it is), as it uses the same function as $findfile (FindNextFile()), which is the fastest way to search for files. I guess any speed advantage of this dll could result from the different way it writes to a file/dumps in a listbox (which is done internally and not using script commands).


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
Page 1 of 2 1 2

Link Copied to Clipboard