forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Frequent API calls

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
dmonckton
Contributor
Contributor


Joined: 09 Aug 2002
Posts: 114
Location: Lewes, U.K.

PostPosted: Thu Jun 11, 2015 9:45 am    Post subject: Frequent API calls Reply with quote

Hi

I'm working on a MIDI project that requires me to make a lot of API calls many times per second. Should I load the Library at the start of the script and unload it at the end, or should I load the library just before the API call and the unload just after?
Code:

rem %1 = handle
:clockPulse
    if @null(%1)
        exit
    end
    rem handle
    %%handle = %1
    rem 0xF8 is the timing clock status,needs to be padded out to 4 bytes
    %%data = $000000F8
    loadlib winmm.dll
    %z = @lib(winmm.dll,midiOutShortMsg,INT:,INT:%%handle,INT:%%data)
    freelib winmm.dll
    exit

I will be using this function every 25 milliseconds. So calling efficiency is important. Should I load winmm.dll at the start of the script and leave it in memory until the end?
Back to top
View user's profile Send private message
Garrett
Moderator Team


Joined: 04 Oct 2001
Posts: 2149
Location: A House

PostPosted: Thu Jun 11, 2015 5:22 pm    Post subject: Reply with quote

I used to always load the library at the beginning of the script and close when the user closed my program.

Constatnly opening and closeing the library lagged my programs down too slow.

~Garrett

_________________
'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.)
Necroprogramming FTW! - "Wait.. Is necroprogramming legal?"
http://www.freewarehome.com <-- Freeware listings since 1996
Back to top
View user's profile Send private message
dmonckton
Contributor
Contributor


Joined: 09 Aug 2002
Posts: 114
Location: Lewes, U.K.

PostPosted: Sun Jun 14, 2015 8:22 am    Post subject: Reply with quote

Thanks Garret

I've changed my MIDI library to reflect your advice. I'm going to start testing my script today, fingers crossed!

One of the reasons I'm still using VDS is its ability to make API calls fairly easy.

Quote:

I used to always load the library

Past tense? Your don't do API calls anymore or your don't use VDS anymore?

Regards

David
Back to top
View user's profile Send private message
Garrett
Moderator Team


Joined: 04 Oct 2001
Posts: 2149
Location: A House

PostPosted: Sun Jun 14, 2015 4:58 pm    Post subject: Reply with quote

Just haven't done much programming at all these days.

I don't have any Windows computers anymore, I'm all Linux here and with only a few select programs that are run through WINE... Though, they are VDS made programs that every so often I do need to update. So VDS is installed. Smile

_________________
'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.)
Necroprogramming FTW! - "Wait.. Is necroprogramming legal?"
http://www.freewarehome.com <-- Freeware listings since 1996
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum




Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group