Ejemplo n.º 1
0
 def play_sequence(self):
     if self.dbg > 0:
         print('[+] playing sequence %i' % self._seq_cnt)
     # recompute sequence and step durations, and STEP_GRID
     self.update_internals()
     # initialize the list of played steps
     self._step_played = [0]
     # ensure we respect sequence duration
     T0 = time()
     # launch step 0, and loop over all subsequent steps
     threadit(self.play_step, (0,))
     while time() - T0 < self.SEQ_DUR:
         # go over the STEP_GRID step by step, on time
         # 1) check in which step we are
         step = int((time()-T0) / self.STEP_DUR)
         # 2) play all steps that are not yet played
         for s in range(self._step_played[-1]+1, step+1):
             threadit(self.play_step, (s,))
             self._step_played.append(s)
         # 3) sleep to wait until next step
         sleep(self._TIME_RES)
     # reinit internal attribute
     self._step_played = []
     # update sequence counter
     self._seq_cnt += 1
Ejemplo n.º 2
0
 def start(self):
     # start the sequencer, backgrounding ._run()
     self._running = True
     threadit(self._run, ())