WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #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
 

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 01:52 PM.


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