WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 05-16-2016, 08:25 AM
jelly jelly is offline
Member
 
Join Date: Feb 2016
Posts: 38
Question Scheduling action at different timings using time.time()

Hello!


I am trying to schedule an action (a beep sound) in Vizard. However, I want the beep to happen at certain timings since onset of the trial.

What I have so far gives me (for example, after running it once) a list of times "times: [ 1.89229142 5.2610474 9.86058804 11.43137033 13.87078666]" and is playing the beep at what seems to be varying intervals and prints out the elements of the above mentioned list. It's just that it's not actually using these elements as seconds/timings at which to play.

My question is: How do I make Python know that these are not just numbers, but timings since onset of the function/trial? Probably I am supposed to use time.time() somewhere, but I am just not sure about the logic of how to get there.

Code:
import time
import numpy as np
import viztask                                              


### Start Vizard ### 
viz.go()


### Cue sound ###
cue = viz.addAudio('cues\dong.wav') 
cueDuration = cue.getDuration() 

### Timings ###

def uniform_min_range(a, b, n, min_dist):
    while True:
        times = np.random.uniform(a, b, size=n)
        np.sort(times)
        if np.all(np.diff(times) >= min_dist):
            return times

def timings():
    global times
    times = uniform_min_range(0, 20, 5, 1.0)
    print "times: ", times


def main():
    global times
    timesIndex =0
    for x in range(len(times)):
        cuetime = times[timesIndex]
        cue.play()
        print 'cue'
        print cuetime
        yield viztask.waitTime(cueDuration + cuetime)
        cue.stop()
        timesIndex = timesIndex + 1



timings_short()
viztask.schedule(main())
Reply With Quote
  #2  
Old 05-20-2016, 04:19 AM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
You can use the viz.tick command to get the time since the script has started.
Reply With Quote
Reply

Tags
time, timing

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Walking action of avatars SivaKartheek Vizard 3 01-08-2016 10:17 AM
Walking action of avatars(files are attached) SivaKartheek Vizard 1 12-15-2015 07:36 AM
walking action of avatars SivaKartheek Vizard 1 12-14-2015 11:58 PM
vizact move action andreionutz Vizard 13 11-19-2014 03:54 AM
How to make avatar's eyes to blink when speaking michelcm3 Vizard 12 01-15-2008 09:48 AM


All times are GMT -7. The time now is 11:12 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC