name pitches

This commit is contained in:
Thomas Lindner 2024-12-23 17:56:59 +01:00
parent 1a1718973b
commit 3696c9726f
2 changed files with 87 additions and 67 deletions

View file

@ -16,7 +16,10 @@ parser.add_argument("--bpm", default=60, type=float, help="beats per minute")
args = parser.parse_args()
# 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
base_duration = 60 / args.bpm / 16
@ -33,14 +36,15 @@ with open(args.output, "w") as f:
if pitch == "":
# skip comment
continue
pitch = int(pitch)
if pitch + 12 < 0 or pitch + 12 > len(frequencies) - 1:
sys.exit(f"pitch goes from -12 to {len(frequencies) - 1 - 12}")
try:
frequency = frequencies[pitch]
except KeyError:
sys.exit("pitch goes from c3 to b5")
duration = int(duration)
pause = int(pause)
if duration < 1 or pause < 0:
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
position += -length if position > 100 else length
if position < 0 or position > 200:

View file

@ -1,62 +1,78 @@
4,4,0
4,4,0
5,4,0
7,4,0
7,4,0
5,4,0
4,4,0
2,4,0
0,4,0
0,4,0
2,4,0
4,4,0
4,6,0
2,2,0
2,8,0
4,4,0
4,4,0
5,4,0
7,4,0
7,4,0
5,4,0
4,4,0
2,4,0
0,4,0
0,4,0
2,4,0
4,4,0
2,6,0
0,2,0
0,8,0
2,4,0
2,4,0
4,4,0
0,4,0
2,4,0
4,2,0
5,2,0
4,4,0
0,4,0
2,4,0
4,2,0
5,2,0
4,4,0
2,4,0
0,4,0
2,4,0
-5,8,0
4,4,0
4,4,0
5,4,0
7,4,0
7,4,0
5,4,0
4,4,0
2,4,0
0,4,0
0,4,0
2,4,0
4,4,0
2,6,0
0,2,0
0,8,0
,,https://www.lieder-archiv.de/lieder/solo1/300600.png
e4,4,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
,,
e4,6,0
d4,2,0
d4,8,0
,,
e4,4,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
,,
d4,4,0
d4,4,0
e4,4,0
c4,4,0
,,
d4,4,0
e4,2,0
f4,2,0
e4,4,0
c4,4,0
,,
d4,4,0
e4,2,0
f4,2,0
e4,4,0
d4,4,0
,,
c4,4,0
d4,4,0
g3,8,0
,,holding the G3 longer sounds better
e4,4,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