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:
parent
1ccab2088f
commit
ea3acf9efe
23
src/io.py
23
src/io.py
|
|
@ -355,9 +355,11 @@ def main():
|
||||||
help="Show analysis statistics after generation",
|
help="Show analysis statistics after generation",
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--osc-enable",
|
"--osc-play",
|
||||||
action="store_true",
|
nargs="?",
|
||||||
help="Enable OSC output for real-time playback",
|
const="output/output_chords.json",
|
||||||
|
default=None,
|
||||||
|
help="Enable OSC playback (optionally specify chord file, default: output/output_chords.json)",
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--osc-ip",
|
"--osc-ip",
|
||||||
|
|
@ -379,6 +381,21 @@ def main():
|
||||||
)
|
)
|
||||||
args = parser.parse_args()
|
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
|
# Select dims
|
||||||
if args.dims == 4:
|
if args.dims == 4:
|
||||||
dims = DIMS_4
|
dims = DIMS_4
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ class OSCSender:
|
||||||
frac = Fraction(pitch["fraction"])
|
frac = Fraction(pitch["fraction"])
|
||||||
freq = self.fundamental * float(frac)
|
freq = self.fundamental * float(frac)
|
||||||
addr = f"/freq"
|
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(voice_idx + 1) # Voice number (1-indexed)
|
||||||
msg.add_arg(freq) # Frequency
|
msg.add_arg(freq) # Frequency
|
||||||
self.client.send(msg.build())
|
self.client.send(msg.build())
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue