Distribute pyjack with freewheel-related functionality
[jack_freewheel_button.git] / pyjack-0.5.2 / demos / transporter.py
blobf117dd115ea0e6ccf455f3c793f877d6d0ba9174
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
4 import jack
6 #print current time
7 def print_time ():
8 time = float(jack.get_current_transport_frame()) / jack.get_sample_rate()
9 print "current time: %f s" % time
11 #testing state set/get
12 def print_state():
13 state = jack.get_transport_state()
14 statename = {
15 jack.TransportStopped:"stopped",
16 jack.TransportRolling:"rolling",
17 jack.TransportStarting:"starting"
18 } [state]
19 print("current state is %i (%s)"% (state, statename))
21 #testing position set/get
22 from time import sleep
23 jack.attach("transporter.py")
24 print ("getting current time")
25 print_time()
26 print ("going to frame 0")
27 jack.transport_locate(0)
28 sleep (2)
30 print ("getting current time")
31 print_time()
33 sleep (0.5)
34 print ("going to 6 sec")
35 jack.transport_locate(jack.get_sample_rate()*6)
36 sleep (2)
38 print ("getting current time")
39 print_time()
41 print ("TransportStopped: %i" % jack.TransportStopped)
42 print ("TransportRolling: %i" % jack.TransportRolling)
43 print ("TransportStarting: %i" % jack.TransportStarting)
44 print_state()
46 print ("playing")
47 jack.transport_start()
48 sleep(5)
49 print ("stopping")
50 jack.transport_stop()
52 print_time()