From 31ac728737e30706196f7466a0a061efa4578d50 Mon Sep 17 00:00:00 2001 From: David Gwilliam Date: Thu, 19 Mar 2026 04:02:06 -0700 Subject: [PATCH] feat: Add LFO mode options to oscilloscope demo - Add --lfo flag for slow modulation (0.5Hz) - Add --fast-lfo flag for rhythmic modulation (5Hz) - Display frequency type (LFO/Audio) in output - More intuitive LFO usage for modulation applications Usage: uv run python scripts/demo_oscilloscope.py --lfo --waveform sine uv run python scripts/demo_oscilloscope.py --fast-lfo --waveform triangle --- scripts/demo_oscilloscope.py | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/scripts/demo_oscilloscope.py b/scripts/demo_oscilloscope.py index ade7409..bbc8909 100644 --- a/scripts/demo_oscilloscope.py +++ b/scripts/demo_oscilloscope.py @@ -116,7 +116,12 @@ def demo_oscilloscope( frames: int = 0, ): """Run oscilloscope demo.""" - print(f"Oscilloscope demo: {waveform} wave at {frequency}Hz") + # Determine if this is LFO range + is_lfo = frequency <= 20.0 and frequency >= 0.1 + freq_type = "LFO" if is_lfo else "Audio" + + print(f"Oscilloscope demo: {waveform} wave") + print(f"Frequency: {frequency}Hz ({freq_type} range)") if frames > 0: print(f"Running for {frames} frames") else: @@ -164,7 +169,17 @@ if __name__ == "__main__": "--frequency", type=float, default=1.0, - help="Oscillator frequency in Hz", + help="Oscillator frequency in Hz (LFO: 0.1-20Hz, Audio: >20Hz)", + ) + parser.add_argument( + "--lfo", + action="store_true", + help="Use LFO frequency (0.5Hz - slow modulation)", + ) + parser.add_argument( + "--fast-lfo", + action="store_true", + help="Use fast LFO frequency (5Hz - rhythmic modulation)", ) parser.add_argument( "--frames", @@ -174,8 +189,16 @@ if __name__ == "__main__": ) args = parser.parse_args() + + # Determine frequency based on mode + frequency = args.frequency + if args.lfo: + frequency = 0.5 # Slow LFO for modulation + elif args.fast_lfo: + frequency = 5.0 # Fast LFO for rhythmic modulation + demo_oscilloscope( waveform=args.waveform, - frequency=args.frequency, + frequency=frequency, frames=args.frames, )