예제 #1
0
def readCCmap(ifile, override=False):
    # CCmap: [buttonindex, procedureindex , additional procedure parameter, voice]
    CCmap=[]
    try:
        sheet=readcsv(ifile)
        for i in range(len(sheet)):
            voice=0
            if override:
                x=sheet[i].pop(0)
                try:
                    voice=int(x)
                except:
                    print("%s: Invalid voice %s, ignoring %s" %(ifile, x, str(sheet[i])))
                    gv.ConfigErr=True
                    continue
            if sheet[i][0]!=gv.UA:      # skip unassigned controllers
                values=[0,"",None,voice]
                x=gv.getindex(sheet[i][0],gv.controllerCCs)
                if x<0:
                    print("%s: Controller %s not defined, ignoring %s" %(ifile, sheet[i][0], str(sheet[i])))
                    gv.ConfigErr=True
                    continue
                elif len(sheet[i])>1:       # skip empty lines
                    if sheet[i][1]!=gv.UA:  # skip unassigned controls
                        if len(sheet[i])<4:
                            print("%s: ignored %s" %(ifile, str(sheet[i])))
                            gv.ConfigErr=True
                            continue
                        for j in xrange(len(CCmap)):
                            if CCmap[j][0]==x and CCmap[j][3]==voice:
                                print ("%s: Controller '%s' already mapped, ignored %s" %(ifile,gv.controllerCCs[x][0],sheet[i]))
                                gv.ConfigErr=True
                                continue
                        if gv.getindex(sheet[i][3].lower(),["continuous","toggle","switch","switchon","switchoff"],True)<0:
                            print("%s: Mode '%s' unrecognized, ignored: %s" %(ifile, sheet[i][3], str(sheet[i])))
                            gv.ConfigErr=True
                        elif (sheet[i][3].lower()!="continuous" and gv.controllerCCs[x][2]==-1 or sheet[i][3].lower()=="continuous" and gv.controllerCCs[x][2]!=-1):
                            print("%s: Continuous/switch controller mapped to incompatible function, ignored: %s" %(ifile, str(sheet[i])))
                            gv.ConfigErr=True
                        else:
                            values[0]=x     # identify controller
                            # Normalize/correct the input
                            if sheet[i][1].upper()==gv.FIXED.upper():
                                mc=sheet[i][2]
                            else:
                                mc=sheet[i][1]
                                values[2]=sheet[i][2]
                            y=gv.getindex(mc,gv.MC)
                            if y>-1:
                                values[1]=y
                                CCmap.append(values)
                            else:
                                print("%s: Control '%s' unrecognized, ignored %s" %(ifile, mc, str(sheet[i])))
                                gv.ConfigErr=True
    except:
        if not override:
            print "%s: No default controller mapping found" %(ifile)
    return CCmap
예제 #2
0
def notes_sav(
        val=None):  # boolean, but as read variable it's always 0=no/false
    global newnotemap, nm_map
    if val != None:
        if gv.parseBoolean(
                val
        ) and nm_map != "":  # do we want to save a map and do we know the name to save it ?
            newnotemap = []
            changes_added = False
            j = 0
            for i in range(len(gv.notemap)):
                if gv.notemap[i][0] != nm_map:
                    newnotemap.append(gv.notemap[i])
                else:
                    if not changes_added:  # insert all existing/changed/new values at once
                        notes_newmaplines()
                        changes_added = True
            if not changes_added:
                notes_newmaplines()
                gv.currnotemap = nm_map
            gv.notemap = newnotemap
            gv.notemaps = []
            for m in gv.notemap:
                if m[0] not in gv.notemaps:
                    gv.notemaps.append(m[0])
            if nm_map not in gv.notemaps:
                nm_map = ""
            if gv.rootprefix == "":
                subprocess.call(['mount', '-vo', 'remount,rw', gv.samplesdir])
            else:
                print "Not running dedicated, so no remount as we're most likely already R/W"
            fname = gv.samplesdir + gv.presetlist[gv.getindex(
                gv.PRESET, gv.presetlist)][1] + "/" + gv.NOTEMAP_DEF
            with open(fname, 'w') as mapfile:
                mapfile.write(
                    "Set,Fractions,Key,Note,Retune,Playvoice,unote\n")
                for i in range(len(newnotemap)):
                    note = gv.midinote2notename(newnotemap[i][3],
                                                newnotemap[i][1])
                    key = newnotemap[i][2]
                    j = gv.getindex("%d" % key, gv.keynames)
                    if j > 0: key = gv.keynames[j][1]
                    mapfile.write(
                        '%s,%s,%s,%s,%s,%s,%s\n' %
                        (newnotemap[i][0], newnotemap[i][1], key, note,
                         newnotemap[i][4], newnotemap[i][5], newnotemap[i][6]))
            if gv.rootprefix == "":
                subprocess.call(['mount', '-vo', 'remount,ro', gv.samplesdir])
    return 0
예제 #3
0
파일: UI.py 프로젝트: bldrvnlw/SamplerBox
def xvoice(*z):  # Does the effects voice (voice=0) exist ?
    try:
        if gv.getindex(0, gv.voicelist) > -1:
            return True
    except:
        pass
    return False
예제 #4
0
파일: UI.py 프로젝트: bldrvnlw/SamplerBox
def ARPord(val=None):  # value in ARPordlist
    try:
        if val != None:
            if isinstance(val, int): arp.ordnum(val)
            else: arp.ordnum(gv.getindex(val, arp.modes, True))
        return arp.mode
    except:
        return 0
예제 #5
0
파일: UI.py 프로젝트: bldrvnlw/SamplerBox
def PLtype(val=None):  # value in PLtypes
    try:
        if val != None:
            if isinstance(val, int): Cpp.PLsetType(val)
            else: Cpp.PLsetType(gv.getindex(val, Cpp.PLtypes, True))
        return Cpp.PLtype
    except:
        return 0
예제 #6
0
파일: UI.py 프로젝트: bldrvnlw/SamplerBox
def LFOtype(val=None):  # value in LFOtypes
    try:
        if val != None:
            if isinstance(val, int): LFO.setType(val)
            else: LFO.setType(gv.getindex(val, LFO.effects, True))
        return LFO.effect
    except:
        return 0
예제 #7
0
파일: UI.py 프로젝트: bldrvnlw/SamplerBox
def CHOrus(val=None):  # value in CHOtypes
    try:
        if val != None:
            if isinstance(val, int): chorus.setType(val)
            else: chorus.setType(gv.getindex(val, chorus.effects, True))
        return chorus.effect
    except:
        return 0
예제 #8
0
def IP(val=None):
	global IPaddress
	try:
		IPs=IPlist()
		if len(IPs)==0:
			IPaddress="Not connected"
		elif val==None:
			if IPaddress in IPs:
				val=gv.getindex(IPaddress,IPs,True)
				if val<0:val=0
			else: val=0
		elif not isinstance(val,int):
			val=gv.getindex(val,IPs,True)
			if val<0: val=0
		elif val>=len(IPs) or val<0: val=0
		IPaddress=IPs[val]
		return IPaddress
	except: return "?.?.?.?"
예제 #9
0
파일: UI.py 프로젝트: bldrvnlw/SamplerBox
def MIDIdev(val=None):  # Pseudo update to serve the button menu system
    global mididev
    try:
        devs = MIDIdevs()
        if len(devs) == 0:
            mididev = "None"
        elif val == None:
            val = gv.getindex(mididev, devs, True)
            if val < 0: val = 0
        elif not isinstance(val, int):
            val = gv.getindex(val, mididevs, True)
            if val < 0: val = 0
        elif val >= len(mididevs) or val < 0:
            val = 0
        mididev = mididevs[val]
        return mididev
    except:
        return "Error"
예제 #10
0
파일: UI.py 프로젝트: bldrvnlw/SamplerBox
def Button(val=None):
    try:
        if val != None:
            if isinstance(val, int): but = int(val)
            else: but = gv.getindex(val, butmenu.buttons, True)
            if but > -1:
                butmenu.nav(but, 4)
                return True
        return False
    except:
        return False
예제 #11
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
예제 #12
0
def ODreset(scope=-1):
    ODtype = 0  # -1 turns of the effect, undefined values cover midi controller turn off
    if scope in [-2, -3, -4]:  # also reset values
        ODtype = gv.getindex(gv.cp.get(gv.cfg, "Overdrive".lower()), ODtypes,
                             True, False)
        if ODtype < 0:
            ODtype = 0
        #if scope == -3:         # load sample set default
        #    load sample set default
        #else:                   # system default
        ODsetBoost((gv.cp.getfloat(gv.cfg, "ODboost".lower()) - 15) / 50 * 127)
        ODsetDrive((gv.cp.getfloat(gv.cfg, "ODdrive".lower()) - 1) / 10 * 127)
        ODsetTone((gv.cp.getfloat(gv.cfg, "ODtone".lower())) * 1.27)
        ODsetMix(gv.cp.getfloat(gv.cfg, "ODlvl".lower()) * 127)
    ODsetType(ODtype)
예제 #13
0
def FVreset(scope=-1):
    FVtype = 0  # -1 turns of the effect, undefined values cover midi controller turn off
    if scope in [-2, -3, -4]:  # also reset values
        FVtype = gv.getindex(gv.cp.get(gv.cfg, "Reverb".lower()), FVtypes,
                             True, False)
        if FVtype < 0:
            FVtype = 0
        #if scope == -3:         # load sample set default
        #    load sample set default
        #else:                   # system default
        FVsetroomsize(gv.cp.getfloat(gv.cfg, "FVroomsize".lower()) * 127)
        FVsetdamp(gv.cp.getfloat(gv.cfg, "FVdamp".lower()) * 127)
        FVsetlevel(gv.cp.getfloat(gv.cfg, "FVlevel".lower()) * 127)
        FVsetwidth(gv.cp.getfloat(gv.cfg, "FVwidth".lower()) * 127)
    FVsetType(FVtype)
