Audacity Bug Summary
••• Introduction •••
••• Keywords •••
    Audacity 3.0.3 development began 19th April 2021

Audacity Bugzilla



Bug 2517 - Mix Stereo To Mono incorrectly changes sample rate to Project Rate without resampling - it should resample to the project rate
Mix Stereo To Mono incorrectly changes sample rate to Project Rate without re...
Status: RESOLVED FIXED
Product: Audacity
Classification: Unclassified
Component: Other
2.4.2
All All
: P3 RepeatableAll
Assigned To: Default Assignee for New Bugs
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2020-08-04 19:42 UTC by Steve Daulton
Modified: 2021-01-28 15:19 UTC (History)
4 users (show)

See Also:
Steps To Reproduce:
1. Launch Audacity 2. Add New > Mono Track 3. Set the track sample rate to 22050 4. Generate 10 seconds, 1000 Hz tone 5. Add New > Mono Track 6. Set the track sample rate to 48000 7. Generate 10 seconds, 12000 Hz tone 8. Join the two mono tracks to make a stereo track 9. Ensure that the Project Rate is 44100 10. Mix Stereo Down to Mono Observe: Track is still a stereo track.
Release Note:
A stereo track can be constructed that has different sample rates for its two channels, and such a stereo track cannot be mixed down to mono. No warning or explanatory message is given.
First Git SHA:
Group: ---
Workaround:
Closed: 2021-01-28 00:00:00
drbailes: Must‑Test‑All‑OS-
petersampsonaudacity: Test‑OK‑Win+
petersampsonaudacity: Test‑OK‑Win+
petersampsonaudacity: Test‑OK‑Mac+
petersampsonaudacity: Test‑OK‑Mac+
stevethefiddle: Test‑OK‑Lin+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Steve Daulton 2020-08-04 19:42:28 UTC
If a stereo track has a different sample rate to the "Project Rate", "Mix Stereo to Mono" incorrectly resamples the track to the project rate. The "track rate" remains unchanged, so the resultant mono mix track plays at the wrong speed.

Example:

1. Stereo Track has sample rate of 48 kHz and is 10 seconds long.
2. Project Rate is 44100 Hz.
3. Mix Stereo Track to Mono
4. The mono mix track is now only 9.188 seconds long and plays too fast and higher pitch. The track sample rate still indicates 48000 Hz sample rate.

Observed on Mac and Linux. Expected to be "All" but not tested on Windows.

This is a regression against 2.3.3.
Comment 2 Peter Sampson 2020-08-07 07:12:07 UTC
Tested on W10 with Audacity 3.0.0 1d9a78b

This now appears to be fixed properly (I tested versus the previous alpha to confirm).
Comment 3 Peter Sampson 2020-08-07 07:16:50 UTC
Also tested on macOS 10.15.6 Catalina

works properly now on Mac too.
Comment 4 Steve Daulton 2020-08-07 11:57:27 UTC
Fine on Linux.
Comment 5 Steve Daulton 2020-08-31 05:48:33 UTC
As per the first comment on https://github.com/audacity/audacity/commit/1d9a78b
"Mix Stereo down to mono" fails if left and right channels have different sample  rates.

Also, I'm not convinced that mixing down to the track rate is correct. For the other two "Tracks menu > Mix" commands we use the project rate. Surely we should be consistent?

