Example #1
0
    exit()

# wiringpi.wiringPiSetup()
wiringpi.wiringPiSetupGpio()

pinR = config.getint('output', 'red')
pinG = config.getint('output', 'green')
pinB = config.getint('output', 'blue')

wiringpi.pinMode(pinR, wiringpi.OUTPUT)
wiringpi.pinMode(pinG, wiringpi.OUTPUT)
wiringpi.pinMode(pinB, wiringpi.OUTPUT)

wiringpi.softPwmCreate(pinR, 0, 127)
wiringpi.softPwmCreate(pinG, 0, 127)
wiringpi.softPwmCreate(pinB, 0, 127)

while True:
    time.sleep(config.getfloat('general', 'delay'))

    valR = EEGsynth.getint('input', 'red',   config, r) * EEGsynth.getfloat('scaling', 'red',   config, r)
    valG = EEGsynth.getint('input', 'green', config, r) * EEGsynth.getfloat('scaling', 'green', config, r)
    valB = EEGsynth.getint('input', 'blue',  config, r) * EEGsynth.getfloat('scaling', 'blue',  config, r)

    print valR, valG, valB

    wiringpi.softPwmWrite(pinR, int(valR))
    wiringpi.softPwmWrite(pinG, int(valG))
    wiringpi.softPwmWrite(pinB, int(valB))

Example #2
0
        time.sleep(config.getfloat('general', 'delay'))

        for chanindx in range(1, 512):
            chanstr = "channel%03d" % chanindx

            try:
                chanval = EEGsynth.getfloat('input', chanstr, config, r)
            except:
                # the channel is not configured in the ini file, skip it
                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
Example #3
0
import EEGsynth

config = ConfigParser.ConfigParser()
config.read(os.path.join(installed_folder, os.path.splitext(os.path.basename(__file__))[0] + '.ini'))

# this determines how much debugging information gets printed
debug = config.getint('general','debug')

try:
    r = redis.StrictRedis(host=config.get('redis','hostname'),port=config.getint('redis','port'),db=0)
    response = r.client_list()
except redis.ConnectionError:
    print "Error: cannot connect to redis server"
    exit()

pattern = EEGsynth.getint('input','pattern', config, r, default=0)
previous = pattern

try:
  sequence = config.get('sequence',"pattern{:d}".format(pattern))
except:
  sequence = '0'

print pattern, sequence

try:
    while True:

        for note in sequence.split():
            note = int(note)
Example #4
0
naptime = 0.02

while True:

    # measure the time that it takes
    now = time.time()

    if endsample > nSamples - 1:
        if debug > 0:
            print "End of file reached, jumping back to start"
        begsample = 0
        endsample = 0
        block = 0
        continue

    if EEGsynth.getint('playback', 'rewind', config, r):
        if debug > 0:
            print "Rewind pressed, jumping back to start of file"
        begsample = 0
        endsample = 0
        block = 0
        continue

    if not EEGsynth.getint('playback', 'play', config, r):
        if debug > 0:
            print "Paused"
        time.sleep(0.1)
        continue

    if debug > 1:
        print "Playing control value", block
Example #5
0
for thread in trigger:
    thread.start()

# control values are only relevant when different from the previous value
previous_val = {}
for name in control_name:
    previous_val[name] = None

try:
    while True:
        time.sleep(config.getfloat('general', 'delay'))

        for name, cmd in zip(control_name, control_code):
            split_name = name.split('/')
            # loop over the control values
            val = EEGsynth.getint(split_name[0], split_name[1], config, r)
            if val is None:
                continue#  it should be skipped when not present in the ini or redis
            if val==previous_val[name]:
                continue # it should be skipped when identical to the previous value
            previous_val[name] = val
            msg = mido.Message('control_change', control=cmd, value=val, channel=midichannel)
            if debug>1:
                print cmd, val, name
            lock.acquire()
            outputport.send(msg)
            lock.release()

except KeyboardInterrupt:
    print "Closing threads"
    for thread in trigger:
Example #6
0
    if debug > 0:
        print "Connected to redis server"
except redis.ConnectionError:
    print "Error: cannot connect to redis server"
    exit()

filenumber = 0
recording = False
delay = config.getfloat('general', 'delay')
adjust = 1

while True:
    # measure the time to correct for the slip
    now = time.time()

    if recording and not EEGsynth.getint('recording', 'record', config, r):
        if debug > 0:
            print "Recording disabled - closing", fname
        f.close()
        recording = False
        continue

    if not recording and not EEGsynth.getint('recording', 'record', config, r):
        if debug > 0:
            print "Recording is not enabled"
        time.sleep(1)

    if not recording and EEGsynth.getint('recording', 'record', config, r):
        recording = True
        # open a new file
        fname = config.get('recording', 'file')
Example #7
0
init_midi   = False
init_serial = False

previous_use_midi = None
previous_use_serial = None

try:
    # start the thread that synchronizes over MIDI
    midisync = MidiThread()
    midisync.start()

    while True:
        # measure the time to correct for the slip
        now = time.time()

        use_serial = EEGsynth.getint('general', 'serial', config, r, default=0)
        use_midi   = EEGsynth.getint('general', 'midi', config, r, default=0)
        use_redis  = EEGsynth.getint('general', 'redis', config, r, default=0)

        if previous_use_serial is None:
            previous_use_serial = not(use_serial);

        if previous_use_midi is None:
            previous_use_midi = not(use_midi);

        if use_serial and not init_serial:
            # this might not be running at the start
            serialport = initialize_serial()
            init_serial = True

        if use_midi and not init_midi: