initial commit

This commit is contained in:
v 2024-12-23 01:08:03 +01:00
commit 675516b28b
2 changed files with 84 additions and 0 deletions

22
freude.py Normal file
View file

@ -0,0 +1,22 @@
import csv
steps_per_mm = 5
# starting from C3 = 130.81 Hz
frequencies = [2**(i/12) * 130.81 for i in range(24)]
base_duration = 0.12
with open("FREUDE.gcode", "w") as f:
f.write("G21 ; set units to millimeters\n")
f.write("G90 ; use absolute coordinates\n")
f.write("G0 Z10 F300\n")
f.write("G0 X0 Y0 F3000\n")
f.write("G4 S1 ; wait 1 second\n")
position = 0
with open("freude.txt", "r") as notes:
for note, duration in csv.reader(notes):
feedrate = int(frequencies[int(note) + 12] * 60 / steps_per_mm)
length = int(duration) * base_duration / 60 * feedrate
position += -length if position > 100 else length
f.write(f"G0 X{position:.6f} Y{position:.6f} F{feedrate} \n")
f.write("G4 P15 ; wait a bit\n")
f.write("G4 ; wait\n")

62
freude.txt Normal file
View file

@ -0,0 +1,62 @@
4,2
4,2
5,2
7,2
7,2
5,2
4,2
2,2
0,2
0,2
2,2
4,2
4,3
2,1
2,4
4,2
4,2
5,2
7,2
7,2
5,2
4,2
2,2
0,2
0,2
2,2
4,2
2,3
0,1
0,4
2,2
2,2
4,2
0,2
2,2
4,1
5,1
4,2
0,2
2,2
4,1
5,1
4,2
2,2
0,2
2,2
-8,2
4,4
4,2
5,2
7,2
7,2
5,2
4,2
2,2
0,2
0,2
2,2
4,2
2,3
0,1
0,4