Default plugin issues: Studio Fade Out

from Issues on translating default plugins - #2 by steve

I’ve looked into this further, and I’m no longer convinced that it is a bug. The behaviour is certainly a bit confusing when there are mixed sample rates, but that appears to be a necessary aspect of handling mixed sample rates.

If you still think this is a bug, please give precise step-by-step instructions to reproduce the issue so that I can investigate the specific case.

Yes, mixed sample rates. I noticed that after my post.
My trial was what I mixed up the project rate and the track one, sorry.
Here is my steps to reproduce, just for information. Underlined ones are the behaviors which don’t seem that the error boundary is between 2 and 3 samples.

  • Preparation
    1. Start Audacity
    2. “Open…” to open a *.wav file of 44100 Hz (both new project and new track are rated 44100 Hz)
    3. In the import method warning, select “Read the files directly from the original (faster)”, then press “OK”
    4. Make sure that “View” > “Toolbars” > “Selection Toolbar” is enabled
    5. On the selection toolbar, select “samples” as time unit and “Start and Length of Selection” as selection type, then input “000,000,002” samples as length (start is 000,000,000 by default)
    6. “Effect” > “Studio Fade Out”
    7. Make sure that “It must be more than 2 samples” error appears
  • 22050 Hz
    1. On the selection toolbar, set “22050” project rate and “000,000,002” length (track rate is still 44100. I had forgotten it)
    2. “Effect” > “Studio Fade Out”
    3. No error appears
    4. On the selection toolbar, set “000,000,001” length
    5. “Effect” > “Studio Fade Out”
    6. “It must be more than 2 samples” error appears (makes sense)
  • 96000 Hz
    1. On the selection toolbar, set “96000” project rate and “000,000,002” length (track rate is still 44100)
    2. “Effect” > “Studio Fade Out”
    3. “It must be more than 2 samples” error appears (makes sense)
    4. On the selection toolbar, set “000,000,005” length
    5. “Effect” > “Studio Fade Out”
    6. “It must be more than 2 samples” error appears
    7. On the selection toolbar, set “000,000,006” length
    8. “Effect” > “Studio Fade Out”
    9. No error appears (makes sense, except selection increases to 7 samples)

Sorry for the delay getting back to you. Those are very clear examples.

Here’s a more simple way to demonstrate the “issue”, and illustrate that it is not specific to Studio Fade Out:

  1. Add a new mono audio track to a new project, sample rate 44100
  2. Change the Project Rate to 96000
  3. In the Selection Toolbar, select 6 samples
  4. Zoom in so that you can see the selection (Ctrl + E)
  5. In the “Nyquist Prompt”, type the following and click OK

You will observe the same behaviour as your “96000 Hz” case, namely that 3 samples are generated in the track, and the Selection Toolbar indicates 7 samples.

Note that Audacity puts the “dot” of the sample at the beginning of the sample period.
If the track highlighting ends before a dot, then that sample IS NOT included in the selection.
If the track highlighting ends after a dot, then that sample IS included in the selection.

Note also that highlighting within a track always snaps to the end of the “sample period” - that is, the shading ends just before the next dot. (Not my preferred method of representation, but sample accurate editing across mixed sample rates is very tricky to achieve, and this scheme works, even though it does sometimes produce peculiar looking rounding effects, as in this case).

So, for 44100 Hz, the “sample periods” are (start = dot position, end = end of selection highlight):

index   start           end
1       0.000000000     0.000022676
2       0.000022676     0.000045351
3       0.000045351     0.000068027
4       0.000068027     0.000090703

and, for 96000 Hz, the “sample periods” are:

index   start           end
6       0.000052083     0.000062500
7       0.000062500     0.000729167

Note that the “dot” of the 3rd sample @ 44100 Hz is less than the end of the selection for 6 samples @ 96000 Hz, but the 4th sample dot @ 44100 Hz is after the end of the 6 samples @ 96000 Hz selection. Therefore, 3 samples @ 44100 Hz is the correct amount of audio for Nyquist to return.

On receiving the audio, Audacity redraws the selection to fit the returned audio.
The end of the 3rd sample period @ 44100 Hz is 0.000068027 s, which comes after the start of the 7th sample period @ 96000 Hz, so the Selection Toolbar (correctly) shows 7 samples @ 96000 Hz.

I haven’t deepened my thought into the sample-level audio, especially the timing of each sample.
Thank you a lot for your very detail explanation, steve.