Skip to content

Fix setting clip's project tempo after opening project - #11526

Merged
kryksyh merged 1 commit into
audacity:audacity3from
DavidBailes:fixprojecttempo
Aug 17, 2026
Merged

kryksyh merged 1 commit into
audacity:audacity3from
DavidBailes:fixprojecttempo

Conversation

@DavidBailes

Copy link
Copy Markdown
Collaborator

Resolves: #11337

Problem:
After opening a project, clips can have the wrong tempo. The tempo of a clip is the clip's "RawAudioTempo" rather than the project tempo. So when these values are different, a clip has the wrong tempo.

This issue was caused by PR #10688, in which there was a change to publishing a TrackListEvent::ADDITION event immediately, rather than using CallAfter. When opening a project, ProjectTempoListener::ProjectTempoListener() responds to a TrackListEvent::ADDITION by calling DoProjectTempoChange(*track, tempo), which calls OnProjectTempoChange::Call(group, oldTempo, newTempo), where oldTempo is nullopt, and newTempo is the project tempo. This is an attached virtual function, and there are overrides for each type of track. For wavetracks, this function sets the clip's project tempo. However because of the change in timing of the publishing of the event, the clips have not yet been added to the track, and so their values of project tempo are not set. When the oldTempo is nullopt, the overrides for all the other track types do nothing, and so other tracks are not affected by the change in timing.

Fix:
Add another call to OnProjectTempoChange::Call(group, oldTempo, newTempo), after the clips have been added.

  • [ 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:

  • Testflow test cases have been run

@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Pro Plus

Run ID: ae6b39cc-2331-4a8a-8fe2-8a240a673120

📥 Commits

Reviewing files that changed from the base of the PR and between 2cbd4c4 and 3717a17f06eadabb608602344e90dab37e05e5ec.

📒 Files selected for processing (1)
  • src/ProjectFileManager.cpp

📝 Walkthrough

Walkthrough

After successfully parsing a project without track errors, OpenProjectFile computes the current tempo from ProjectTimeSignature and invokes OnProjectTempoChange::Call for every track, passing no previous tempo and the computed project tempo.

Estimated code review effort: 2 (Simple) | ~5 minutes

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main fix: restoring clip project tempo after opening a project.
Description check ✅ Passed The description includes the issue link, problem explanation, fix summary, and checklist items, so it is mostly complete.
Linked Issues check ✅ Passed The change adds the missing tempo update after clips are added, matching the regression fix required by issue #11337.
Out of Scope Changes check ✅ Passed The patch is narrowly scoped to the project-open tempo update and introduces no unrelated changes.

Warning

Review ran into problems

🔥 Problems

Linked repositories: Public OSS repositories can only analyze public repositories installed in this organization. No linked repositories were analyzed; skipped musescore/musescore.


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.

@DavidBailes
DavidBailes requested a review from kryksyh July 27, 2026 09:09

@kryksyh kryksyh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DavidBailes thank you!

@kryksyh kryksyh linked an issue Aug 17, 2026 that may be closed by this pull request
Problem:
After opening a project, clips can have the wrong tempo. The tempo of a clip is the clip's "RawAudioTempo" rather than the project tempo. So when these values are different, a clip has the wrong tempo.

This issue was caused by PR audacity#10688, in which there was a change to publishing a TrackListEvent::ADDITION event immediately, rather than using CallAfter.
When opening a project, ProjectTempoListener::ProjectTempoListener() responds to a TrackListEvent::ADDITION by calling DoProjectTempoChange(*track, tempo), which calls OnProjectTempoChange::Call(group, oldTempo, newTempo), where oldTempo is nullopt, and newTempo is the project tempo. This is an attached virtual function, and there are overrides for each type of track. For wavetracks, this function sets the clip's project tempo. However because of the change in timing of the publishing of the event, the clips have not yet been added to the track, and so their values of project tempo are not set. When the oldTempo is nullopt, the overrides for all the other track types do nothing, and so other tracks are not affected by the change in timing.

Fix:
Add another call to OnProjectTempoChange::Call(group, oldTempo, newTempo), after the clips have been added.
@kryksyh
kryksyh merged commit c90c052 into audacity:audacity3 Aug 17, 2026
9 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.

When opening a project, clips can have the wrong tempo

2 participants