#1
|
|||
|
|||
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()) |
Tags |
time, timing |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Walking action of avatars | SivaKartheek | Vizard | 3 | 01-08-2016 09:17 AM |
Walking action of avatars(files are attached) | SivaKartheek | Vizard | 1 | 12-15-2015 06:36 AM |
walking action of avatars | SivaKartheek | Vizard | 1 | 12-14-2015 10:58 PM |
vizact move action | andreionutz | Vizard | 13 | 11-19-2014 02:54 AM |
How to make avatar's eyes to blink when speaking | michelcm3 | Vizard | 12 | 01-15-2008 08:48 AM |