Beispiel #1
0
def open_soundfont():
    global config
    sfpath = check_output("find /home/pi -name '*.sf2'", shell=True).strip()
    sf = [x[9:] for x in sfpath.decode('ascii').split('\n')]
    s = SB.choose_opt(sf, row=1, scroll=True)
    if s < 0:
        return False
    SB.lcd_message("loading...      ", 1)
    load_soundfont(sf[s])
    config['soundfont'] = sf[s]
    write_config()
    SB.waitforrelease(1)
    return True
Beispiel #2
0
def add_fromusb():
    SB.lcd_clear()
    SB.lcd_message("looking for USB \n")
    b = check_output('sudo blkid'.split())
    x = re.findall(b'/dev/sd[a-z]\d*', b)
    if x:
        SB.lcd_message("copying files.. ", 1)
        for u in x:
            call(['sudo', 'mount', u, '/mnt/usbdrv/'])
            call(['sudo', '/home/pi/copyfromUSB.sh'])
            call(['sudo', 'umount', u])
        SB.lcd_clear()
        SB.lcd_message("copying files.. \ndone!")
        SB.waitforrelease(1)
    else:
        SB.lcd_message("USB not found!  ", 1)
        SB.waitforrelease(1)
Beispiel #3
0
def switch_bank():
    global config
    SB.lcd_message("Load Bank:      ")
    bpaths = check_output("find /home/pi -name '*.yaml'", shell=True).strip()
    banks = [x[9:] for x in bpaths.decode('ascii').split('\n')]
    del banks[banks.index('squishbox_settings.yaml')]
    i = SB.choose_opt(banks, row=1, scroll=True)
    if i >= 0:
        SB.lcd_message("loading patches ", 1)
        if not load_bank(banks[i]):
            SB.lcd_message("bank load error!", 1)
            SB.waitforrelease(2)
            return False
        config['currentbank'] = banks[i]
        if config['uselastbank']:
            config['initialbank'] = banks[i]
        write_config()
        SB.waitforrelease(1)
        return True
    return False
Beispiel #4
0
def wifi_settings():
    ssid = check_output(['iwgetid', 'wlan0', '--raw']).strip().decode('ascii')
    ip = re.sub(b'\s.*', b'', check_output(['hostname', '-I'])).decode('ascii')
    if ssid == "":
        statusmsg = "Not connected   \n" + ' ' * 16
    else:
        statusmsg = "%16s\n%-16s" % (ssid, ip)
    j = SB.choose_opt([statusmsg, "Add Network..   \n" + ' ' * 16])
    if j == 1:
        SB.lcd_message("Network (SSID):")
        newssid = SB.char_input()
        if not newssid:
            return
        SB.lcd_message("Password:"******"adding network.." + ' ' * 16)
        f = open('/etc/wpa_supplicant/wpa_supplicant.conf', 'a')
        f.write('network={\n  ssid="%s"\n  psk="%s"\n}\n' % (newssid, newpsk))
        f.close()
        call('sudo service networking restart'.split())
        SB.waitforrelease(1)
Beispiel #5
0
def patch_menu():
    global patches, pno
    k = SB.choose_opt(
        ['Update Patch', 'Save New Patch', 'Rename Patch', 'Delete Patch'], 1)
    if k == 0:
        update_patch(patches[pno])
        SB.lcd_message("updated!        ", 1)
        SB.waitforrelease(1)
    elif k == 1:
        newname = patches[pno]['name']
        x = re.search('[0-9]*$', newname)
        if x.group():
            newname = re.sub('[0-9]*$', "%d" % (int(x.group()) + 1), newname)
        else:
            newname += '2'
        pnew = len(patches)
        patches.append({'name': newname})
        if 'router_rules' in patches[pno]:
            patches[pnew]['router_rules'] = []
            for rule in patches[pno]['router_rules']:
                patches[pnew]['router_rules'].append(dict(rule))
        update_patch(patches[pnew])
    elif k == 2:
        SB.lcd_message("Rename Patch:   ")
        a = SB.char_input(patches[pno]['name'])
        if a:
            patches[pno]['name'] = a
            write_bank()
    elif k == 3:
        if len(patches) < 2:
            SB.lcd_message("only 1 patch!   ", 1)
            SB.waitforrelease(1)
        else:
            del patches[pno]
            pno = (pno - 1) % len(patches)
            select_patch(patches[pno])
            write_bank()
Beispiel #6
0
def saveasnew_bank():
    global config
    x = re.search('([0-9]*).yaml$', config['currentbank'])
    if x.group(1):
        f = re.sub('[0-9]*.yaml$', "%d.yaml" % (int(x.group(1)) + 1),
                   config['currentbank'])
    else:
        f = re.sub('\.yaml$', '2.yaml', config['currentbank'])
    SB.lcd_message("New Bank:       ")
    newbank = SB.char_input(f)
    if newbank:
        if not re.search('\.yaml$', newbank):
            newbank += '.yaml'
        if not write_bank(newbank):
            SB.lcd_message("bank save error!", 1)
            SB.waitforrelease(1)
            return
        call(['sudo', 'chmod', '666', newbank])
        config['currentbank'] = newbank
        if config['uselastbank']:
            config['initialbank'] = newbank
        write_config()
        SB.lcd_message("new bank saved! ", 1)
        SB.waitforrelease(1)
Beispiel #7
0
            saveasnew_bank()
        elif k == 2:
            SB.lcd_message("Output Gain:    ")
            g = SB.choose_val(bank['gain'], 0.1, 0.0, 5.0, "%16.2f")
            bank['gain'] = g
            fluid.setting('synth.gain', g)
            write_bank()
        elif k == 3:
            chorverb_menu()
        elif k == 4:
            SB.lcd_message("Advanced:       ")
            j = SB.choose_opt([
                'Open Soundfont', 'MIDI Reconnect', 'Wifi Settings',
                'Add From USB'
            ], 1)
            if j == 0:
                if open_soundfont():
                    sfp = 0
                    select_sfpreset(sfpresets[sfp])
            if j == 1:
                SB.lcd_message("reconnecting..  ", 1)
                midi_connect()
                SB.waitforrelease(1)
            if j == 2:
                wifi_settings()
            if j == 3:
                add_fromusb()
        elif k == 5:
            SB.lcd_message("Shutting down...\nWait 30s, unplug", 0)
            call('sudo shutdown -h now'.split())