示例#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
示例#2
0
def chorverb_menu():
    global bank
    opts = [
        'Chorus Voices', 'Chorus Level', 'Chorus Speed', 'Chorus Depth',
        'Chorus Type', 'Reverb Size', 'Reverb Damping', 'Reverb Width',
        'Reverb Level'
    ]
    while True:
        SB.lcd_message("Chorus/Reverb   ")
        i = SB.choose_opt(opts, 1)
        if i < 0:
            return
        SB.lcd_message("%-16s" % opts[i])
        if i == 0:
            bank['chorus_nr'] = SB.choose_val(fluid.get_chorus_nr(), 1, 0, 99,
                                              '%16d')
        elif i == 1:
            bank['chorus_level'] = SB.choose_val(fluid.get_chorus_level(), 0.1,
                                                 0.0, 10.0, '%16.1f')
        elif i == 2:
            bank['chorus_depth'] = SB.choose_val(fluid.get_chorus_depth(), 0.1,
                                                 0.0, 21.0, '%16.1f')
        elif i == 3:
            bank['chorus_speed'] = SB.choose_val(fluid.get_chorus_speed(), 0.1,
                                                 0.3, 5.0, '%16.1f')
        elif i == 4:
            bank['chorus_type'] = SB.choose_val(fluid.get_chorus_type(), 1, 0,
                                                1, '%16d')
        elif i == 5:
            bank['reverb_roomsize'] = SB.choose_val(
                fluid.get_reverb_roomsize(), 0.1, 0.0, 1.0, '%16.1f')
        elif i == 6:
            bank['reverb_damping'] = SB.choose_val(fluid.get_reverb_damp(),
                                                   0.1, 0.0, 1.0, '%16.1f')
        elif i == 7:
            bank['reverb_width'] = SB.choose_val(fluid.get_reverb_width(), 1.0,
                                                 0.0, 100.0, '%16.1f')
        elif i == 8:
            bank['reverb_level'] = SB.choose_val(fluid.get_reverb_level(),
                                                 0.01, 0.00, 1.00, '%16.2f')
        set_chorus_reverb()
        write_bank()
示例#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
示例#4
0
def soundfont_menu():
    global config, patches, sfids, sfid
    k = SB.choose_opt(['Save as Patch', 'Exit Soundfont'], 1)
    if k == 0:
        newsfid = fluid.sfload(config['soundfont'])
        sfids[config['soundfont']] = newsfid
        pnew = len(patches)
        patches.append({'name': sfpresets[sfp][0]})
        patches[pnew][0] = {
            'soundfont': config['soundfont'],
            'bank': sfpresets[sfp][1],
            'program': sfpresets[sfp][2]
        }
        write_bank()
    if k == 1:
        config['soundfont'] = ''
        fluid.sfunload(sfid)
        sfid = 0
        select_patch(patches[pno])
        write_config()
示例#5
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)
示例#6
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()
示例#7
0
         pno = (pno + 1) % len(patches)
     elif SB.l_state == SB.STATE_TAP:
         pno = (pno - 1) % len(patches)
     if SB.r_state == SB.STATE_TAP or SB.l_state == SB.STATE_TAP:
         select_patch(patches[pno])
         SB.reset_scroll()
         continue
     elif SB.r_state == SB.STATE_HOLD:
         patch_menu()
         continue
 if SB.r_state + SB.l_state == SB.STATE_NONE:
     continue
 elif SB.l_state == SB.STATE_HOLD:
     SB.lcd_message("Settings:       ")
     k = SB.choose_opt([
         'Switch Bank', 'Save New Bank', 'Set Gain', 'Chorus/Reverb',
         'Advanced..', 'Power Down'
     ], 1)
     if k == 0:
         if switch_bank():
             patches = bank['patches']
             pno = 0
             select_patch(patches[pno])
     elif k == 1:
         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: