|
Joined: Feb 2003
Posts: 3,432
Hoopy frood
|
OP
Hoopy frood
Joined: Feb 2003
Posts: 3,432 |
I have this in my mp3 player:
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,.) }
|
|
|
|
Joined: May 2003
Posts: 2,265
Hoopy frood
|
Hoopy frood
Joined: May 2003
Posts: 2,265 |
.echo -q $findfile(<dir>,*.mp3,0,write mp3.list.txt $1-)
new username: tidy_trax
|
|
|
|
Joined: Feb 2003
Posts: 3,432
Hoopy frood
|
OP
Hoopy frood
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,.) }
|
|
|
|
Joined: May 2003
Posts: 2,265
Hoopy frood
|
Hoopy frood
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
|
|
|
|
Joined: Jan 2003
Posts: 3,012
Hoopy frood
|
Hoopy frood
Joined: Jan 2003
Posts: 3,012 |
correct. var %a = $findfile(...) works also
-KingTomato
|
|
|
|
Joined: May 2003
Posts: 2,265
Hoopy frood
|
Hoopy frood
Joined: May 2003
Posts: 2,265 |
indeed. i would think its slower though. edit: i just benched it var = 60ms echo = 100ms ;\ i used:
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
|
|
|
|
Joined: Jan 2003
Posts: 3,012
Hoopy frood
|
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
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
|
|
|
|
Joined: Feb 2003
Posts: 3,432
Hoopy frood
|
OP
Hoopy frood
Joined: Feb 2003
Posts: 3,432 |
I just replyed to somone! you didnt find any faster way to list the mp3 files? cos i cant make it list fast if i using winamp, then i list 500 mp3's in like 10 sec.. and with mirc it takes minutes and thats wierd cos it shouldent take so long..
if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
|
|
|
|
Joined: May 2003
Posts: 2,265
Hoopy frood
|
Hoopy frood
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
|
|
|
|
Joined: Feb 2003
Posts: 3,432
Hoopy frood
|
OP
Hoopy frood
Joined: Feb 2003
Posts: 3,432 |
OPs. i saw i added this in the wrong section of this forum 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,.) }
|
|
|
|
Joined: Feb 2003
Posts: 810
Hoopy frood
|
Hoopy frood
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
|
|
|
|
Joined: Feb 2003
Posts: 26
Ameglian cow
|
Ameglian cow
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 [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.
|
|
|
|
Joined: May 2003
Posts: 2,265
Hoopy frood
|
Hoopy frood
Joined: May 2003
Posts: 2,265 |
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
|
|
|
|
Joined: Feb 2003
Posts: 810
Hoopy frood
|
Hoopy frood
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): if ($devent == init) {
var %dname = $dname, %| = |, %file = $+(",$scriptdir,playlist.txt"), $&
%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 $&, this is just to avoid messing up the board.[/color]
.echo -q $findfile(%dir,*.mp3,0, $&
.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
|
|
|
|
Joined: Jan 2003
Posts: 2,523
Hoopy frood
|
Hoopy frood
Joined: Jan 2003
Posts: 2,523 |
Instead of .echo -q $findfile(%dir,*.mp3,0, $&
.fwrite -n playlist $+(",$1-,") [ %| ] did -a %dname 10 $left($nopath($1-),-4) )
hadd -m playlist total $findfile(%dir,*.mp3,0) you could use this .hadd -m playlist total $findfile(%dir,*.mp3,0, $&
.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
|
|
|
|
Joined: Feb 2003
Posts: 810
Hoopy frood
|
Hoopy frood
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
|
|
|
|
Joined: Jan 2003
Posts: 2,523
Hoopy frood
|
Hoopy frood
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"
/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
|
|
|
|
Joined: Feb 2003
Posts: 810
Hoopy frood
|
Hoopy frood
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
|
|
|
|
Joined: Aug 2003
Posts: 1,831
Hoopy frood
|
Hoopy frood
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().
|
|
|
|
Joined: Jan 2003
Posts: 2,523
Hoopy frood
|
Hoopy frood
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
|
|
|
|
Joined: Feb 2003
Posts: 810
Hoopy frood
|
Hoopy frood
Joined: Feb 2003
Posts: 810 |
You know, this is one of the various times I realize that I should definitely finish something to use with mIRC 6.12, but I'm just lazy to finish scripting anything and keep stuck with my script on 5.91 (eek) :tongue:
* cold edits his posts 24/7
|
|
|
|
Joined: Feb 2003
Posts: 810
Hoopy frood
|
Hoopy frood
Joined: Feb 2003
Posts: 810 |
* Edited
Thanks, didn't notice that one. The DLL determines some common destinations (a listbox, a combo, a file etc.) and dumps the data itself, and provides some functions to process it (if specified), as I've quickly read from its readme.. maybe the speed relies on these "built-in" tasks, like you've said. But the bad thing is it won't count subdirectories, so it can't really replace $findfile(), since you'd have to script a snippet using $finddir() or so, which would break its purpose (IMO), as it'd probably end up slower, since you'd not use built-in stuff anymore. Some people on ms.org actually mentioned this issue.
A findfile+finddir-like DLL that actually counted subdirectories *and* offered some common mIRC-related tasks would be great.
Last edited by cold; 19/10/03 09:07 AM.
* cold edits his posts 24/7
|
|
|
|
|