-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.py
48 lines (39 loc) · 1.18 KB
/
example.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
47
48
import pygame, mido
from pygame import midi as midi
import random as rand
import os
# for some reason, mido can't connect in my environment unless
# i use pygame (to initialize portmidi...?)
midi.init()
# This is my midi controller, which has din-midi and usb-midi
# the jx8p is connected to this controller
mo=mido.open_output("Bitstream 3X")
mi=mido.open_input("Bitstream 3X")
# This is my jx8p patcher
import jx8p_patcher as jx8p
# I have a bunch of .syx files for the jx8p
# here is an example of loading a .syx file as a patch
p1=jx8p.Patch(r"C:\Users\Dylan\Downloads\jx8p.syx\jcb\dryrhodes.syx")
p2=jx8p.Patch(r"C:\Users\Dylan\Downloads\jx8p.syx\jcbceleste1.syx")
def cclerp(patch1, patch2):
"""
maps any midi cc to an interpolation
at the moment, this is hardcoded
Every step actually generates a new patch
and dispatches it to the midi output i opened
earlier.
"""
while True:
m = mi.receive()
if m.type == 'control_change':
p=jx8p.lerp2(patch1, patch2, m.value)
mo.send(jx8p.message(p))
# this
def rp():
"""
returns a randomized JX8P patch object
"""
p = jx8p.Patch()
for param in p.parameters:
param.value = rand.randint(0,128)
return p