de en es fr
Let the machine help
Light teasing, exhibition, BDSM, sissyfication, watersports... with sounds and pictures


Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Displaying timer countdown while sound.
PostPosted: Thu Jun 06, 2019 4:28 pm 
Offline
Veteran
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.


Top
 Profile Send private message 
 
 Re: Displaying timer countdown while sound.
PostPosted: Tue Jun 11, 2019 3:53 pm 
Offline
Site Admin
User avatar
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


Top
 Profile Send private message 
 
 Re: Displaying timer countdown while sound.
PostPosted: Wed Jun 12, 2019 2:35 pm 
Offline
Veteran
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


Top
 Profile Send private message 
 
 Re: Displaying timer countdown while sound.
PostPosted: Thu Jun 13, 2019 5:50 pm 
Offline
Site Admin
User avatar
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.


Top
 Profile Send private message 
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


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 post attachments in this forum

Search for:
Jump to:  


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Maroon Fusion theme created by Oxydo
Software, theme modifications, phpBB modification by Doti 2010, 2015
This website uses session cookies only.