Example #1
0
 def osc_send_cb(self, widget):
     #osc.Message("/filter/cutoff", [145.1232]).sendlocal(port)
     #sub in current widget value to sub location. Iterate over all paths for multid widgets
     if hasattr(widget, 'split_path'):
         if (type(widget) == phat.Pad):
             parms = [
                 widget.get_x().value,
                 widget.get_y().value,
                 widget.get_xtilt().value,
                 widget.get_ytilt().value,
                 widget.get_pressure().value
             ]
             #print parms
             for i in range(len(widget.split_path)):
                 if len(widget.split_path[i]) > 0:
                     widget.split_path[i][widget.sub_index[i]] = parms[i]
                     osc.Message(
                         widget.split_path[i][0], widget.split_path[i]
                         [1:len(widget.split_path)]).sendlocal(
                             widget.port[i])
                     #print 'osc.Message(', widget.split_path[i][0], widget.split_path[i][1:len(widget.split_path)], ').sendlocal(', widget.port[i],')'
         else:
             if len(widget.split_path[0]) > 0:
                 widget.split_path[0][
                     widget.sub_index[0]] = widget.get_value()
                 osc.Message(
                     widget.split_path[0][0], widget.split_path[0]
                     [1:len(widget.split_path[0])]).sendlocal(
                         widget.port[0])
                 #print 'osc.Message(', widget.split_path[0][0], widget.split_path[0][1:len(widget.split_path[0])], ').sendlocal(', widget.port[0], ')'
     return
Example #2
0
def send_col(col):
    print("colour shift: " + col)
    osc.Message("/eval", [
        "(play-now (mul (adsr 0 0.1 1 0.1)" +
        "(sine (mul (sine 30) 800))) 0)" + "(set-warp-yarn! loom warp-yarn-" +
        col + ")" + "(set-weft-yarn! loom weft-yarn-" + col + ")"
    ]).sendlocal(8000)
Example #3
0
def do_colour_change(v,state):
    decision = 0
    dec=""
    if are_eq(v,[0,0,0,1]):
        decision = 1
        dec="a"
    elif are_eq(v,[0,0,1,0]):
        decision = 2
        dec="b"
    elif are_eq(v,[0,1,0,0]):
        decision = 3
        dec="c"
    elif are_eq(v,[1,0,0,0]):
        decision = 4
        dec="d"
    elif are_eq(v,[0,1,1,1]):
        decision = 5
        dec="e"

    if decision>0 and decision==state.last_decision:
        state.strength+=1

        if state.strength>10:
            print "COLOUR SHIFT",dec
            osc.Message("/eval",["(play-now (mul (adsr 0 0.1 1 0.1)"+
                                 "(sine (mul (sine 30) 800))) 0)"+
                                 "(set-warp-yarn! loom warp-yarn-"+dec+")"+
                                 "(set-weft-yarn! loom weft-yarn-"+dec+")"]).sendlocal(8000)
            state.strength=-100000

    else: state.strength=0

    state.last_decision = decision
Example #4
0
def send_weave_structure(blocks,last):
    weave = blocks

    conv = ""
    for n,i in enumerate(weave):
        if i==0: conv+="0 "
        else: conv+="1 "
        if n%5==4: conv+="\n"

    #print conv

    if last!=conv:
        last=conv
        osc.Message("/eval",["(loom-update! loom (list \n"+conv+"))"]).sendlocal(8000)


        try:
            osc.Message("/matrix",blocks).sendto("192.168.0.2",8000)
        except Exception:
            pass

    return last
Example #5
0
def send_weave_structure(blocks,last):
    weave = blocks

    conv = ""
    for n,i in enumerate(weave):
        conv+=str(i)+" "
        if n%5==4: conv+="\n"


    if last!=conv:
        print conv
        last=conv
        try:
            osc.Message("/matrix",blocks).sendto("192.168.0.2",8000)
        except Exception:
            pass
    return last
Example #6
0
def send_weave_structure(blocks, last):
    weave = [
        blocks[0], blocks[1], blocks[2], blocks[3], blocks[8], blocks[9],
        blocks[10], blocks[11], blocks[16], blocks[17], blocks[18], blocks[19],
        blocks[24], blocks[25], blocks[26], blocks[27]
    ]
    conv = reduce(lambda r, e: r + "0 " if e == 0 else r + "1 ", weave, "")

    if last != conv:
        last = conv
        osc.Message("/eval", [
            "(with-primitive warp \n  (set-draft! \n    warp-draft-start \n      (list "
            + conv + ")))\n" +
            "(with-primitive weft \n  (set-draft! \n    weft-draft-start \n      (list "
            + conv + ")))"
        ]).sendlocal(8000)
    return last
Example #7
0
def send_weave_structure_raw(blocks,last):
    weave = blocks

    conv = ""
    for n,i in enumerate(weave):
        if i==0: conv+="0 "
        else: conv+="1 "
        if n%5==4: conv+="\n"

    #print conv

    if last!=conv:
        last=conv

        try:
            print("sending to alex:",blocks)
            osc.Message("/matrix",blocks).sendto("192.168.0.2",8000)
        except Exception:
            pass

    return last
Example #8
0
import osc,time

bpm=43
#bpm=60
beat=0

#osc.Message("/socketio",[100.0,100.0]).sendlocal(9998)

while 1:
     print("sync")
     osc.Message("/sync",[beat,bpm]).sendlocal(8000)
     delay=(1/(bpm/60.0))
     print(delay)
     beat+=1
     time.sleep(delay)
Example #9
0
def send_pattern(pat):
    osc.Message("/eval",
                ["(loom-update! loom (list \n" + pat + "))"]).sendlocal(8000)
