From c63b6cb1d4891bf2d49d57e8c7c21e434627cb17 Mon Sep 17 00:00:00 2001 From: Michael Winter Date: Fri, 13 Mar 2026 01:11:18 +0100 Subject: [PATCH] Add frequency output file (fundamental=100Hz) --- compact_sets.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/compact_sets.py b/compact_sets.py index 4c0a9ad..7c258a5 100644 --- a/compact_sets.py +++ b/compact_sets.py @@ -970,6 +970,18 @@ def write_chord_sequence_readable(seq: list[Chord], path: str) -> None: 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 # ============================================================================ @@ -1069,6 +1081,9 @@ def main(): write_chord_sequence_readable(path, "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__": main()