Пример #1
0
def forward_handler(addr, tags, data, source):
    global prefix
    global scake
    global offset

    if debug > 1:
        print "---"
        print "source %s" % OSC.getUrlStr(source)
        print "addr   %s" % addr
        print "tags   %s" % tags
        print "data   %s" % data

    if addr[0] != '/':
        # ensure it starts with a slash
        addr = '/' + addr

    if tags == 'f' or tags == 'i':
        # it is a single value
        key = prefix + addr.replace('/', '.')
        val = EEGsynth.rescale(data[0], slope=scale, offset=offset)
        EEGsynth.setvalue(key, val)

    else:
        for i in range(len(data)):
            # it is a list, send it as multiple scalar control values
            # append the index to the key, this starts with 0
            key = prefix + addr.replace('/', '.') + '.%i' % i
            val = EEGsynth.rescale(data[i], slope=scale, offset=offset)
            EEGsynth.setvalue(key, val)
Пример #2
0
                if patch.getstring('processing',
                                   'detect') == 'release' and msg.velocity > 0:
                    pass
                elif patch.getstring(
                        'processing',
                        'detect') == 'press' and msg.velocity == 0:
                    pass
                else:
                    # prefix.noteXXX=velocity
                    key = '{}.note{:0>3d}'.format(
                        patch.getstring('output', 'prefix'), msg.note)
                    val = msg.velocity
                    val = EEGsynth.rescale(val,
                                           slope=output_scale,
                                           offset=output_offset)
                    EEGsynth.setvalue(key, val)
                    # prefix.note=note
                    key = '{}.note'.format(patch.getstring('output', 'prefix'))
                    val = msg.note
                    EEGsynth.setvalue(key, val)
            elif hasattr(msg, 'control'):
                # ignore these
                pass
            elif hasattr(msg, 'time'):
                # ignore these
                pass

except KeyboardInterrupt:
    print 'Closing threads'
    for thread in trigger:
        thread.stop()