Example #10
0

flip = 1


def update_debug(pat):
    #print(pat)
    global flip
    if flip == 1: flip = 0
    else: flip = 1

    sev_seg.write(bus, debug_mcp,
                  [pat[0], pat[1], 0, 0, 0, pat[3], pat[2], flip])


osc.Message("/eval", ["(set-scale pentatonic-minor)"]).sendlocal(8000)

#######################################################

last = ""
last_col = 0

while True:
    for address in mcp:
        grid.update(frequency, address, mcp23017.read_inputs_a(bus, address),
                    mcp23017.read_inputs_b(bus, address))
    pat = build_pattern(grid.data(5), symbols)
    cc = pat[0] + pat[1] + pat[2] + pat[3] + pat[4]
    if cc != last:
        last = cc
        print("   " + pat[0] + "\n   " + pat[1] + "\n   " + pat[2] + "\n   " +
Example #11
0
def send_ar(pat):
    try:
        osc.Message("/matrix", [pat]).sendto("10.42.0.6", 8000)
    except Exception:
        pass
Example #12
0
def send_pattern(pat):
    osc.Message("/eval",["(lz-prog l 0 \""+pat[0]+"\")\n "+\
                         "(lz-prog l 1 \""+pat[1]+"\")\n "+\
                         "(lz-prog l 2 \""+pat[2]+"\")\n "+\
                         "(lz-prog l 3 \""+pat[3]+"\")\n "]).sendlocal(8000)
Example #13
0
def send_bar(bar):
    print("bar: " + str(bar))
    osc.Message("/eval",
                ["(set-nz-bar-reset! z " + str(bar) + ")"]).sendlocal(8000)
Example #14
0
def send_vx(vx):
    print("vx: " + str(vx))
    osc.Message("/eval", ["(set-nz-vx! z " + str(vx) + ")"]).sendlocal(8000)
Example #15
0
for device_folder in device_folders:
    old_temps.append(0)

while True:
    for i in range(0, len(device_folders)):
        temp_c = read_temp(i)

        if temp_c > max_temp: max_temp = temp_c
        if temp_c < min_temp: min_temp = temp_c

        # gradual recalibration
        #max_temps[i]*=0.99
        #min_temps[i]*=1.01

        temp_range = max_temp - min_temp
        #print(str(temp_range)+" "+str(min_temps[i])+" "+str(max_temps[i]))

        temp_norm = 0
        if temp_range > 0:
            temp_norm = (temp_c - min_temp) / temp_range

        #print(str(i)+":"+str(temp_c))
        #print(str(i)+":"+str(temp_c-old_temps[i]))
        #print(str(i)+" norm :"+str(temp_norm))
        osc.Message("/temp-" + str(i), [temp_c]).sendlocal(8889)
        osc.Message("/tempdiff-" + str(i),
                    [temp_c - old_temps[i]]).sendlocal(8889)
        osc.Message("/tempnorm-" + str(i), [temp_norm]).sendlocal(8889)
        old_temps[i] = temp_c
Example #16
0
def send_sch(sch):
    print("sch: " + sch)
    osc.Message("/eval", ["(set-scale " + sch + ")"]).sendlocal(8000)
Example #17
0
    ">": [1, 0, 1, 1],
    "+": [1, 1, 0, 1],
    "-": [1, 1, 1, 0]
}


def send_pattern(pat):
    osc.Message("/eval",["(lz-prog l 0 \""+pat[0]+"\")\n "+\
                         "(lz-prog l 1 \""+pat[1]+"\")\n "+\
                         "(lz-prog l 2 \""+pat[2]+"\")\n "+\
                         "(lz-prog l 3 \""+pat[3]+"\")\n "]).sendlocal(8000)


def send_grp(grp):
    osc.Message("/eval", ["(set-nz-grp! z " + str(grp) + ")"]).sendlocal(8000)


send_grp(3)

osc.Message("/eval", ["(set-scale '(2 4 2 2 2))"]).sendlocal(8000)
#osc.Message("/eval",["(set-scale '(2 2 2 2 2 2))"]).sendlocal(8000)

#osc.Message("/eval",["(synth-record \"dz\")"]).sendlocal(8000)

#send_pattern(["B+B-B",
#              "abcdc",
#              "acaaA",
#              "--A++"])

send_pattern(["........", "aaaaa", "-aAa+", "-aAa+"])
Example #18
0
def send_mul(mul):
    print("mul: " + str(mul))
    osc.Message("/eval",
                ["(set-nz-bpm-mult! z " + str(mul) + ")"]).sendlocal(8000)
Example #19
0
def send_grp(grp):
    osc.Message("/eval", ["(set-nz-grp! z " + str(grp) + ")"]).sendlocal(8000)
Example #20
0
def read_temp_raw():
    f = open(device_file, 'r')
    lines = f.readlines()
    f.close()
    return lines

def read_temp():
    lines = read_temp_raw()
    while lines[0].strip()[-3:] != 'YES':
        lines = read_temp_raw()
    equals_pos = lines[1].find('t=')
    if equals_pos != -1:
        temp_string = lines[1][equals_pos+2:]
        temp_c = float(temp_string) / 1000.0
        # temp_f = temp_c * 9.0 / 5.0 + 32.0
        return temp_c

old_temp = 0

while True:
	temp_c = read_temp()
	print(temp_c)
	print(temp_c-old_temp)
        # send the current temperature out over osc
	osc.Message("/temp",[temp_c]).sendlocal(8889)
        # sends the difference from the last recorded over osc
	osc.Message("/tempdiff",[temp_c-old_temp]).sendlocal(8889)
	old_temp = temp_c
	time.sleep(0.1)