mIRC Home    About    Download    Register    News    Help

Page 1 of 2 1 2 >
Topic Options
#55567 - 17/10/03 09:08 PM ?
sparta Offline
Planetary brain

Registered: 22/02/03
Posts: 3432
Loc: Sweden/Borlänge
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,.) }

Top
#55568 - 17/10/03 09:10 PM Re: ?
pheonix Offline
Hoopy frood

Registered: 06/05/03
Posts: 2265
.echo -q $findfile(<dir>,*.mp3,0,write mp3.list.txt $1-)
_________________________
new username: tidy_trax

Top
#55569 - 17/10/03 09:14 PM Re: ?
sparta Offline
Planetary brain

Registered: 22/02/03
Posts: 3432
Loc: Sweden/Borlänge
echo ? why?? "i using mirc 6.03"
_________________________
if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }

Top
#55570 - 17/10/03 09:18 PM Re: ?
pheonix Offline
Hoopy frood

Registered: 06/05/03
Posts: 2265
.echo -q doesnt echo. it avoids you getting an error message from starting the line with an $identifier.
_________________________
new username: tidy_trax

Top
#55571 - 17/10/03 09:19 PM Re: ?
KingTomato Offline
Planetary brain

Registered: 04/01/03
Posts: 3012
Loc: New Hampshire, USA
correct. var %a = $findfile(...) works also
_________________________
-KingTomato

Top
#55572 - 17/10/03 09:26 PM Re: ?
pheonix Offline
Hoopy frood

Registered: 06/05/03
Posts: 2265
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

Top
#55573 - 17/10/03 09:47 PM Re: ?
KingTomato Offline
Planetary brain

Registered: 04/01/03
Posts: 3012
Loc: New Hampshire, USA
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

Top
#55574 - 17/10/03 11:50 PM Re: ?
sparta Offline
Planetary brain

Registered: 22/02/03
Posts: 3432
Loc: Sweden/Borlänge
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,.) }

Top
#55575 - 17/10/03 11:51 PM Re: ?
pheonix Offline
Hoopy frood

Registered: 06/05/03
Posts: 2265
mircscript is most probably a lot slower than whatever winamp is made in. winamp ownz all audio players anyway ;o
_________________________
new username: tidy_trax

Top
#55576 - 18/10/03 01:08 AM Re: ?
sparta Offline
Planetary brain

Registered: 22/02/03
Posts: 3432
Loc: Sweden/Borlänge
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,.) }

Top
#55577 - 18/10/03 06:12 AM Re: ?
cold Offline
Hoopy frood

Registered: 25/02/03
Posts: 810
Loc: Brazil
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

Top
#55578 - 18/10/03 06:20 AM Re: ?
MRN Offline
Ameglian cow

Registered: 26/02/03
Posts: 26
Loc: Arendal, Norway
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]


Edited by MRN (18/10/03 06:23 AM)

Top
#55579 - 18/10/03 06:22 AM Re: ?
pheonix Offline
Hoopy frood

Registered: 06/05/03
Posts: 2265
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

Top
#55580 - 18/10/03 07:04 AM Re: ?
cold Offline
Hoopy frood

Registered: 25/02/03
Posts: 810
Loc: Brazil
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

Top
#55581 - 18/10/03 03:10 PM Re: ?
qwerty Offline
Hoopy frood

Registered: 07/01/03
Posts: 2523
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

Top
#55582 - 18/10/03 04:01 PM Re: ?
cold Offline
Hoopy frood

Registered: 25/02/03
Posts: 810
Loc: Brazil
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

Top
#55583 - 18/10/03 04:10 PM Re: ?
qwerty Offline
Hoopy frood

Registered: 07/01/03
Posts: 2523
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

Top
#55584 - 18/10/03 04:23 PM Re: ?
cold Offline
Hoopy frood

Registered: 25/02/03
Posts: 810
Loc: Brazil
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

Top
#55585 - 18/10/03 08:24 PM Re: ?
Iori Offline
Hoopy frood

Registered: 30/08/03
Posts: 1831
While you're improving things, since v6.0 $inmp3 and $mp3() are also deprecated in favour of $insong and $sound(). smile

Top
#55586 - 19/10/03 01:46 AM Re: ?
qwerty Offline
Hoopy frood

Registered: 07/01/03
Posts: 2523
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

Top
Page 1 of 2 1 2 >