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()
import jack def print_time(): print("current time: %f s" % (float(jack.get_current_transport_frame()) / jack.get_sample_rate())) #testing position set/get from time import sleep jack.attach("/var/run/jack") print("getting current time") print_time() print("going to frame 0") jack.transport_locate(0) sleep(0.2) print("getting current time") print_time() sleep(0.2) print("going to 6 sec") jack.transport_locate(jack.get_sample_rate() * 6) sleep(0.2) print("getting current time") print_time() #testing state set/get def print_state():
def stop(self): jack.transport_stop() jack.transport_locate(0) self.b_play.setChecked(False)
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_state(): state = jack.get_transport_state() statename = { jack.TransportStopped:"stopped", jack.TransportRolling:"rolling", jack.TransportStarting:"starting" } [state] print("current state is %i (%s)"% (state, statename)) #testing position set/get from time import sleep jack.attach("transporter.py") print ("getting current time") print_time() print ("going to frame 0") jack.transport_locate(0) sleep (2) print ("getting current time") print_time() sleep (0.5) print ("going to 6 sec") jack.transport_locate(jack.get_sample_rate()*6) sleep (2) print ("getting current time") print_time() print ("TransportStopped: %i" % jack.TransportStopped) print ("TransportRolling: %i" % jack.TransportRolling)
def goForward(self): jack.transport_locate(jack.get_current_transport_frame() + 100000)