예제 #14
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 **"
예제 #15
0
def readcontrollerCCs(ifile):
    # controllerCCs: [wheel/button/pot/drawbarname, controller, data LSB (-1 if continuous controller)]
    sheet=readcsv(ifile,1)
    gv.controllerCCs=[[gv.UA,-1,-1]]  # define controller for unassigned controls
    for i in range(len(sheet)):
        if len(sheet[i])>2:     # skip useless lines
            if gv.getindex(sheet[i][0],gv.controllerCCs)>-1:
                print ("%s: Controller %s already defined, ignored %s" %(ifile,sheet[i][0],sheet[i]))
            else:
                values=[]
                for j in range(3):
                    values.append(sheet[i][j])
                gv.controllerCCs.append(values)
        else:
            print ("%s: ignored %s" %(ifile, sheet[i]))
            gv.ConfigErr=True
    return 
예제 #16
0
def PLreset(scope=-1):
    c_filters.plinit()
    PLtype = 0  # -1 turns of the effect, undefined values cover midi controller turn off
    if scope in [-2, -3, -4]:  # also reset values
        PLtype = gv.getindex(gv.cp.get(gv.cfg, "Limiter".lower()), PLtypes,
                             True, False)
        if PLtype < 0:
            PLtype = 0
        #if scope == -3:         # load sample set default
        #    load sample set default
        #else:                   # system default
        PLsetThresh(
            (gv.cp.getfloat(gv.cfg, "PLthresh".lower()) - 70) / 40 * 127)
        PLsetAttack(
            (gv.cp.getfloat(gv.cfg, "PLattack".lower()) - 1) / 10 * 127)
        PLsetRelease(
            (gv.cp.getfloat(gv.cfg, "PLrelease".lower()) - 5) / 20 * 127)
    PLsetType(PLtype)
예제 #17
0
def LFreset(scope=-1):
    LFtype = 0
    # -1 turns of the effect, undefined values cover midi controller turn off
    if scope in [-2, -3, -4]:  # also reset values
        LFtype = gv.getindex(gv.cp.get(gv.cfg, "Moog".lower()), LFtypes, True,
                             False)
        if LFtype < 0:
            LFtype = 0
        #if scope == -3:         # load sample set default
        #    load sample set default
        #else:                   # system default
        LFsetResonance(
            (gv.cp.getfloat(gv.cfg, "LFresonance".lower()) / 3.8) * 127)
        LFsetCutoff(
            (gv.cp.getfloat(gv.cfg, "LFcutoff".lower()) - 1000) / 10000 * 127)
        LFsetDrive((gv.cp.getfloat(gv.cfg, "LFdrive".lower()) - 1) / 20 * 127)
        LFsetLvl(gv.cp.getfloat(gv.cfg, "LFlvl".lower()) * 127)
        LFsetGain((gv.cp.getfloat(gv.cfg, "LFgain".lower()) - 1) / 10 * 127)
    LFsetType(LFtype)
예제 #18
0
def readkeynames(ifile):
    # keynames: [name of key/string/pad, midinote sent by this trigger]
    global keynames
    gv.keynames=[["-1","None"]]
    keynames=[]
    gv.drumpadmap=[]
    gv.drumpad=False
    try:        # giving keys/strings/triggers a name is optional
        sheet=readcsv(ifile)
        for i in range(len(sheet)):
            values=[]
            valucas=[]
            valuesDP=[]
            valuesCC=[]
            if len(sheet[i])>1:     # skip useless lines
                if gv.getindex(sheet[i][0],gv.keynames)>-1:
                    print ("%s: Key %s already defined, ignored %s" %(ifile,sheet[i][0],sheet[i]))
                else:
                    try:
                        values.append(sheet[i][1])
                        values.append(sheet[i][0])
                        gv.keynames.append(values)
                        valucas.append(sheet[i][0].upper())
                        valucas.append(sheet[i][1])
                        keynames.append(valucas)
                        valuesCC.append(sheet[i][0])
                        valuesCC.append(gv.NOTES_CC)
                        valuesCC.append(int(sheet[i][1]))
                        gv.controllerCCs.append(valuesCC)
                        if len(sheet[i])>2: # drumpad remap definition
                            valuesDP.append(int(sheet[i][2]))
                            valuesDP.append(int(sheet[i][1]))
                            gv.drumpadmap.append(valuesDP)
                    except:
                        print ("%s: %s contains errors, partly processed" %(ifile, sheet[i]))
            else:
                print ("%s: ignored %s" %(ifile, sheet[i]))
                gv.ConfigErr=True
        if len(gv.drumpadmap)>0: gv.drumpad=True
    except:
        pass    # giving keys/strings/triggers a name is optional
    return 
