Skip to content

Fix generating tone from a macro or a script. - #10870

Merged
kryksyh merged 1 commit into
audacity:audacity3from
DavidBailes:tonegen
May 25, 2026
Merged

kryksyh merged 1 commit into
audacity:audacity3from
DavidBailes:tonegen

Conversation

@DavidBailes

@DavidBailes DavidBailes commented May 5, 2026 •

Copy link
Copy Markdown
Collaborator

Resolves: #4280

Problem.
The results of generating a tone from a macro or script are unpredicable. This is because mFrequency1 and mAmplitude are not being set. There is a function posSet(), which I presume was meant to be called by DoSet() in ShuttleAutomation.h. However the latter function appears not be be called at all.

Fix.
Remove posSet(), and simply call PosSet() in ToneGenBase::ProcessInitialize()

  • [x ] I signed CLA
  • [x ] The title of the pull request describes an issue it addresses
  • [ x] If changes are extensive, then there is a sequence of easily reviewable commits
  • [x ] Each commit's message describes its purpose and effects
  • [x ] There are no behavior changes unnecessary for the stated purpose of the PR

Recommended:

  • [ x] Each commit compiles and runs on my machine without known undesirable changes of behavior

QA:

  • Test the macro in the issue works correctly when run multiple times
  • Test the macro works both with TONE and CHIRP generator
  • Test Tone and Chirp generators work as expected when run directly from Generate/ menu

@DavidBailes DavidBailes linked an issue May 5, 2026 that may be closed by this pull request
@coderabbitai

coderabbitai Bot commented May 5, 2026 •

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: 0be53c57-5d34-4dd8-9976-0ee478f68f75

📥 Commits

Reviewing files that changed from the base of the PR and between 74a028cc9ba05ed2c47788d2dda00e3f983c90a1 and d0862b0.

📒 Files selected for processing (1)
  • libraries/lib-builtin-effects/ToneGenBase.cpp

📝 Walkthrough

Walkthrough

ToneGenBase::Parameters() was refactored to remove the postSet lambda initializer that previously set up chirpParameters and toneParameters static CapturedParameters. The initialization logic is now triggered by an unconditional PostSet() call added to ToneGenBase::ProcessInitialize(). This ensures generator state is properly synchronized when the effect is invoked from external automation contexts like macros or scripts.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title directly and concisely describes the main fix: enabling tone generation from macros/scripts, which is the primary objective of the changeset.
Linked Issues check ✅ Passed The code changes directly address issue #4280 by ensuring mFrequency1 and mAmplitude are initialized in ProcessInitialize(), fixing deterministic tone generation from macros/scripts.
Out of Scope Changes check ✅ Passed All changes are scoped to the ToneGenBase::ProcessInitialize() fix, directly addressing the issue without unrelated modifications.
Description check ✅ Passed The pull request description addresses the issue, explains the problem and fix clearly, and includes all required checklist items with appropriate selections.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@kryksyh

kryksyh commented May 5, 2026

Copy link
Copy Markdown
Member

@DavidBailes we have outdated certificates on artifactory.audacityteam.org, that's why the pipeline is failing. Should be fixed in a day or two.

@DavidBailes

Copy link
Copy Markdown
Collaborator Author

Thanks for the info. It's now fixed.

@kryksyh

kryksyh commented May 6, 2026

Copy link
Copy Markdown
Member

@DavidBailes thank you!

Problem.
The results of generating a tone from a macro or script are unpredicable. This is because mFrequency1 and mAmplitude are not being set. There is a function posSet(), which I presume was meant to be called by DoSet() in ShuttleAutomation.h. However the latter function appears not be be called at all.

Fix.
Remove posSet(), and simply call PosSet() in ToneGenBase::ProcessInitialize().
@kryksyh
kryksyh merged commit 3d6cc7e into audacity:audacity3 May 25, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Macros: Incorrect and inconsistent results from "Tone" command

2 participants