Example #1
0
 def _postMapPs(self, iNo, val):  # alwasy map pitch
     # pitchtools limit will automatically constrain min/max as well
     # this rounds floating point values to integers
     val = pitchTools.psToMidi(val, 'limit')
     # always limit max values
     if val < 0: val = 0
     if val > 127: val = 127
     return val
Example #2
0
 def _postMapPs(self, iNo, val): # alwasy map pitch
     # pitchtools limit will automatically constrain min/max as well
     # this rounds floating point values to integers
     val = pitchTools.psToMidi(val, 'limit')
     # always limit max values
     if val < 0: val = 0
     if val > 127: val = 127
     return val
Example #3
0
def getPercNameFromNoteName(usrStr):
    """get perc name from midi note number
    nameStr can be a string (psName) or number (midiNote number)
    """
    if drawer.isStr(usrStr):
        psInt = pitchTools.psNameToPs(usrStr)
        midiInt = pitchTools.psToMidi(psInt)
    else:
        midiInt = int(usrStr)
    # normalize bad values
    if midiInt < 35: midiInt = 35
    if midiInt > 81: midiInt = 81
    else:
        for name, num in gmPercussionNames.items():
            if num == midiInt:
                percName = name
                break
    return percName
Example #4
0
def getPercNameFromNoteName(usrStr):
    """get perc name from midi note number
    nameStr can be a string (psName) or number (midiNote number)
    """
    if drawer.isStr(usrStr):
        psInt = pitchTools.psNameToPs(usrStr)
        midiInt = pitchTools.psToMidi(psInt)
    else:
        midiInt = int(usrStr)
    # normalize bad values  
    if midiInt < 35: midiInt = 35
    if midiInt > 81: midiInt = 81
    else:
        for name, num in gmPercussionNames.items():
            if num == midiInt:
                percName = name
                break
    return percName
Example #5
0
 def _postMapPs(self, iNo, val):
     val = pitchTools.psToMidi(val, 'noLimit')
     return val