-
Notifications
You must be signed in to change notification settings - Fork 0
/
ahkjam.py
46 lines (40 loc) · 1.94 KB
/
ahkjam.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
46
import ahk
import random
import time
bpm = 60 # change this to whatever bpm you like
events = 300 # playback will consist of this many sound 'events'
stay_back_forward = [0.4, 0.6, 1.0] # cumulative for the probabilities [0.4, 0.2, 0.4]
same_or_reroll_position = [0.6, 1.0] # cumulative for the probabilities [0.6, 0.4]
same_or_reroll_duration = [0.5, 1.0] # cumulative for the probabilities [0.5, 0.5]
qnote = 60.0/bpm
durations = [qnote * 2, qnote, qnote / 2, qnote / 4, qnote * 2 / 3, qnote * 2 / 5, qnote * 2 / 7, qnote * 4 / 9]
interval = durations[random.randint(0,7)]
position = random.randint(18, 251) # where 18 is the leftmost end of the transport bar, and 251 the rightmost
keystroke = 'x'
ahk.start()
ahk.ready()
ahk.execute('Esc::\nSend v\nExitApp') # 'safe word' / key is Esc
ahk.execute('SetMouseDelay, 0')
ahk.execute('SetKeyDelay, 0')
ahk.execute('WinActivate, ahk_class Winamp v1.x')
ahk.execute('Click 108,62') # clicks volume to 0%
ahk.execute('Send ' + keystroke)
for x in range(0, events):
if random.random() > same_or_reroll_position[0]:
position = random.randint(18, 251)
if random.random() > same_or_reroll_duration[0]:
interval = durations[random.randint(0,7)]
p = random.random()
if p < stay_back_forward[0]:
keystroke = 'x' # where 'x' is the keyboard shortcut for 'play' (on Winamp it restarts playing track)
elif p < stay_back_forward[1]:
keystroke = 'z' # where 'z' is the shortcut for 'previous track' (on Winamp, if it is already on very first track, no harm done)
else:
keystroke = 'b' # where 'b' is the shortcut for 'next track' (on Winamp, if it is already on very last track, no harm done)
ahk.execute('Click 108,62') # volume 0%
ahk.execute('Send ' + keystroke)
ahk.execute('Click ' + str(position) + ',75')
ahk.execute('Click 170,62') # volume 100%
time.sleep(interval)
ahk.execute('Send v') # stop
ahk.execute('ExitApp')