Page 2 of 2

Re: Delay problem

Posted: Thu Dec 10, 2015 3:45 pm
by infratec
You have to disable the Debugger.

Re: Delay problem

Posted: Thu Dec 10, 2015 4:00 pm
by SeregaZ
i am even set 22.675736 for more tune, and create exe file, and close any others programm - still not same, as original.

Re: Delay problem

Posted: Thu Dec 10, 2015 4:12 pm
by infratec
Can you provide a wav file?

I have no winamp.

Re: Delay problem

Posted: Thu Dec 10, 2015 4:17 pm
by SeregaZ

Re: Delay problem

Posted: Thu Dec 10, 2015 4:54 pm
by infratec
Hm...

I compensate a bit the calling

Code: Select all

DelayMicroSeconds(MusArr(i)\pause * 22.676 - 5)
But for me it sounds already a bit faster as the original.

Bernd

Re: Delay problem

Posted: Thu Dec 10, 2015 5:10 pm
by SeregaZ
sounds very closer. but how they get this so small pauses? i think it was made by VB6.0

Re: Delay problem

Posted: Thu Dec 10, 2015 5:41 pm
by kenmo
My advice: do not not not use a sequence of delays to control your timing. Error will accumulate eventually, even using a function more precise than Delay().

I would try a method similar to this:

Code: Select all

    Debug "play"
    
    PlayedTicks.i = 0
    PlayedUS.i = 0
    CurrentUS.i = 0
    StartMS.i = ElapsedMilliseconds()
    
    For i = 0 To ArraySize(MusArr())-1
    
    Select MusArr(i)\type
      Case 1
        OPN_Write(0, MusArr(i)\reg, MusArr(i)\val)
      Case 2
        tmp = MusArr(i)\reg+256
        OPN_Write(0, tmp, MusArr(i)\val)
      Case 3   
        ;COMMENT AND UNCOMMENT HERE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        
        ;infratec
        ;DelayMicroSeconds(MusArr(i)\pause * 23) ; but need * 22.675 as 0. 000 022 675s
        
        ;CELTIC88
        ;DelayEx(MusArr(i)\pause) ; i even dont know how to use it
        
        ;lowest pb value
        ;Delay(1)
        
        PlayedTicks + MusArr(i)\pause
        PlayedUS = PlayedTicks * 22.675
        While (CurrentUS < PlayedUS)
          Delay(1)
          CurrentUS.i = (ElapsedMilliseconds() - StartMS) * 1000
        Wend
        
    EndSelect
    
    If stopflag
      Break
    EndIf 
    
  Next

Re: Delay problem

Posted: Fri Dec 11, 2015 8:55 am
by Joris
For this kind of timings you need to use MS-windows API timers (how to do this on OSX I don't know). All other timing-functions can be influenced by the user when moving a window or whatever, which will result in time interrupts.

Re: Delay problem

Posted: Tue Nov 23, 2021 4:33 am
by Rinzwind
Microsecond delay with no loop for Windows (found a c version on net, thought I share)

Code: Select all

Procedure usleep(usec)
	Define timer, ft.LARGE_INTEGER

	ft\QuadPart = -(10 * usec)
	timer = CreateWaitableTimer_(0, #True, 0);
	SetWaitableTimer_(timer, @ft, 0, 0, 0, 0);
	WaitForSingleObject_(timer, #INFINITE);
	CloseHandle_(timer);
EndProcedure

Debug ElapsedMilliseconds()
usleep(10000)
Debug ElapsedMilliseconds()

Repeat
  usleep(1)  
ForEver
CPU usage is 0.