-
Notifications
You must be signed in to change notification settings - Fork 68
/
Copy pathex-tempo-modulate.py
executable file
·45 lines (38 loc) · 1.34 KB
/
ex-tempo-modulate.py
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
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env python3
#------------------------------------------------------------------------
# pylive: ex-tempo-modulate.py
#
# Slowly modulates the tempo of a Live set.
#------------------------------------------------------------------------
from live import *
import time
import math
import logging
logging.basicConfig(format="%(asctime)-15s %(message)s")
logging.getLogger("live").setLevel(logging.INFO)
#------------------------------------------------------------------------
# Don't need to scan the set for simple set-wide operations.
#------------------------------------------------------------------------
def main():
set = Set(scan=True)
tempo_default = 120.0
tempo_range = tempo_default * 0.5
sleep = 0.01
period = 10.0
t = 0.0
#------------------------------------------------------------------------
# Change the set's tempo every 0.01s based on a smooth sinusoid,
# giving a wave-like tempo modulation.
#
# The below are synonymous:
#
# set.tempo = 120.0
# set.set_tempo(120.0)
#------------------------------------------------------------------------
print("Modulating tempo of Live set...")
while True:
set.tempo = tempo_default + (tempo_range * math.sin(math.pi * 2.0 * t / period))
time.sleep(sleep)
t += sleep
if __name__ == "__main__":
main()