File: klick.py

package info (click to toggle)
mididings 0~20120419~ds0-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 928 kB
  • sloc: python: 5,085; cpp: 3,454; ansic: 319; makefile: 8
file content (33 lines) | stat: -rw-r--r-- 902 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#
# klick.py - uses SendOSC() to start/stop klick, or change its tempo
#
# klick: http://das.nasophon.de/klick/
#
# CC 13 runs/terminates the klick process (alternatively,
# run "klick -P -o 1234"),
# CC 14 starts/stops the metronome, and CC 15 changes tempo.
#

from mididings import *
from mididings.extra.osc import SendOSC

port = 1234

run(
    Filter(CTRL) >> CtrlSplit({
        # CC 13: run/terminate klick process
        13: CtrlValueSplit(
                64,
                SendOSC(port, '/klick/quit'),
                System('klick -P -o %d' % port)
            ),
        # CC 14: start/stop playing
        14: CtrlValueSplit(
                64,
                SendOSC(port, '/klick/metro/stop'),
                SendOSC(port, '/klick/metro/start'),
            ),
        # CC 15: change tempo
        15: SendOSC(port, '/klick/simple/set_tempo', lambda ev: 60 + ev.value)
    })
)