예제 #19
0
def reset(scope=-1):
    global VIBRpitch, VIBRspeed, VIBRtrill, TREMampl, BOXTREMspeed, TREMspeed, TREMtrill, PANwidth, PANspeed
    effect = 0
    if scope in [-2, -4]:  # also reset values
        effect = gv.getindex(gv.cp.get(gv.cfg, "LFOeffect".lower()), effects,
                             True, False)
        if effect < 0:
            effect = 0
        #if scope == -2:         # load sample set default
        #    load sample set default
        #else:                   # system default
        VIBRpitch = gv.cp.getfloat(gv.cfg, "VIBRpitch".lower())
        VIBRspeed = gv.cp.getint(gv.cfg, "VIBRspeed".lower())
        VIBRtrill = gv.cp.getboolean(gv.cfg, "VIBRtrill".lower())
        TREMampl = gv.cp.getfloat(gv.cfg, "TREMampl".lower())
        BOXTREMspeed = gv.cp.getint(gv.cfg, "TREMspeed".lower())
        TREMspeed = BOXTREMspeed
        TREMtrill = gv.cp.getboolean(gv.cfg, "TREMtrill".lower())
        PANwidth = gv.cp.getfloat(gv.cfg, "PANwidth".lower())
        PANspeed = gv.cp.getint(gv.cfg, "PANspeed".lower())
    setType(effect)
예제 #20
0
def readkeynames(ifile):
    # keynames: [name of key/string/pad, midinote sent by this trigger]
    gv.keynames = []
    try:  # giving keys/strings/triggers a name is optional
        sheet = readcsv(ifile)
        for i in range(len(sheet)):
            values = []
            if len(sheet[i]) > 1:  # skip useless lines
                if gv.getindex(sheet[0], gv.keynames) != -1:
                    print("%s: Key %s already defined, ignored %s" %
                          (ifile, sheet[0], sheet[i]))
                else:
                    values.append(sheet[i][0])
                    values.append(sheet[i][1])
            else:
                print("%s: ignored %s" % (ifile, sheet[i]))
                gv.ConfigErr = True
            gv.keynames.append(values)
    except:
        pass  # giving keys/strings/triggers a name is optional
    return
예제 #21
0
def notes_sync():
	global actnotemap,nm_inote,nm_onote,nm_unote,nm_Q,nm_retune,nm_voice,nm_map
	if actnotemap!=gv.currnotemap:
		actnotemap=gv.currnotemap
		nm_map=actnotemap
	nm_onote=-1
	if len(gv.notemapping)>0:	nm_Q=gv.notemapping[0][1]
	else:						nm_Q=1
	nm_retune=0
	nm_voice=0
	nm_unote=2
	if nm_inote>-1:
		i=gv.getindex(nm_inote,gv.notemapping)
		if i>-1:
			nm_Q=gv.notemapping[i][1]
			nm_onote=gv.notemapping[i][2]
			nm_retune=gv.notemapping[i][3]
			nm_voice=gv.notemapping[i][4]
			nm_unote=gv.notemapping[i][5]
		else:
			nm_onote=nm_inote
예제 #22
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 **"
예제 #23
0
def AWreset(scope=-1):
    AWtype = 0  # -1 turns of the effect, undefined values cover midi controller turn off
    if scope in [-2, -3, -4]:  # also reset values
        AWtype = gv.getindex(gv.cp.get(gv.cfg, "Wah".lower()), AWtypes, True,
                             False)
        if AWtype < 0:
            AWtype = 0
        #if scope == -3:         # load sample set default
        #    load sample set default
        #else:                   # system default
        AWsetQualityFactor(
            gv.cp.getfloat(gv.cfg, "AWqfactor".lower()) / 25 * 127)
        AWsetMixing(gv.cp.getfloat(gv.cfg, "AWmixing".lower()) * 127)
        AWsetMinFreq(gv.cp.getfloat(gv.cfg, "AWminfreq".lower()) / 500 * 127)
        AWsetMaxFreq(gv.cp.getfloat(gv.cfg, "AWmaxfreq".lower()) / 10000 * 127)
        AWsetAttack(gv.cp.getfloat(gv.cfg, "AWattack".lower()) / 0.5 * 127)
        AWsetRelease(gv.cp.getfloat(gv.cfg, "AWrelease".lower()) / 0.05 * 127)
        AWsetSpeed(
            (gv.cp.getfloat(gv.cfg, "AWspeed".lower()) - 100) / 1000 * 127)
        AWsetLVLrange(gv.cp.getfloat(gv.cfg, "AWlvlrange".lower()) / 100 * 127)
    AWsetType(AWtype)
    AWsetCCval(0)  # pedal always back to base
예제 #24
0
def DLYreset(scope=-1):
    DLYtype = 0  # -1 turns of the effect, undefined values cover midi controller turn off
    if scope in [-2, -3, -4]:  # also reset values
        DLYtype = gv.getindex(gv.cp.get(gv.cfg, "Delay".lower()), DLYtypes,
                              True, False)
        if DLYtype < 0:
            DLYtype = 0
        #if scope == -3:         # load sample set default
        #    load sample set default
        #else:                   # system default
        DLYsetfb(gv.cp.getfloat(gv.cfg, "DLYfb".lower()) * 127)
        DLYsetwet(gv.cp.getfloat(gv.cfg, "DLYwet".lower()) * 127)
        DLYsetdry(gv.cp.getfloat(gv.cfg, "DLYdry".lower()) * 127)
        DLYsettime(
            (gv.cp.getfloat(gv.cfg, "DLYtime".lower()) - 1000) / 60000 * 127)
        DLYsetsteep(
            (gv.cp.getfloat(gv.cfg, "DLYsteep".lower()) - 1) / 10 * 127)
        DLYsetsteplen(
            (gv.cp.getfloat(gv.cfg, "DLYsteplen".lower()) - 300) / 3000 * 127)
        DLYsetmin((gv.cp.getfloat(gv.cfg, "DLYmin".lower()) - 5) / 20 * 127)
        DLYsetmax((gv.cp.getfloat(gv.cfg, "DLYmax".lower()) - 50) / 100 * 127)
    DLYsetType(DLYtype)
예제 #25
0
def readnotemap(ifile):
    # notemap: [set, fractions, key, note, retune, playvoice]
    gv.notemap = []
    try:  # note mapping is optional
        sheet = readcsv(ifile, 4)
        for i in range(len(sheet)):
            if len(sheet[i]) > 3:  # skip useless lines
                values = ["", 0, 0, 0, 0, 0]
                values[0] = format(sheet[i][0]).title(
                )  # force num to string and normalize upper/lowercase usage
                if values[0] == "":
                    print("%s: Sets must have a name, ignored %s" %
                          (ifile, sheet[i]))
                    continue
                try:
                    values[1] = int(sheet[i][1])
                    if values[1] < 1 or values[1] > 2:
                        print("%s: invalid fractions, ignored %s" %
                              (ifile, sheet[i]))
                except:
                    print("%s: invalid fractions, ignored %s" %
                          (ifile, sheet[i]))
                    continue
                try:
                    values[2] = int(sheet[i][2])
                except:
                    x = gv.getindex(sheet[i][2], gv.keynames)
                    if x < 0:
                        print("%s: keyname '%s' not defined, ignored %s" %
                              (ifile, sheet[i][2], sheet[i]))
                        continue
                    else:
                        values[2] = int(gv.keynames[x][1])
                try:
                    values[3] = int(sheet[i][3])
                    if values[3] < 0 or values[5] > 127:
                        print("%s: invalid notenumber, ignored %s" %
                              (ifile, sheet[i]))
                except:
                    midinote = gv.notename2midinote(sheet[i][3], sheet[i][1])
                    if midinote > -1:
                        values[3] = midinote
                    else:
                        print("%s: invalid notename '%s', ignored %s" %
                              (ifile, sheet[i][2], sheet[i]))
                        continue
                if len(sheet[i]) > 4:  # the values are optional
                    try:
                        values[4] = int(sheet[i][4])
                        values[5] = int(sheet[i][5])
                    except:
                        pass
                gv.notemap.append(values)
                if gv.getindex(values[0], gv.notemaps, True) < 0:
                    gv.notemaps.append(values[0])
            else:
                print("%s: ignored %s" % (ifile, sheet[i]))
                gv.ConfigErr = True
    except:
        pass  # notemapping is optional
    return
예제 #26
0
def setType(x, *z):
    if x > 0:
        gv.CHOrus = True
    else:
        gv.CHOrus = False


def toggle(*z):
    gv.CHOrus != gv.CHOrus


def setdepth(x, *z):  # 2-15
    gv.CHOdepth = 2 + 13 * x / 127


def setgain(x, *z):  # 0.3-0.8
    gv.CHOgain = 0.3 + 0.5 * x / 127.0


def reset():
    gv.CHOrus = False
    gv.CHOdepth = gv.cp.getfloat(gv.cfg, "CHOdepth".lower())
    gv.CHOgain = gv.cp.getfloat(gv.cfg, "CHOgain".lower())


reset()
gv.MC[gv.getindex(gv.CHORUS, gv.MC)][2] = toggle
gv.MC[gv.getindex(gv.CHORUSDEPTH, gv.MC)][2] = setdepth
gv.MC[gv.getindex(gv.CHORUSGAIN, gv.MC)][2] = setgain
예제 #27
0
파일: LFO.py 프로젝트: beavis07/SamplerBox
        VibrLFO.settriangle(63)  # start about neutral, going up
        VibrLFO.setstep(gv.VIBRspeed)  # and with correct speed
    else:
        gv.VIBRvalue = 0  # tune the note


