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
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()
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)
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
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)
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()
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)
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) ### STARTUP ### SB.lcd_clear() SB.lcd_message("Squishbox v2.0", 0) SB.lcd_message("setting up", 1) # load main settings file try: f = open('/home/pi/squishbox_settings.yaml') config = yaml.safe_load(f) except yaml.YAMLError or IOError: SB.lcd_message("bad config file!", 1) time.sleep(10) f.close() # to do -- # if fluidversion is in settings, # set some environment variable so # fluidsynth.py knows where it is, then