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()