name pitches
This commit is contained in:
parent
1a1718973b
commit
3696c9726f
14
freude.py
14
freude.py
|
|
@ -16,7 +16,10 @@ parser.add_argument("--bpm", default=60, type=float, help="beats per minute")
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
# starting from C3 = 130.81 Hz
|
# starting from C3 = 130.81 Hz
|
||||||
frequencies = [2 ** (i / 12) * 130.81 for i in range(36)]
|
pitches = ["c", "c#", "d", "d#", "e", "f", "f#", "g", "g#", "a", "a#", "b"]
|
||||||
|
frequencies = {
|
||||||
|
f"{pitches[i % 12]}{i // 12 + 3}": 2 ** (i / 12) * 130.81 for i in range(36)
|
||||||
|
}
|
||||||
# duration of 1/16th beat
|
# duration of 1/16th beat
|
||||||
base_duration = 60 / args.bpm / 16
|
base_duration = 60 / args.bpm / 16
|
||||||
|
|
||||||
|
|
@ -33,14 +36,15 @@ with open(args.output, "w") as f:
|
||||||
if pitch == "":
|
if pitch == "":
|
||||||
# skip comment
|
# skip comment
|
||||||
continue
|
continue
|
||||||
pitch = int(pitch)
|
try:
|
||||||
if pitch + 12 < 0 or pitch + 12 > len(frequencies) - 1:
|
frequency = frequencies[pitch]
|
||||||
sys.exit(f"pitch goes from -12 to {len(frequencies) - 1 - 12}")
|
except KeyError:
|
||||||
|
sys.exit("pitch goes from c3 to b5")
|
||||||
duration = int(duration)
|
duration = int(duration)
|
||||||
pause = int(pause)
|
pause = int(pause)
|
||||||
if duration < 1 or pause < 0:
|
if duration < 1 or pause < 0:
|
||||||
sys.exit("duration/pause are integer multiples of 1/16th beat")
|
sys.exit("duration/pause are integer multiples of 1/16th beat")
|
||||||
feedrate = int(frequencies[pitch + 12] * 60 / args.steps_per_mm)
|
feedrate = int(frequency * 60 / args.steps_per_mm)
|
||||||
length = duration * base_duration / 60 * feedrate
|
length = duration * base_duration / 60 * feedrate
|
||||||
position += -length if position > 100 else length
|
position += -length if position > 100 else length
|
||||||
if position < 0 or position > 200:
|
if position < 0 or position > 200:
|
||||||
|
|
|
||||||
140
freude.txt
140
freude.txt
|
|
@ -1,62 +1,78 @@
|
||||||
4,4,0
|
,,https://www.lieder-archiv.de/lieder/solo1/300600.png
|
||||||
4,4,0
|
e4,4,0
|
||||||
5,4,0
|
e4,4,0
|
||||||
7,4,0
|
f4,4,0
|
||||||
7,4,0
|
g4,4,0
|
||||||
5,4,0
|
,,
|
||||||
4,4,0
|
g4,4,0
|
||||||
2,4,0
|
f4,4,0
|
||||||
0,4,0
|
e4,4,0
|
||||||
0,4,0
|
d4,4,0
|
||||||
2,4,0
|
,,
|
||||||
4,4,0
|
c4,4,0
|
||||||
4,6,0
|
c4,4,0
|
||||||
2,2,0
|
d4,4,0
|
||||||
2,8,0
|
e4,4,0
|
||||||
4,4,0
|
,,
|
||||||
4,4,0
|
e4,6,0
|
||||||
5,4,0
|
d4,2,0
|
||||||
7,4,0
|
d4,8,0
|
||||||
7,4,0
|
,,
|
||||||
5,4,0
|
e4,4,0
|
||||||
4,4,0
|
e4,4,0
|
||||||
2,4,0
|
f4,4,0
|
||||||
0,4,0
|
g4,4,0
|
||||||
0,4,0
|
,,
|
||||||
2,4,0
|
g4,4,0
|
||||||
4,4,0
|
f4,4,0
|
||||||
2,6,0
|
e4,4,0
|
||||||
0,2,0
|
d4,4,0
|
||||||
0,8,0
|
,,
|
||||||
2,4,0
|
c4,4,0
|
||||||
2,4,0
|
c4,4,0
|
||||||
4,4,0
|
d4,4,0
|
||||||
0,4,0
|
e4,4,0
|
||||||
2,4,0
|
,,
|
||||||
4,2,0
|
d4,6,0
|
||||||
5,2,0
|
c4,2,0
|
||||||
4,4,0
|
c4,8,0
|
||||||
0,4,0
|
,,
|
||||||
2,4,0
|
d4,4,0
|
||||||
4,2,0
|
d4,4,0
|
||||||
5,2,0
|
e4,4,0
|
||||||
4,4,0
|
c4,4,0
|
||||||
2,4,0
|
,,
|
||||||
0,4,0
|
d4,4,0
|
||||||
2,4,0
|
e4,2,0
|
||||||
-5,8,0
|
f4,2,0
|
||||||
4,4,0
|
e4,4,0
|
||||||
4,4,0
|
c4,4,0
|
||||||
5,4,0
|
,,
|
||||||
7,4,0
|
d4,4,0
|
||||||
7,4,0
|
e4,2,0
|
||||||
5,4,0
|
f4,2,0
|
||||||
4,4,0
|
e4,4,0
|
||||||
2,4,0
|
d4,4,0
|
||||||
0,4,0
|
,,
|
||||||
0,4,0
|
c4,4,0
|
||||||
2,4,0
|
d4,4,0
|
||||||
4,4,0
|
g3,8,0
|
||||||
2,6,0
|
,,holding the G3 longer sounds better
|
||||||
0,2,0
|
e4,4,0
|
||||||
0,8,0
|
e4,4,0
|
||||||
|
f4,4,0
|
||||||
|
g4,4,0
|
||||||
|
,,
|
||||||
|
g4,4,0
|
||||||
|
f4,4,0
|
||||||
|
e4,4,0
|
||||||
|
d4,4,0
|
||||||
|
,,
|
||||||
|
c4,4,0
|
||||||
|
c4,4,0
|
||||||
|
d4,4,0
|
||||||
|
e4,4,0
|
||||||
|
,,
|
||||||
|
d4,6,0
|
||||||
|
c4,2,0
|
||||||
|
c4,8,0
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue