Advertisement
Redxone

[Python][KeyNoter] - Key To Note Converter

Oct 27th, 2015
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.31 KB | None | 0 0
  1. #########################################
  2. #   Created By Lewisk3 /  Redxone   #
  3. #########################################
  4.  
  5. # Doesnt do numbers yet :/
  6. # Python Virtual Piano To Real Notes Converter!
  7. matrix = {
  8.     'q':'F 1',
  9.     'w':'G 2',
  10.     'e':'A 2',
  11.     'r':'B 2',
  12.     't':'C 2',
  13.     'y':'D 2',
  14.     'u':'E 2',
  15.     'i':'F 3',
  16.     'o':'G 3',
  17.     'p':'A 3',
  18.     'a':'B 3',
  19.     's':'C 3',
  20.     'd':'D 3',
  21.     'f':'E 4',
  22.     'g':'F 4',
  23.     'h':'G 4',
  24.     'j':'A 4',
  25.     'k':'B 4',
  26.     'l':'C 4',
  27.     'z':'D 5',
  28.     'x':'E 5',
  29.     'c':'F 5',
  30.     'v':'G 5',
  31.     'b':'A 5',
  32.     'n':'B 5',
  33.     'm':'C 5'
  34. }
  35.  
  36. f = input("File with virtual piano notes inside it: ")
  37. o = input('Output as: ')
  38. rf = open(f, 'r')
  39. vpkeys = rf.read()
  40. rf.close()
  41. realkeys = vpkeys.split()
  42. transkeys = ""
  43.  
  44.  
  45. for key in realkeys:
  46.     transkeys += key
  47.    
  48. wo = open(o, 'w')
  49. for char in transkeys:
  50.     maketowrite = str(matrix[str(char).lower()])
  51.     if(str(char).istitle()):
  52.         rch = (maketowrite.upper()).split()[0]
  53.         if rch == 'D' or rch == 'A' or rch == 'C' or rch == 'F' or rch == 'G':
  54.             towritev = maketowrite.split()
  55.             towritev[0] += '#'
  56.             maketowrite = str(towritev[0]) + ' ' + str(towritev[1])
  57.        
  58.     wo.write( maketowrite + '\n' )
  59. wo.close()
  60. print("FINISHED")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement