The first one is easy using “Nyquist” scripting.
Apply this code via the “Nyquist Prompt” effect (See: Nyquist Prompt - Audacity Manual)
(setf bias 0.5)
(setf hz 100)
(setf amplitude 0.8)
(scale amplitude (osc-pulse hz bias))
- “bias” controls the pulse width and should be between -1 and +1, giving a pulse width from 0% (always at -1) to 100% (always at +1). When bias is zero, a square wave is generated.
- “hz” controls the frequency.
- “amplitude” controls the amplitude (0 to 1)
For more complex examples, as Trebor wrote, see this plug-in: Expression Generator - #2 by steve
It is a “Nyquist plug-in”.
Installation instructions for Nyquist plug-inson Linux: https://manual.audacityteam.org/man/installing_effect_generator_and_analyzer_plug_ins_on_linux.html#nyquist_install