1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181
|
print("Please enter the original an'dand ambition tune(use space splite)") tuneer = input("The default is to C:") '''#b表示低音,#表示升(半音阶),g表示高音,用b#表示低半音,用g#表示高半音''' putin = input("please enter number:") first1 = "" listin1 = [] listin2 = [] listout1 = [] listout2 = [] listoutTemp = [] listTemp = [] changekey = {} changekey2 = {}
def checkspace(listin): '''#b表示低音,#表示升(半音阶),g表示高音,用b#表示低半音,用g#表示高半音''' listTemp = "" listTemp = listin.strip() listlow = listTemp.lower() listOut = listlow.split(" ") if len(listOut) == 1: listOut.append("c") return listOut
listin1 = checkspace(putin) formtuneer = checkspace(tuneer) tuneerin = formtuneer[0] tuneerout = formtuneer[1]
GtoC = {"1" : "b5", "2" : "b6", "3" : "b7", "4" : "1", "5" : "2", "6": "3", "7" : "#4", "g1" : "5", "g2":"6","g3":"7","g4":"g1","g5":"g2","g6":"3", "g7":"g#4","gg1":"g5"} AtoC = {"b7" : "#5", "1" : "b6", "2" : "b7", "3" : "#1", "4" : "2", "5" : "3", "6" : "#4", "7" : "#5", "g1" : "6", "g2" : "7", "g3" : "g#1", "g4" : "g2", "g5" : "g3", "g6" : "g#4" } BtoC = {"b6" : "b#5", "b7":"b#6", "1" : "b7", "2" : "#1", "3" : "#2", "4" : "3", "5" : "#4", "6" : "#5", "7" : "#6", "g1" : "7", "g2" : "g#1", "g3" : "g#2", "g4" : "g3", "g5" : "g#4"} DtoC = {"b4" : "b5", "b5" : "b6", "b6" : "b7", "b7" : "#1", "1" : "2", "2" : "3", "3" : "#4", "4" : "5", "5" : "6", "6" : "7", "7" : "g#1", "g1" : "g2", "g3" : "g#4", "g4" : "g5"} EtoC = {"b3" : "b#5", "b4" : "b6", "b5" : "b7", "b6" : "#1", "b7" : "#2", "1" : "3", "2" : "#4", "3" : "#5", "4" : "6", "5" : "7", "6" : "g#1", "7" : "g#2", "g1" : "g3", "g2" : "g#4"} FtoC = {"b2" : "b5", "b3" : "b6", "b4" : "b#6", "b5" : "1", "b6" : "2", "b7" : "3", "1" : "4", "2" : "5", "3" : "6", "4" : "#6", "5" : "g1", "6" : "g2", "7" : "g3", "g1" : "g4", "g2" : "g5"}
Fulltunekey = {"g":GtoC, "a" : AtoC, "b" : BtoC, "d" : DtoC, "e" : EtoC, "f" : FtoC}
def inverse(dict): dictout = {v : k for k,v in dict.items()} return dictout
CtoG = inverse(GtoC) CtoA = inverse(AtoC) CtoB = inverse(BtoC) CtoD = inverse(DtoC) CtoE = inverse(EtoC) CtoF = inverse(FtoC)
Fulltuneanykey = {"g" : CtoG, "a" : CtoA, "b" : CtoB, "d" : CtoD, "e" : CtoE, "f" : CtoF}
def dictoc(tuneerin,tuneerout): if tuneerin == "a": changekey = Fulltunekey["a"] elif tuneerin == "g": changekey = Fulltunekey["g"] elif tuneerin == "b": changekey = Fulltunekey["b"] elif tuneerin == "d": changekey = Fulltunekey["d"] elif tuneerin == "e": changekey = Fulltunekey["e"] elif tuneerin == "f": changekey = Fulltunekey["f"] return changekey
def dictoany(tuneerout): if tuneerout == "a": changekey2 = Fulltuneanykey["a"] elif tuneerout == "g": changekey2 = Fulltuneanykey["g"] elif tuneerout == "b": changekey2 = Fulltuneanykey["b"] elif tuneerout == "d": changekey2 = Fulltuneanykey["d"] elif tuneerout == "e": changekey2 = Fulltuneanykey["e"] elif tuneerout == "f": changekey2 = Fulltuneanykey["f"] return changekey2
def alltoC(tuneerin): changekey = dictoc(tuneerin, tuneerout) for i in listin1: listout1.append(changekey[i]) return listout1
def ctoall(tuneerout): if tuneerout != "c": changekey2 = dictoany(tuneerout) listout1 = alltoC(tuneerin) for i in listout1: listout2.append(changekey2[i]) return listout2
def checkout(tuneerin,tuneerout): if tuneerout == "c": alltoC(tuneerin) print(tuneerin,listin1) print("->") print("c",listout1) else: listout2 = ctoall(tuneerout) print(tuneerin,listin1) print("->") print(tuneerout,listout2) return
checkout(tuneerin,tuneerout)
"5" : "3", "6" : "#4", "7" : "#5", "g1" : "6", "g2" : "7", "g3" : "g#1", "g4" : "g2", "g5" : "g3", "g6" : "g#4" }
|