The title of this bug could be clearer. I think the sample rate should be changed to the project rate, but should be done correctly (that is, the track should be resampled, not simply changing the rate without resampling.
Comment 6 David Bailes 2020-09-07 05:14:18 UTC
(In reply to Steve Daulton from comment #5)
> As per the first comment on
> https://github.com/audacity/audacity/commit/1d9a78b
> "Mix Stereo down to mono" fails if left and right channels have different
> sample  rates.
> 
> Also, I'm not convinced that mixing down to the track rate is correct. For
> the other two "Tracks menu > Mix" commands we use the project rate. Surely
> we should be consistent?
> 
> The title of this bug could be clearer. I think the sample rate should be
> changed to the project rate, but should be done correctly (that is, the
> track should be resampled, not simply changing the rate without resampling.

My fix in:
https://github.com/audacity/audacity/commit/1d9a78b8c8ad5d1e81f1b90aed23b19bff436468

fixes the regression which was caused by commit: e8f9f4a.
Prior to that, and going back at least to Audacity 1.3.7:
1. If the two channels had the same rate, they were mixed down to that rate.
2. If the two channels had different rates, then the command had no effect.

I think it would be clearer if the bug where the channels have different rates, and the enhancement to change the rate for the mix were logged as separate bug/enhancements, and this bug was closed.


e8f9f4a
Comment 7 Steve Daulton 2020-09-07 06:36:49 UTC
(In reply to David Bailes from comment #6)
> I think it would be clearer if the bug where the channels have
> different rates, and the enhancement to change the rate for the
> mix were logged as separate bug/enhancements, and this bug was closed.

On the other hand, on Linux, Mix Stereo Track to Mono fails on Linux in Audacity 2.3.2 in a different way (nothing happens at all if the channels have different sample rates). It was "fixed" in 2.3.3 but still produced the wrong result. It has now been fixed again, but is still not producing the "correct" result, so I thought it reasonable to say that it isn't actually "fixed".

I have now updated the bug title.

Try these steps:
1. Launch Audacity
2. Add New > Mono Track
3. Set the track sample rate to 22050
4. Generate 10 seconds, 1000 Hz tone
5. Add New > Mono Track
6. Set the track sample rate to 48000
7. Generate 10 seconds, 12000 Hz tone
8. Join the two mono tracks to make a stereo track
9. Ensure that the Project Rate is 44100
10. Mix Stereo Down to Mono

Expected result, the stereo track is mixed down to a mono track with a sample rate of 44100.

Actual result - nothing happens. It silently fails.
This also happens in Audacity 2.3.2 on Linux, though it is obviously not the correct behaviour.
Comment 8 David Bailes 2020-09-07 06:46:15 UTC
(In reply to Steve Daulton from comment #7)
> (In reply to David Bailes from comment #6)
> > I think it would be clearer if the bug where the channels have
> > different rates, and the enhancement to change the rate for the
> > mix were logged as separate bug/enhancements, and this bug was closed.
> 
> On the other hand, on Linux, Mix Stereo Track to Mono fails on Linux in
> Audacity 2.3.2 in a different way (nothing happens at all if the channels
> have different sample rates). It was "fixed" in 2.3.3 but still produced the
> wrong result. It has now been fixed again, but is still not producing the
> "correct" result, so I thought it reasonable to say that it isn't actually
> "fixed".
> 
> I have now updated the bug title.

Changing the title and the nature of the bug makes following the comments almost impossible.
I still think I fixed the bug as originally specified, and further work on this is not a priority for me.

> 
> Try these steps:
> 1. Launch Audacity
> 2. Add New > Mono Track
> 3. Set the track sample rate to 22050
> 4. Generate 10 seconds, 1000 Hz tone
> 5. Add New > Mono Track
> 6. Set the track sample rate to 48000
> 7. Generate 10 seconds, 12000 Hz tone
> 8. Join the two mono tracks to make a stereo track
> 9. Ensure that the Project Rate is 44100
> 10. Mix Stereo Down to Mono
> 
> Expected result, the stereo track is mixed down to a mono track with a
> sample rate of 44100.
> 
> Actual result - nothing happens. It silently fails.
> This also happens in Audacity 2.3.2 on Linux, though it is obviously not the
> correct behaviour.
Comment 9 Steve Daulton 2020-09-07 07:04:36 UTC
(In reply to David Bailes from comment #8)
> Changing the title and the nature of the bug makes following
> the comments almost impossible.

I apologise for not being clear originally about what the correct behaviour should be. "incorrectly changes" was ambiguous. I believe the new description is less ambiguous.
Comment 10 James Crook 2020-09-19 07:42:02 UTC
**** STEPS UPDATED ****

Demoting residual to P3.
It's pretty rare that people will make stereo tracks in this way, and this residual does not merit the P2 rating.
Comment 11 Leland Lucius 2021-01-23 07:51:21 UTC
Fix in:

https://github.com/audacity/audacity/commit/e9d4a8e

Try it with 1 hour tracks and watch the progress dialog. There will 1 to 3 stages for each stereo track.

1 if the channels have the same sample rate
2 if the channels don't have the same sample rate and 1 of them matches the project rate
3 if both channels do not match the project rate
Comment 12 Peter Sampson 2021-01-23 12:18:58 UTC
(In reply to Leland Lucius from comment #11)
Testing on W10 with Audacity 3.0.0 4e6e3c2

This works properly on Windows
Comment 13 Peter Sampson 2021-01-23 12:23:40 UTC
(In reply to Leland Lucius from comment #11)
Testing on macOS 11.1 Big Sur with Audacity 3.0.0 4e6e3c2

This works properly on Mac with Leland's latest change
Comment 14 Peter Sampson 2021-01-28 15:19:39 UTC
Examing the commit for this shows that it is plarform-indeoendent
https://github.com/audacity/audacity/commit/e9d4a8e53804c9800631e9a69b2e0eee8abc5b92

So as this works OK on Win and Mac I shall close this as FIXED