Tone Generator via Scripting drifts frequency to last GUI-used value despite explicit parameters

Dear Community,

I’m trying to generate a constant frequency sine wave using Audacity’s scripting interface (mod-script-pipe), by using the Tone command in my python script:

do_command('NewMonoTrack:')
do_command('Select: Start=0 End=1 Track=0')
do_command('Tone: Frequency=440 Amplitude=0.9 Waveform="Sine"')

The resulting tone starts at 440 Hz but then drifts/sweeps to whatever frequency I last used in the GUI Tone Generator. Restarting Audacity does not solve the issue (then, the frequency decreases to 0 Hz). When I use the GUI Tone Generator, everything works as expected.
This seems to indicate that the scripting interface’s Tone command is still referencing some internal stored state from the GUI tone generator, overriding the scripted parameters partially or gradually over time.

Is there a known way to completely reset or override the Tone Generator’s internal parameter state via scripting?
Thank you for any pointers or workarounds!

Yours sincerely,
flori8029

It looks like a bug to me. If you wish to report it to the developers, do so here: GitHub · Where software is built

A possible workaround might be to use “Chirp” instead of “Tone”. If the start and end parameters of Chirp are the same, then the generated sound is a constant Tone.