def VibrSetpitch(CCval, *z):
    gv.VIBRpitch = 1.0 * CCval / 32  # steps of 1/32th, range like GUI


def VibrSetspeed(CCval, *z):
    gv.VIBRspeed = 1.0 * CCval / 4  # range=32
    VibrLFO.setstep(gv.VIBRspeed)


gv.MC[gv.getindex(gv.VIBRDEPTH, gv.MC)][2] = VibrSetpitch
gv.MC[gv.getindex(gv.VIBRSPEED, gv.MC)][2] = VibrSetspeed
#gv.VibrSetspeed=VibrSetspeed

TremLFO = plfo()
gv.TREMvalue = 1.0  # Full volume


def TremProc(*z):
    if gv.LFOtype == 4:
        TremLFO.setstep(gv.VIBRspeed)
    TremLFO.process()
    if gv.TREMtrill:
        gv.TREMvalue = 1 - (gv.TREMampl * TremLFO.getinvsaw() / 127)
    else:
        gv.TREMvalue = 1 - (gv.TREMampl * TremLFO.gettriangle() / 127)
예제 #28
0
                    gv.triggernotes[note] = 128
        rewind()  # initialize before start
        active = True  # and start...
    if not onoff and active:
        active = False  # stop first
        rewind()  # initialize completely for safety...


def togglepower(CCval, *z):
    if currnote < 0:
        power(True)
    else:
        power(False)


gv.MC[gv.getindex(gv.ARP, gv.MC)][2] = togglepower


def noteoff():
    global playnote
    if playnote > -1:
        if playnote in gv.playingnotes:
            for m in gv.playingnotes[playnote]:
                m.fadeout(
                    not (cycleoff
                         == cyclestep))  # damp when notes are consecutive
            gv.playingnotes[playnote] = []
        playnote = -1


def rewind():
예제 #29
0
    def do_POST(self):
        inval = 0

        length = int(self.headers.getheader('content-length'))
        field_data = self.rfile.read(length)
        fields = parse_qs(field_data)
        #print fields
        if "SB_RenewMedia" in fields:
            if fields["SB_RenewMedia"][0] == "Yes":
                gv.basename = "None"
                self.LoadSamples()
                return
        if "SB_Preset" in fields:
            inval = gv.presetlist[int(fields["SB_Preset"][0])][0]
            if gv.PRESET != inval:
                gv.PRESET = inval
                self.LoadSamples()
                return
        if "SB_DefinitionTxt" in fields:
            if gv.DefinitionTxt != fields["SB_DefinitionTxt"][0]:
                gv.DefinitionTxt = fields["SB_DefinitionTxt"][0]
                #print gv.DefinitionTxt
                subprocess.call(['mount', '-vo', 'remount,rw', gv.samplesdir])
                fname = gv.samplesdir + gv.presetlist[gv.getindex(
                    gv.PRESET, gv.presetlist)][1] + "/" + gv.SAMPLESDEF
                with open(fname, 'w') as definitionfile:
                    definitionfile.write(gv.DefinitionTxt)
                subprocess.call(['mount', '-vo', 'remount,ro', gv.samplesdir])
                gv.basename = "None"  # do a renew to sync the update
                self.LoadSamples()
                return
        if "SB_MidiChannel" in fields:
            gv.MIDI_CHANNEL = int(fields["SB_MidiChannel"][0])
        if "SB_SoundVolume" in fields:
            gv.setvolume(int(fields["SB_SoundVolume"][0]))
        if "SB_MidiVolume" in fields:
            gv.volumeCC = float(fields["SB_MidiVolume"][0]) / 100
        if "SB_Gain" in fields:
            gv.globalgain = float(fields["SB_Gain"][0]) / 100
        if "SB_Pitchrange" in fields:
            gv.pitchnotes = int(fields["SB_Pitchrange"][0]) * 2
        if "SB_Voice" in fields:
            if gv.voicelist[0][0] == 0: i = 1
            else: i = 0
            gv.MC[gv.getindex(gv.VOICES,
                              gv.MC)][2](int(fields["SB_Voice"][0]) + i, 0)
        if "SB_Notemap" in fields:
            gv.MC[gv.getindex(gv.NOTEMAPS,
                              gv.MC)][2](int(fields["SB_Notemap"][0]))
        if "SB_Scale" in fields:
            inval = int(fields["SB_Scale"][0])
            if gv.currscale == inval: scalechange = False
            else:
                scalechange = True
                gv.currscale = inval
                if gv.last_musicnote < 0: gv.currchord = 0
                else:
                    gv.currchord = gv.scalechord[gv.currscale][
                        gv.last_musicnote]
        if "SB_Chord" in fields and not scalechange:
            inval = int(fields["SB_Chord"][0])
            if not gv.currchord == inval:
                gv.currchord = inval
                gv.currscale = 0
        if "SB_CHOrus" in fields:
            CHOrus.setType(
                gv.getindex(fields["SB_CHOrus"][0], ["Off", "On"], True))
        if "SB_CHOdepth" in fields:
            CHOrus.setdepth((float(fields["SB_CHOdepth"][0]) - 2) * 9.77)
        if "SB_CHOgain" in fields:
            CHOrus.setgain((float(fields["SB_CHOgain"][0]) - 30) * 2.54)
        if "SB_FVtype" in fields:
            Cpp.FVsetType(
                gv.getindex(fields["SB_FVtype"][0], ["Off", "On"], True))
        if "SB_FVroomsize" in fields:
            Cpp.FVsetroomsize(float(fields["SB_FVroomsize"][0]) * 1.27)
        if "SB_FVdamp" in fields:
            Cpp.FVsetdamp(float(fields["SB_FVdamp"][0]) * 1.27)
        if "SB_FVlevel" in fields:
            Cpp.FVsetlevel(float(fields["SB_FVlevel"][0]) * 1.27)
        if "SB_FVwidth" in fields:
            Cpp.FVsetwidth(float(fields["SB_FVwidth"][0]) * 1.27)
        if "SB_AWtype" in fields:
            Cpp.AWsetType(gv.getindex(fields["SB_AWtype"][0], gv.AWtypes,
                                      True))
        if "SB_AWmixing" in fields:
            Cpp.AWsetMixing(float(fields["SB_AWmixing"][0]) * 1.27)
        if "SB_AWattack" in fields:
            Cpp.AWsetAttack(float(fields["SB_AWattack"][0]) * 0.254)
        if "SB_AWrelease" in fields:
            Cpp.AWsetRelease(float(fields["SB_AWrelease"][0]) * 0.254)
        if "SB_AWminfreq" in fields:
            Cpp.AWsetMinFreq(float(fields["SB_AWminfreq"][0]) * 0.254)
        if "SB_AWmaxfreq" in fields:
            Cpp.AWsetMaxFreq(float(fields["SB_AWmaxfreq"][0]) * 0.0127)
        if "SB_AWqfactor" in fields:
            Cpp.AWsetQualityFactor(float(fields["SB_AWqfactor"][0]) * 0.0508)
        if "SB_AWspeed" in fields:
            Cpp.AWsetSpeed((float(fields["SB_AWspeed"][0]) - 100) * 0.127)
        if "SB_AWlvlrange" in fields:
            Cpp.AWsetLVLrange(float(fields["SB_AWlvlrange"][0]) * 1.27)
        if "SB_DLYtype" in fields:
            Cpp.DLYsetType(
                gv.getindex(fields["SB_DLYtype"][0], gv.DLYtypes, True))
        if "SB_DLYfb" in fields:
            Cpp.DLYsetfb(float(fields["SB_DLYfb"][0]) * 1.27)
        if "SB_DLYwet" in fields:
            Cpp.DLYsetwet(float(fields["SB_DLYwet"][0]) * 1.27)
        if "SB_DLYdry" in fields:
            Cpp.DLYsetdry(float(fields["SB_DLYdry"][0]) * 1.27)
        if "SB_DLYtime" in fields:
            Cpp.DLYsettime(
                (float(fields["SB_DLYtime"][0]) - 1000) / 600 * 1.27)
        if "SB_DLYsteep" in fields:
            Cpp.DLYsetsteep((float(fields["SB_DLYsteep"][0]) - 1) * 12.7)
        if "SB_DLYsteplen" in fields:
            Cpp.DLYsetsteplen(
                (float(fields["SB_DLYsteplen"][0]) - 300) / 30 * 1.27)
        if "SB_DLYmin" in fields:
            Cpp.DLYsetmin((float(fields["SB_DLYmin"][0]) - 5) * 5.36)
        if "SB_DLYmax" in fields:
            Cpp.DLYsetmax((float(fields["SB_DLYmax"][0]) - 50) * 1.27)
        if "SB_LFtype" in fields:
            Cpp.LFsetType(
                gv.getindex(fields["SB_LFtype"][0], ["Off", "On"], True))
        if "SB_LFresonance" in fields:
            Cpp.LFsetResonance(float(fields["SB_LFresonance"][0]) / 38 * 127)
        if "SB_LFcutoff" in fields:
            Cpp.LFsetCutoff(
                (float(fields["SB_LFcutoff"][0]) - 1000) / 100 * 1.27)
        if "SB_LFdrive" in fields:
            Cpp.LFsetDrive(
                (float(fields["SB_LFdrive"][0]) - 1) * 6.35)  # =/20.0*127)
        if "SB_LFlvl" in fields:
            Cpp.LFsetLvl((float(fields["SB_LFlvl"][0])) * 1.27)
        if "SB_LFgain" in fields:
            Cpp.LFsetGain((float(fields["SB_LFgain"][0]) - 10) * 1.27)
        if "SB_LFOtype" in fields:
            LFO.setType(gv.getindex(fields["SB_LFOtype"][0], gv.LFOtypes,
                                    True))
        if "SB_VIBRpitch" in fields:
            gv.VIBRpitch = float(fields["SB_VIBRpitch"][0]) / 16
        if "SB_VIBRspeed" in fields:
            LFO.VibrSetspeed(int(fields["SB_VIBRspeed"][0]) * 4)
        if "SB_VIBRtrill" in fields:
            if fields["SB_VIBRtrill"][0].title() == "On": gv.VIBRtrill = True
            else: gv.VIBRtrill = False
        if "SB_TREMampl" in fields:
            gv.TREMampl = float(fields["SB_TREMampl"][0]) / 100
        if "SB_TREMspeed" in fields:
            LFO.TremSetspeed(int(fields["SB_TREMspeed"][0]) * 4)
        if "SB_TREMtrill" in fields:
            if fields["SB_TREMtrill"][0].title() == "On": gv.TREMtrill = True
            else: gv.TREMtrill = False
        if "SB_PANwidth" in fields:
            gv.PANwidth = float(fields["SB_PANwidth"][0]) / 20
        if "SB_PANspeed" in fields:
            LFO.PanSetspeed(int(fields["SB_PANspeed"][0]) * 4)
        if "SB_ARPord" in fields:
            arp.ordnum(gv.getindex(fields["SB_ARPord"][0], gv.ARPtypes, True))
        if "SB_ARPstep" in fields:
            arp.tempo(int(fields["SB_ARPstep"][0]) * 1.27)
        if "SB_ARPsustain" in fields:
            arp.sustain(int(fields["SB_ARPsustain"][0]) * 1.27)
        if "SB_ARPloop" in fields:
            if fields["SB_ARPloop"][0].title() == "On": arp.loop = True
            else: arp.loop = False
        if "SB_ARP2end" in fields:
            if fields["SB_ARP2end"][0].title() == "On": arp.play2end = True
            else: arp.play2end = False
        if "SB_ARPfade" in fields:
            arp.fadeout(1.27 * int(fields["SB_ARPfade"][0]))
        gv.display("")  # show it on the box
        self.do_GET()  # as well as on the gui
