Add frequency output file (fundamental=100Hz)

This commit is contained in:
Michael Winter 2026-03-13 01:11:18 +01:00
parent b89ff9c184
commit c63b6cb1d4

View file

@ -970,6 +970,18 @@ def write_chord_sequence_readable(seq: list[Chord], path: str) -> None:
f.write(")\n") f.write(")\n")
def write_chord_sequence_frequencies(
seq: list[Chord], path: str, fundamental: float = 100.0
) -> None:
"""Write chord sequence as frequencies in Hz - one line per chord."""
with open(path, "w") as f:
f.write("(\n")
for chord in seq:
freqs = tuple(fundamental * float(p.to_fraction()) for p in chord._pitches)
f.write(f" {freqs},\n")
f.write(")\n")
# ============================================================================ # ============================================================================
# MAIN / DEMO # MAIN / DEMO
# ============================================================================ # ============================================================================
@ -1069,6 +1081,9 @@ def main():
write_chord_sequence_readable(path, "output_chords.txt") write_chord_sequence_readable(path, "output_chords.txt")
print("Written to output_chords.txt") print("Written to output_chords.txt")
write_chord_sequence_frequencies(path, "output_frequencies.txt")
print("Written to output_frequencies.txt")
if __name__ == "__main__": if __name__ == "__main__":
main() main()