SexScripts : Displaying timer countdown while sound. - https://ss.deviatenow.com:443/viewtopic.php?f=4&t=902 Page 1 of 1

Displaying timer countdown while sound.

cd228 [ Thu Jun 06, 2019 4:28 pm ]

Hi.

How would you make a timer countdown while stroking to the beat?

I made this little tool:

Code:
def metronome = { speed ->
   def baud = 100
   def timeLeft = timePerSquare
   def counter = 0
   def speedBaud = (int)((1/speed)*baud)
   
   while(timeLeft>0){
      if(counter%baud==0){
         timeLeft--
         show("Time: "+timeLeft)
      }
      if(counter%speedBaud==0){
         playBackgroundSound("tom.wav")
      }
      counter++
      sleep((int)(1000/baud))

   }
}


It basically displays the time left, and the sound is independent from the timer. The problem is that there is a small delay when using the show(), causing it to beat irregularly. If i comment this line out it works perfectly.

Is there a way to minimize the delay, or another way to optain the same effect? In fact, I want there to be a timer countdown, while stroking is sounding while there is a button, which can be pressed before the time runs out.

Re: Displaying timer countdown while sound.

doti [ Tue Jun 11, 2019 3:53 pm ]

If you want a better timer, you have to use the system time :
  • at the beginning of the loop, get a timestamp (for example with System.currentTimeMillis() )
  • at the end of the loop, before sleeping, get a another timestamp and calculate exactly how much you have to wait

Re: Displaying timer countdown while sound.

cd228 [ Wed Jun 12, 2019 2:35 pm ]

Will that help with the irregular delay caused by the show() function?
The problem doesnt seem to be with the way i calculate the delay, but when text i shown

Re: Displaying timer countdown while sound.

doti [ Thu Jun 13, 2019 5:50 pm ]

The main goal is to know how much time elapsed already in the loop (show or not for example), to wait less if needed. Sus a regular total time for each loop.

Page 1 of 1 All times are UTC + 1 hour [ DST ]
https://ss.deviatenow.com:443/
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Maroon Fusion theme created by Oxydo
Software, theme modifications, phpBB modification by Doti 2010, 2011