-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.html
156 lines (135 loc) · 6.14 KB
/
index.html
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
<!DOCTYPE html>
<html>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/brython@3.10.5/brython.min.js">
</script><!--script type="text/javascript" src="brython_stdlib.js"></script-->
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<title>Chord Transposer</title>
<link rel="icon" href="icon.png">
<link rel="manifest" href="manifest.webmanifest">
<meta charset="utf-8">
<meta name="Description" CONTENT="Transpose your songs to match your voice pitch. Transpose selectinng initial and final note or transpose by semitones. This website is 100% free, no paid extra features or anythong similar. Enjoy :)">
</head>
<body onload="brython();document.getElementById('input').focus()">
<script src="script.js"></script>
<script type="text/python">
from browser import document, alert, window
#import re
def echo(text):
alert(text)
def run(event):
oldval = document["output"].value
song = document["input"].value
keys ={
"C": 1,
"C#": 2,
"D♭": 2,
"D": 3,
"D#": 4,
"E♭": 4,
"E": 5,
"F": 6,
"F#": 7,
"G♭": 7,
"G": 8,
"G#": 9,
"A♭": 9,
"A": 10,
"A#": 11,
"B♭": 11,
"B": 12,
}
vals ={
1: "C",
2: "C#",
2: "D♭",
3: "D",
4: "D#",
4: "E♭",
5: "E",
6: "F",
7: "F#",
7: "G♭",
8: "G",
9: "G#",
9: "A♭",
10: "A",
11: "A#",
11: "B♭",
12: "B",
}
if document["notesRadio"].checked == True:
start = vals[int(document["startChord"].value)]
print(start)
end = vals[int(document["endChord"].value)]
diff = keys[end]-keys[start]
else:
diff = int(float(document["tonesSelector"].value)*2)
def getCorrectVal(i):
while i > 12:
i -= 12
while i <= 0:
i += 12
return i
print("diff is", diff)
song = song.replace("\n", " \n ").replace("\t", " ")
fSong = ""
for line in song.split("\n"):
if " " in line:
for key in keys.keys():
line = line.replace(" "+key+"", "~#"+vals[getCorrectVal(keys[key]+diff)])
fSong += line.replace("~#", "")+"\n"
document["output"].value = fSong
if fSong == oldval:
window.showInput()
document["output"].value = ""
else:
window.showOutput()
document["calculate"].bind("click", run)
document["edittext"].bind("click", run)
</script>
<p id="title">Chord Transposer</p>
<p id="subtitle">Easily transpose the chords on your songs!</p>
<img src="./icon.png" id="logo">
<textarea id="input" onclick="showInput()" placeholder="Write or paste the chords here" onkeyup="document.getElementById('calculate').disabled = document.getElementById('input').value == '';" spellcheck="false"></textarea><textarea id="output" onclick="if(document.getelementById('output').value != ''){showOutput();}" placeholder="Please wait..." disabled></textarea>
<span id=sNotesRadio><input type="radio" id="notesRadio" name="input_mode" value="notes" onclick="showNotes()" checked><label for="notesRadio"> Transpose using notes</label></span>
<span id=sTonesRadio><input type="radio" id="tonesRadio" name="input_mode" value="tones" onclick="showTones()"><label for="tonesRadio"> Transpose using tones</label></span>
<select id="startChord">
<option value="1">Select start note</option>
<option value="1">C</option>
<option value="2">C♯ | D♭</option>
<option value="3">D</option>
<option value="4">D♯ | E♭</option>
<option value="5">E</option>
<option value="6">F</option>
<option value="7">F♯ | G♭</option>
<option value="8">G</option>
<option value="9">G♯ | A♭</option>
<option value="10">A</option>
<option value="11">A♯ | B♭</option>
<option value="12">B</option>
</select>
<select id="endChord">
<option value="1">Select end note</option>
<option value="3">D</option>
<option value="4">D♯ | E♭</option>
<option value="5">E</option>
<option value="6">F</option>
<option value="7">F♯ | G♭</option>
<option value="8">G</option>
<option value="9">G♯ | A♭</option>
<option value="10">A</option>
<option value="11">A♯ | B♭</option>
<option value="12">B</option>
<option value="1">C</option>
<option value="2">C♯ | D♭</option>
</select>
<span id=sTonesSelector style="visibility: hidden;display: flex;"><span style="line-height: 40px;">Amount of tones to transpose: </span><input type=number id=tonesSelector value=0 step=0.5 placeholder="" , style="float: right; flex-grow: 1;"></span>
<button id="calculate" disabled>Transpose</button>
<div id="bottom">
<p style="background-color: transparent;text-align: left; position: absolute; left: 20px;">Made by <a href="https://www.marticliment.com/" target="_blank">Martí Climent</a></p>
<p style="background-color: transparent;text-align: right;position: absolute; right: 20px;">Version 1.2 - Under the <a href="https://github.com/marticliment/marticliment.github.io/blob/main/LICENSE" target="_blank">MIT License</a></p>
</div>
<button id="edittext" onclick="showInput()">✎</button>
</body>
</html>