예제 #30
0
def readnotemap(ifile):
    # notemap: [set, fractions, key, note, retune, playvoice]
    global keynames
    gv.notemap=[]
    gv.notemaps=[]
    try:        # note mapping is optional
        sheet=readcsv(ifile,4)
        for i in range(len(sheet)):
            if len(sheet[i])>3:     # skip useless lines
                values=["",1,0,-1,0,0,0]
                values[0]=format(sheet[i][0]).title()   # force num to string and normalize upper/lowercase usage
                if values[0]=="":
                    print ("%s: Sets must have a name, ignored %s" %(ifile, sheet[i]))
                    continue
                try:
                    values[1]=int(sheet[i][1])
                    if values[1]<1 or values[1]>2:
                        print ("%s: invalid fractions, ignored %s" %(ifile, sheet[i]))
                except:
                    print ("%s: invalid fractions, ignored %s" %(ifile, sheet[i]))
                    continue
                try:
                    values[2]=int(sheet[i][2])
                except:
                    ucas=sheet[i][2].upper()
                    x=gv.getindex(ucas,keynames)
                    if x<0:
                        print ("%s: keyname '%s' not defined, ignored %s" %(ifile, sheet[i][2], sheet[i]))
                        continue
                    else:
                        values[2]=int(gv.keynames[x+1][0])
                if len(gv.notemap)>0:
                    for j in range(len(gv.notemap)):
                        if values[0]==gv.notemap[j][0] and values[2]==gv.notemap[j][2]:
                            print ("%s: duplicate midinote %d in notemap %s, ignored %s" %(ifile, values[2], values[0], sheet[i]))
                            break
                    if j<len(gv.notemap)-1:
                        continue
                try:
                    values[3]=int(sheet[i][3])
                except:
                    if sheet[i][3].title()=="Ctrl":
                        values[3]=-2
                    elif sheet[i][3].title()=="None":
                        values[3]=-1
                    else:
                        midinote=gv.notename2midinote(sheet[i][3],values[1])
                        if midinote>-1:
                            values[3]=midinote
                        else:
                            print ("%s: invalid notename '%s', ignored %s" %(ifile, sheet[i][3], sheet[i]))
                            continue
                if len(sheet[i])>4: # the values are optional
                    try:
                        values[4]=int(sheet[i][4])
                        values[5]=int(sheet[i][5])
                        values[6]=int(sheet[i][6])
                    except:
                        pass
                gv.notemap.append(values)
                if gv.getindex(values[0],gv.notemaps,True)<0:
                    gv.notemaps.append(values[0])
            else:
                print ("%s: ignored %s" %(ifile, sheet[i]))
                gv.ConfigErr=True
        gv.notemap.sort(key=operator.itemgetter(0,2))   # sort on: map->input(midi)key
    except:
        pass    # notemapping is optional
    return