def loop(): '''Main loop function, calls processing sub-functions.''' global _jackRunning # compute the current tick interval = 60.0 / tempo / 2 # call the loop twice per beat (for blinking) transportTime = float( jack.get_current_transport_frame()) / jack.get_sample_rate() tickCount = math.floor(transportTime / interval) if tickCount > 0 and not _jackRunning: print 'jack is up and running... starting monome sequencer' _jackRunning = True if jack.get_transport_state() != jack.TransportRolling: # jack is stopped... stop processing here, as well if tickCount == 0 and _jackRunning: print 'jack transport has been stopped... waiting for jack to be restarted' _jackRunning = False mon.led_all(0) for i, itrack in tracks.iteritems(): itrack.clear() Timer(0.1, loop).start() return # processing readEvents(tickCount) beat(tickCount) # see when the loop needs to be called the next time transportTime = float( jack.get_current_transport_frame()) / jack.get_sample_rate() waitTime = (tickCount + 1) * interval - transportTime Timer(waitTime, loop).start()
def loop(): """Main loop function, calls processing sub-functions.""" global _jackRunning # compute the current tick interval = 60.0 / tempo / 2 # call the loop twice per beat (for blinking) transportTime = float(jack.get_current_transport_frame()) / jack.get_sample_rate() tickCount = math.floor(transportTime / interval) if tickCount > 0 and not _jackRunning: print "jack is up and running... starting monome sequencer" _jackRunning = True if jack.get_transport_state() != jack.TransportRolling: # jack is stopped... stop processing here, as well if tickCount == 0 and _jackRunning: print "jack transport has been stopped... waiting for jack to be restarted" _jackRunning = False mon.led_all(0) for i, itrack in tracks.iteritems(): itrack.clear() Timer(0.1, loop).start() return # processing readEvents(tickCount) beat(tickCount) # see when the loop needs to be called the next time transportTime = float(jack.get_current_transport_frame()) / jack.get_sample_rate() waitTime = (tickCount + 1) * interval - transportTime Timer(waitTime, loop).start()
def refreshUi(self): state = jack.get_transport_state() frame = jack.get_current_transport_frame() rate = jack.get_sample_rate() # Jack State if (state == 0): self.l_state.setText("Stopped") self.b_play.setChecked(False) elif (state == 1): self.l_state.setText("Rolling") self.b_play.setChecked(True) elif (state == 3): self.l_state.setText("Starting") else: self.l_state.setText("Unknown (%i)" % state) # Current Time time = frame / rate secs = time % 60 mins = (time / 60) % 60 hrs = (time / 3600) % 60 secH = minH = hrsH = "" if secs < 10: secH = "0" if mins < 10: minH = "0" if hrs < 10: hrsH = "0" self.l_time.setText(hrsH+str(hrs)+":"+minH+str(mins)+":"+secH+str(secs)) # Current Frame self.l_frame.setText(str(frame))
def refreshUi(self): state = jack.get_transport_state() frame = jack.get_current_transport_frame() rate = jack.get_sample_rate() # Jack State if (state == 0): self.l_state.setText("Stopped") self.b_play.setChecked(False) elif (state == 1): self.l_state.setText("Rolling") self.b_play.setChecked(True) elif (state == 3): self.l_state.setText("Starting") else: self.l_state.setText("Unknown (%i)" % state) # Current Time time = frame / rate secs = time % 60 mins = (time / 60) % 60 hrs = (time / 3600) % 60 secH = minH = hrsH = "" if secs < 10: secH = "0" if mins < 10: minH = "0" if hrs < 10: hrsH = "0" self.l_time.setText(hrsH + str(hrs) + ":" + minH + str(mins) + ":" + secH + str(secs)) # Current Frame self.l_frame.setText(str(frame))
def refresh(): global ret_blender_curr global ret_blender_next global ret_jack_current global prev_blen global prev_jack getFrames() #print "blender old", prev_blen #print "blender frame is", ret_blender_curr #print "jack old", prev_jack #print "jack frame is", ret_jack_current if (prev_jack != ret_jack_current): #Jack changed, externally Set("curframe", ret_blender_next) #Window.Redraw(Window.Types.ACTION) Window.Redraw(Window.Types.BUTS) #Window.Redraw(Window.Types.IMAGE) #Window.Redraw(Window.Types.IMASEL) #Window.Redraw(Window.Types.INFO) Window.Redraw(Window.Types.SEQ) #Window.Redraw(Window.Types.TEXT) Window.Redraw(Window.Types.VIEW3D) elif (prev_blen != ret_blender_curr): #Blender changed, internally jack.transport_locate(ret_blender_curr) while jack.get_current_transport_frame() != ret_blender_curr: time.sleep(0.01) # waiting till pyjack applyed transport id = Window.GetAreaID() Window.QAdd(id, Draw.TIMER3, 0, 1) prev_blen = ret_blender_curr prev_jack = ret_jack_current
def button_event(evt): global play_button currentJackFrame = jack.get_current_transport_frame() if evt == BEV_PLAY: #play/pause if play_button.val == 1: jack.transport_start() else: jack.transport_stop() elif evt == BEV_START: #back to 0 jack.transport_locate(0) elif evt == BEV_PREV: #go back nextJackFrame = currentJackFrame - 200000 if (nextJackFrame < 0): nextJackFrame = 0 jack.transport_locate(nextJackFrame) elif evt == BEV_NEXT: #go forward nextJackFrame = currentJackFrame + 200000 jack.transport_locate(nextJackFrame) elif evt == BEV_EXIT: #quit script jack.detach() Draw.Exit()
def getFrames(): global ret_blender_curr global ret_blender_next global ret_jack_current currblenframe = Get("curframe") currjackframe = jack.get_current_transport_frame() rate = jack.get_sample_rate() fps = Scene.GetCurrent().getRenderingContext().fps fpsBase = Scene.GetCurrent().getRenderingContext().fpsBase factor = int(rate / (fps / fpsBase)) ret_blender_curr = currblenframe * factor ret_blender_next = currjackframe / factor ret_jack_current = currjackframe
def print_time(): print("current time: %f s" % (float(jack.get_current_transport_frame()) / jack.get_sample_rate()))
def goForward(self): jack.transport_locate(jack.get_current_transport_frame()+100000)
def goBack(self): pos = int(jack.get_current_transport_frame()) - 100000 if pos < 0: jack.transport_locate(0) else: jack.transport_locate(pos)
def print_time (): time = float(jack.get_current_transport_frame()) / jack.get_sample_rate() print "current time: %f s" % time
def print_time (): print ("current time: %f s" % ( float(jack.get_current_transport_frame())/jack.get_sample_rate() ) )
def goForward(self): jack.transport_locate(jack.get_current_transport_frame() + 100000)
def print_time(): time = float(jack.get_current_transport_frame()) / jack.get_sample_rate() print "current time: %f s" % time
def get_time(): return float(jack.get_current_transport_frame()) / jack.get_sample_rate()