Replace --osc-enable with --osc-play

- Add --osc-play with optional file argument
- If no file provided, defaults to output/output_chords.json
- Fix python-osc API (addr -> address)
- Keep --fundamental, --osc-ip, --osc-port
This commit is contained in:
Michael Winter 2026-03-17 17:10:37 +01:00
parent 1ccab2088f
commit ea3acf9efe
2 changed files with 21 additions and 4 deletions

View file

@ -355,9 +355,11 @@ def main():
help="Show analysis statistics after generation",
)
parser.add_argument(
"--osc-enable",
action="store_true",
help="Enable OSC output for real-time playback",
"--osc-play",
nargs="?",
const="output/output_chords.json",
default=None,
help="Enable OSC playback (optionally specify chord file, default: output/output_chords.json)",
)
parser.add_argument(
"--osc-ip",
@ -379,6 +381,21 @@ def main():
)
args = parser.parse_args()
# Handle OSC playback mode (separate from generation)
if args.osc_play:
from .osc_sender import OSCSender
chords_file = args.osc_play
sender = OSCSender(
ip=args.osc_ip, port=args.osc_port, fundamental=args.fundamental
)
sender.load_chords(chords_file)
print(f"OSC playback from: {chords_file}")
print(f"Destination: {args.osc_ip}:{args.osc_port}")
print(f"Fundamental: {args.fundamental} Hz")
sender.play()
return # Exit after OSC playback
# Select dims
if args.dims == 4:
dims = DIMS_4

View file

@ -45,7 +45,7 @@ class OSCSender:
frac = Fraction(pitch["fraction"])
freq = self.fundamental * float(frac)
addr = f"/freq"
msg = osc_message_builder.OscMessageBuilder(addr=addr)
msg = osc_message_builder.OscMessageBuilder(address=addr)
msg.add_arg(voice_idx + 1) # Voice number (1-indexed)
msg.add_arg(freq) # Frequency
self.client.send(msg.build())