def emit_keymap(samp, keyLo, keyHi): print >> gl.ofile, " SAMP:%s:%d:%d:%d:\t(%3s - %3s)" % ( samp.fname, keyLo, keyHi, samp.mnote, jmidi.mnote_name( keyLo, None), jmidi.mnote_name(keyHi, None)) print >> gl.sfzf print >> gl.sfzf, "<region> sample=%s" % samp.fname print >> gl.sfzf, "lokey=%s" % jmidi.mnote_name(keyLo, None) print >> gl.sfzf, "hikey=%s" % jmidi.mnote_name(keyHi, None) print >> gl.sfzf, "pitch_keycenter=%s" % jmidi.mnote_name(samp.mnote, None)
def showmap(grid, layerdata): # Generate heading showing "piano keyboard" in three lines: # first line is octave number # second line is key name, omitting sharp or flat # third line is "b" for flats and " " for naturals # # Example: # 111111111111222222222222333333333333444444444444... # CDDEEFGGAABBCDDEEFGGAABBCDDEEFGGAABBCDDEEFGGAABB... # b b b b b b b b b b b b b b b b b b b b ... line1 = line2 = line3 = "" for col in range(LO_KEY, HI_KEY+1): notename = jmidi.mnote_name(col, pad=None) line2 += notename[0] if notename[1] == "b": line3 += "b" octave = notename[2] else: line3 += " " octave = notename[1] line1 += octave # print "keyboard" print >>gl.ofile, "#", line1 print >>gl.ofile, "#", line2 print >>gl.ofile, "#", line3 print >>gl.ofile, "#" # print key assignments for row in range(len(layerdata)-1, -1, -1): line = "" for col in range(LO_KEY, HI_KEY+1): samp = gl.grid[row][col] if samp: if samp.layer == row and samp.mnote == col: line += " " else: line += samp.char else: line += "!" print >>gl.ofile, ( "# %s Layer %-6s v=%03d" % (line, layerdata[row][LNAME], layerdata[row][LVEL])) print >>gl.ofile, "#" print >>gl.ofile, "# Key:" print >>gl.ofile, "# space = unity-mapped key" print >>gl.ofile, "# ! = unmapped key" print >>gl.ofile, "# anything else: see sample layer list above"
def showmap(grid, layerdata): # Generate heading showing "piano keyboard" in three lines: # first line is octave number # second line is key name, omitting sharp or flat # third line is "b" for flats and " " for naturals # # Example: # 111111111111222222222222333333333333444444444444... # CDDEEFGGAABBCDDEEFGGAABBCDDEEFGGAABBCDDEEFGGAABB... # b b b b b b b b b b b b b b b b b b b b ... line1 = line2 = line3 = "" for col in range(LO_KEY, HI_KEY + 1): notename = jmidi.mnote_name(col, pad=None) line2 += notename[0] if notename[1] == "b": line3 += "b" octave = notename[2] else: line3 += " " octave = notename[1] line1 += octave # print "keyboard" print >> gl.ofile, "#", line1 print >> gl.ofile, "#", line2 print >> gl.ofile, "#", line3 print >> gl.ofile, "#" # print key assignments for row in range(len(layerdata) - 1, -1, -1): line = "" for col in range(LO_KEY, HI_KEY + 1): samp = gl.grid[row][col] if samp: if samp.layer == row and samp.mnote == col: line += " " else: line += samp.char else: line += "!" print >> gl.ofile, ( "# %s Layer %-6s v=%03d" % (line, layerdata[row][LNAME], layerdata[row][LVEL])) print >> gl.ofile, "#" print >> gl.ofile, "# Key:" print >> gl.ofile, "# space = unity-mapped key" print >> gl.ofile, "# ! = unmapped key" print >> gl.ofile, "# anything else: see sample layer list above"
def emit_keymap(samp, keyLo, keyHi): print >>gl.ofile, " SAMP:%s:%d:%d:%d:\t(%3s - %3s)" % ( samp.fname, keyLo, keyHi, samp.mnote, jmidi.mnote_name(keyLo, None), jmidi.mnote_name(keyHi, None))
def load_filenames(args): global gl warnings = [] errors = [] for arg in args: #{ for sampfname in glob.glob(arg): if True: try: sampf = file(sampfname, "rb") except IOError, msg: errors.append(msg) if sampf: sampf.close() samp = Samp() # strip directory basename = sampfname.replace("\\", "/") basename = sampfname.split("/")[-1] # strip ".wav" extension basename = basename.split(".") basename = ".".join(basename[0:-1]) basename = jtrans.tr(basename, DELIMS, " ") # get layer name parts = basename.split(" ") if len(parts) <= abs(LAYER_LOC): loc = LAYER_LOC if loc >= 0: loc += 1 print >>sys.stderr, ( "After splitting filename '%s' delimiters," % (basename)) print >>sys.stderr, ( "there aren't enough parts to find part number %d." % loc) sys.exit(1) layername = parts[LAYER_LOC] # get note: might be MIDI number or note name if len(parts) <= abs(NOTE_LOC): loc = NOTE_LOC if loc >= 0: loc += 1 print >>sys.stderr, ( "After splitting filename '%s' at delimiters, there aren't" % (basename)) print >>sys.stderr, ( "there aren't enough parts to find part number %d." % loc) sys.exit(1) notespec = parts[NOTE_LOC] mnote = jmidi.notenum(notespec) if mnote == None: print >>sys.stderr, ( "Invalid MIDI note designation '%s' in '%s'" % (notespec, basename)) sys.exit(1) # print sampfname, mnote, layername, jmidi.mnote_name(mnote)[0] samp.fname = sampfname samp.mnote = mnote samp.notename = jmidi.mnote_name(mnote, pad=None) samp.layername = layername if layername not in gl.layernum: warnings.append("Sample for unconfigured layer '%s': %s" % (samp.layername, samp.fname)) continue samp.layer = gl.layernum[layername] if samp.layer == None: warnings.append("Sample for missing layer '%s': %s" % (samp.layername, samp.fname)) continue x = LO_KEY - MAX_NOTE_SHIFT if (samp.mnote < max(0, LO_KEY - MAX_NOTE_SHIFT) or samp.mnote > HI_KEY + MAX_NOTE_SHIFT): warnings.append("Sample outside useful note range (%s): %s" % (samp.notename, samp.fname)) continue samp.char = None gl.samps[sampfname] = samp gl.grid[samp.layer][mnote] = samp
def emit_keymap(samp, keyLo, keyHi): print >> gl.ofile, " SAMP:%s:%d:%d:%d:\t(%3s - %3s)" % ( samp.fname, keyLo, keyHi, samp.mnote, jmidi.mnote_name( keyLo, None), jmidi.mnote_name(keyHi, None))
def load_filenames(args): global gl warnings = [] errors = [] for arg in args: #{ for sampfname in glob.glob(arg): if True: try: sampf = file(sampfname, "rb") except IOError, msg: errors.append(msg) if sampf: sampf.close() samp = Samp() # strip directory basename = sampfname.replace("\\", "/") basename = sampfname.split("/")[-1] # strip ".wav" extension basename = basename.split(".") basename = ".".join(basename[0:-1]) basename = jtrans.tr(basename, DELIMS, " ") # get layer name parts = basename.split(" ") if len(parts) <= abs(LAYER_LOC): loc = LAYER_LOC if loc >= 0: loc += 1 print >> sys.stderr, ( "After splitting filename '%s' delimiters," % (basename)) print >> sys.stderr, ( "there aren't enough parts to find part number %d." % loc) sys.exit(1) layername = parts[LAYER_LOC] # get note: might be MIDI number or note name if len(parts) <= abs(NOTE_LOC): loc = NOTE_LOC if loc >= 0: loc += 1 print >> sys.stderr, ( "After splitting filename '%s' at delimiters, there aren't" % (basename)) print >> sys.stderr, ( "there aren't enough parts to find part number %d." % loc) sys.exit(1) notespec = parts[NOTE_LOC] mnote = jmidi.notenum(notespec) if mnote == None: print >> sys.stderr, ( "Invalid MIDI note designation '%s' in '%s'" % (notespec, basename)) sys.exit(1) # print sampfname, mnote, layername, jmidi.mnote_name(mnote)[0] samp.fname = sampfname samp.mnote = mnote samp.notename = jmidi.mnote_name(mnote, pad=None) samp.layername = layername if layername not in gl.layernum: warnings.append("Sample for unconfigured layer '%s': %s" % (samp.layername, samp.fname)) continue samp.layer = gl.layernum[layername] if samp.layer == None: warnings.append("Sample for missing layer '%s': %s" % (samp.layername, samp.fname)) continue x = LO_KEY - MAX_NOTE_SHIFT if (samp.mnote < max(0, LO_KEY - MAX_NOTE_SHIFT) or samp.mnote > HI_KEY + MAX_NOTE_SHIFT): warnings.append("Sample outside useful note range (%s): %s" % (samp.notename, samp.fname)) continue samp.char = None gl.samps[sampfname] = samp gl.grid[samp.layer][mnote] = samp