예제 #1
0
파일: UI.py 프로젝트: bldrvnlw/SamplerBox
def RenewMedia(
    val=None
):  # boolean, return value True indicates "preset load in progress",
    try:  # setting optional input to any value except False or "n*" forces a reload of same sample set
        if val and str(
                val)[0].upper() != "N":  # using yes/no is also allowed :-)
            gv.basename = "None"  # start from scratch
            gv.LoadSamples()  # perform the loading
        return gv.ActuallyLoading
    except:
        return True
예제 #2
0
def Preset(val=None):  # 0-127
    try:
        if val != None:
            if val >= 0 and val <= 127:
                if gv.PRESET != val:
                    gv.PRESET = val
                    gv.LoadSamples()
            return gv.ActuallyLoading
        return gv.PRESET
    except:
        return 0
예제 #3
0
파일: UI.py 프로젝트: bldrvnlw/SamplerBox
def Preset(val=None):  # 0-127
    try:
        if val != None:
            if val >= 0 and val <= 127:
                if gv.PRESET != val:
                    if gv.getindex(val, gv.presetlist) > -1:
                        gv.PRESET = val
                        gv.LoadSamples()
                    else:
                        print("Preset %d does not exist, ignored" % val)
                #else: print ("Preset %d already loaded" %val)
            return gv.ActuallyLoading
        return gv.PRESET
    except:
        return 0
예제 #4
0
파일: UI.py 프로젝트: bldrvnlw/SamplerBox
def DefinitionTxt(val=None):  # contains definition.txt
    try:
        if val != None:
            if gv.DefinitionTxt != val:
                gv.DefinitionTxt = val
                fname = gv.samplesdir + gv.presetlist[gv.getindex(
                    gv.PRESET, gv.presetlist)][1] + "/" + gv.SAMPLESDEF
                gp.samples2write()
                with open(fname, 'w') as definitionfile:
                    definitionfile.write(gv.DefinitionTxt)
                gp.samples2read()
                gv.basename = "None"  # do a renew to sync the update
                gv.LoadSamples()
            return gv.ActuallyLoading
        return gv.DefinitionTxt
    except:
        return "** Error **"
예제 #5
0
파일: UI.py 프로젝트: finnolin/SamplerBox-1
def DefinitionTxt(val=None):  # contains definition.txt
    try:
        if val != None:
            if gv.DefinitionTxt != val:
                gv.DefinitionTxt = val
                fname = gv.samplesdir + gv.presetlist[gv.getindex(
                    gv.PRESET, gv.presetlist)][1] + "/" + gv.SAMPLESDEF
                if gv.rootprefix == "":
                    subprocess.call(
                        ['mount', '-vo', 'remount,rw', gv.samplesdir])
                with open(fname, 'w') as definitionfile:
                    definitionfile.write(gv.DefinitionTxt)
                if gv.rootprefix == "":
                    subprocess.call(
                        ['mount', '-vo', 'remount,ro', gv.samplesdir])
                gv.basename = "None"  # do a renew to sync the update
                gv.LoadSamples()
            return gv.ActuallyLoading
        return gv.DefinitionTxt
    except:
        return "** Error **"
예제 #6
0
 def LoadSamples(self):
     gv.ActuallyLoading = True  # safety first, as these processes run in parallel
     gv.LoadSamples()  # perform the loading
     self.do_GET()  # answer the browser
예제 #7
0
def Buttons():
    global lastbuttontime, buttfunc, button_functions, BUT_incr, BUT_decr, BUT_sel, button_disp

    GPIO.setmode(GPIO.BCM)
    GPIO.setup(BUT_incr, GPIO.IN, pull_up_down=GPIO.PUD_UP)
    GPIO.setup(BUT_decr, GPIO.IN, pull_up_down=GPIO.PUD_UP)
    GPIO.setup(BUT_sel, GPIO.IN, pull_up_down=GPIO.PUD_UP)
    lastbuttontime = time.time()
    print 'Started buttons via GPIO: Increment=%d, Decrement=%d, Select=%d' % (
        BUT_incr, BUT_decr, BUT_sel)

    while True:
        now = time.time()
        if (now - lastbuttontime) > 0.2:
            if not GPIO.input(BUT_decr):
                lastbuttontime = now
                if buttfunc == 0:
                    x = gv.getindex(gv.PRESET, gv.presetlist) - 1
                    if x < 0: x = len(gv.presetlist) - 1
                    gv.PRESET = gv.presetlist[x][0]
                    gv.LoadSamples()
                elif buttfunc == 1:
                    gv.volume -= 5
                    if gv.volume < 0: gv.volume = 0
                    gv.setvolume(gv.volume)
                    Button_display()
                elif buttfunc == 2:
                    gv.MIDI_CHANNEL -= 1
                    if gv.MIDI_CHANNEL < 1: gv.MIDI_CHANNEL = 16
                    Button_display()
                elif buttfunc == 3:
                    if not gv.midi_mute:
                        gv.midi_mute = True
                        gv.display("** MIDI muted **")
                    else:
                        gv.midi_mute = False
                        Button_display()
                elif buttfunc == 4:
                    gv.currscale = 0  # scale and chord mode are mutually exclusive
                    gv.currchord -= 1
                    if gv.currchord < 0: gv.currchord = len(gv.chordname) - 1
                    Button_display()
                elif buttfunc == 5:
                    gv.currchord = 0  # scale and chord mode are mutually exclusive
                    gv.currscale -= 1
                    if gv.currscale < 0: gv.currscale = len(gv.scalename) - 1
                    Button_display()

            elif not GPIO.input(BUT_incr):
                lastbuttontime = now
                gv.midi_mute = False
                if buttfunc == 0:
                    x = gv.getindex(gv.PRESET, gv.presetlist) + 1
                    if x >= len(gv.presetlist): x = 0
                    gv.PRESET = gv.presetlist[x][0]
                    gv.LoadSamples()
                elif buttfunc == 1:
                    gv.volume += 5
                    if gv.volume > 100: gv.volume = 100
                    gv.setvolume(gv.volume)
                    Button_display()
                elif buttfunc == 2:
                    gv.MIDI_CHANNEL += 1
                    if gv.MIDI_CHANNEL > 16: gv.MIDI_CHANNEL = 1
                    Button_display()
                elif buttfunc == 3:
                    gv.basename = "None"
                    gv.LoadSamples()
                    #Button_display()   # loadsamples also displays
                elif buttfunc == 4:
                    gv.currscale = 0  # scale and chord mode areLoadSamples mutually exclusive
                    gv.currchord += 1
                    if gv.currchord >= len(gv.chordname): gv.currchord = 0
                    Button_display()
                elif buttfunc == 5:
                    gv.churrchord = 0  # scale and chord mode are mutually exclusive
                    gv.currscale += 1
                    if gv.currscale >= len(gv.scalename): gv.currscale = 0
                    Button_display()

            elif not GPIO.input(BUT_sel):
                lastbuttontime = now
                buttfuncmax = len(button_functions)
                buttfunc += 1
                if buttfunc >= len(button_functions): buttfunc = 0
                if not gv.USE_ALSA_MIXER:
                    if button_disp[buttfunc] == "V": buttfunc += 1
                #use if above gets complex: if buttfunc >= len(button_functions): buttfunc=0
                gv.midi_mute = False
                Button_display()

            time.sleep(0.02)