Exemplo n.º 1
0
def _loop_once():
    """Run the main loop once
    This uses the global variables from setup and start, and adds a set of global variables
    """
    global parser, args, config, r, response, patch
    global monitor, debug, delay, prefix, input_name, input_variable

    if patch.getint('processing', 'enable', default=1):
        # the compressor/expander applies to all channels and must exist as float or redis key
        scale = patch.getfloat('scale', 'lo', default=1.)
        offset = patch.getfloat('offset', 'lo', default=0.)
        lo = patch.getfloat('processing', 'lo')
        lo = EEGsynth.rescale(lo, slope=scale, offset=offset)

        scale = patch.getfloat('scale', 'hi', default=1.)
        offset = patch.getfloat('offset', 'hi', default=0.)
        hi = patch.getfloat('processing', 'hi')
        hi = EEGsynth.rescale(hi, slope=scale, offset=offset)

        monitor.update('lo', lo)
        monitor.update('hi', hi)

        if lo is None or hi is None:
            monitor.debug("cannot apply compressor/expander")
            return

        for name, variable in zip(input_name, input_variable):
            scale = patch.getfloat('scale', name, default=1)
            offset = patch.getfloat('offset', name, default=0)
            val = patch.getfloat('input', name)

            if val == None:
                # the value is not present in redis, skip it
                continue

            val = EEGsynth.rescale(val, slope=scale, offset=offset)
            val = EEGsynth.compress(val, lo, hi)

            key = prefix + "." + variable
            patch.setvalue(key, val)
            monitor.update(key, val)
Exemplo n.º 2
0
                continue

            if chanval == None:
                # the value is not present in redis, skip it
                continue

            if EEGsynth.getint('compressor_expander', 'enable', config, r):
                # the compressor applies to all channels and must exist as float or redis key
                lo = EEGsynth.getfloat('compressor_expander', 'lo', config, r)
                hi = EEGsynth.getfloat('compressor_expander', 'hi', config, r)
                if lo is None or hi is None:
                    if debug > 1:
                        print "cannot apply compressor/expander"
                else:
                    # apply the compressor/expander
                    chanval = EEGsynth.compress(chanval, lo, hi)

            # the scale option is channel specific
            scale = EEGsynth.getfloat('scale', chanstr, config, r, default=1)
            # the offset option is channel specific
            offset = EEGsynth.getfloat('offset', chanstr, config, r, default=0)
            # apply the scale and offset
            chanval = EEGsynth.rescale(chanval, slope=scale, offset=offset)
            chanval = int(chanval)

            if dmxdata[chanindx] != chr(chanval):
                if debug > 0:
                    print "DMX channel%03d" % chanindx, '=', chanval
                # update the DMX value for this channel
                dmxdata = senddmx(dmxdata, chanindx, chanval)
            elif (time.time() - prevtime) > 1:
Exemplo n.º 3
0
            continue

        if chanval==None:
            # the value is not present in redis, skip it
            continue

        if patch.getint('compressor_expander', 'enable'):
            # the compressor applies to all channels and must exist as float or redis key
            lo = patch.getfloat('compressor_expander', 'lo')
            hi = patch.getfloat('compressor_expander', 'hi')
            if lo is None or hi is None:
                if debug>1:
                    print("cannot apply compressor/expander")
            else:
                # apply the compressor/expander
                chanval = EEGsynth.compress(chanval, lo, hi)

        # the scale option is channel specific
        scale = patch.getfloat('scale', chanstr, default=1)
        # the offset option is channel specific
        offset = patch.getfloat('offset', chanstr, default=0)
        # apply the scale and offset
        chanval = EEGsynth.rescale(chanval, slope=scale, offset=offset)

        value[chanindx] = chanval

    for chanindx,chanstr in zip(list(range(numchannel)), inputlist):
        for channel in range(numchannel):
            key = prefix +  "." + chanstr
            val = value[chanindx]
            patch.setvalue(key, val)
Exemplo n.º 4
0
        if any(item is None for item in val):
            # the control value is not present in redis, skip it
            continue
        else:
            val = [float(x) for x in val]

        if EEGsynth.getint('compressor_expander', 'enable', config, r):
            # the compressor applies to all channels and must exist as float or redis key
            lo = EEGsynth.getfloat('compressor_expander', 'lo', config, r)
            hi = EEGsynth.getfloat('compressor_expander', 'hi', config, r)
            if lo is None or hi is None:
                if debug > 1:
                    print "cannot apply compressor/expander"
            else:
                # apply the compressor/expander
                val = EEGsynth.compress(val, lo, hi)

        # the scale option is channel specific
        scale = EEGsynth.getfloat('scale', key1, config, r, default=1)
        # the offset option is channel specific
        offset = EEGsynth.getfloat('offset', key1, config, r, default=0)
        # apply the scale and offset
        val = EEGsynth.rescale(val, slope=scale, offset=offset)

        if debug > 1:
            print 'OSC message', key3, '=', val

        msg = OSC.OSCMessage(key3)
        msg.append(val)
        s.send(msg)