Skip to content

Fix paste into empty audio track preserving source sample rate - #10947

Merged
kryksyh merged 1 commit into
audacity:audacity3from
juancolonna:patch-1
May 25, 2026
Merged

kryksyh merged 1 commit into
audacity:audacity3from
juancolonna:patch-1

Conversation

@juancolonna

Copy link
Copy Markdown

Explanation: Currently, when a destination track is newly created and empty, it usually has the project/default rate (typically 44.1 kHz 32 bits). During paste, clip insertion resample to the destination rate, so copied audio from another rate (for example 48 kHz) is unexpectedly converted.

This fix set the destination track rate to the source track rate and format ONLY when the destination has no clips yet and rates differ. This prevents unintended resampling in the empty-track paste scenario while keeping existing behavior for non-empty destination tracks.

Reproduction:

  • Import one mono wave track with a sampling rate and format different from 44.1 kHz 32 bits (for example 48 kHz 16 PCM)
  • Select this track (or a segment of it) and copy
  • Create a new empty track
  • Paste into the selected new track
  • Verify that the pasted audio was resampled to 44.1 kHz 32 bits regardless of source rate and format

Before this fix: Pasting into a newly created empty track force the pasted audio to the destination/project default sample rate (typically 44.1 kHz 32 bits). This caused unintended sample-rate conversion and possible quality loss

After this fix: If the destination WaveTrack is empty, its rate and format is aligned to the source before paste
Paste behavior for non-empty destination tracks is unchanged

Motivation: Preserve audio fidelity and avoid unexpected resampling.

  • [ 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 May 18, 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: 82eec938-e8d0-4f9c-b381-f736d7e365f2

📥 Commits

Reviewing files that changed from the base of the PR and between a379a28328ddc68e003e883bc0ba7bf8640f7a8f and 6e25ed8.

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

📝 Walkthrough

Walkthrough

The PR modifies the OnPaste function in EditMenus.cpp to fix how sample properties are handled when pasting audio into an empty wave track. Previously, paste operations on empty destination tracks did not preserve the source track's sample rate and format. The change adds explicit logic to copy these properties from the source track to the destination before executing the paste, ensuring consistent audio format handling.

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 accurately describes the main change: preserving source sample rate when pasting into an empty audio track.
Description check ✅ Passed The description includes problem statement, solution, reproduction steps, before/after behavior, motivation, and most checklist items completed, though QA/Testflow testing was not run.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ 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 moved this from To-Do to Ready for QA in [AU3] Main board May 18, 2026
@kryksyh kryksyh added this to the Audacity 3.7.8 milestone May 18, 2026
@dozzzzer dozzzzer moved this from Ready for QA to In QA in [AU3] Main board May 25, 2026
@dozzzzer dozzzzer moved this from In QA to Ready for QA in [AU3] Main board May 25, 2026
@chinakov chinakov moved this from Ready for QA to In QA in [AU3] Main board May 25, 2026
@chinakov chinakov self-assigned this May 25, 2026
@chinakov chinakov moved this from In QA to Ready for merge in [AU3] Main board May 25, 2026
Fix paste into empty audio track preserving source sample rate
@kryksyh
kryksyh merged commit 7e0dc4f into audacity:audacity3 May 25, 2026
8 checks passed
@github-project-automation github-project-automation Bot moved this from Ready for merge to Done in [AU3] Main board May 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants