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

Audacity Bugzilla



Bug 1278 - Spectral edit parametric EQ gives incorrect results if frequency content of track exceeds Nyquist frequency.
Spectral edit parametric EQ gives incorrect results if frequency content of t...
Status: RESOLVED FIXED
Product: Audacity
Classification: Unclassified
Component: Built-in FX
2.1.2
Per OS All
: P4 Repeatable
Assigned To: Default Assignee for New Bugs
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2015-12-13 16:35 UTC by Gale Andrews
Modified: 2018-08-20 11:51 UTC (History)
8 users (show)

See Also:
Steps To Reproduce:
1) Create a new project with two audio tracks. 1 track with a sample rate of 44100 Hz and one track with a sample rate of 8000 Hz. (project rate does not matter). 2) Generate white noise into both tracks. 3) Change to a "Spectral" view, enable spectral selection in both tracks and select all (Ctrl+A) 4) With the Spectral Selection toolbar, select Centre frequency 3000 Hz, Width 3 octaves. 5) Apply "Spectral Edit Parametric Eq" with Gain set to -24 dB. 6) Use Plot Spectrum to examine each of the tracks, As expected, the notch in the 44100 Hz track is at 3 kHz, but the notch in the 8000 Hz track is at 2 kHz.
Release Note:
First Git SHA:
Group: ---
Workaround:
Closed: 2018-08-20 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Gale Andrews 2015-12-13 16:35:42 UTC
So on my testing, Spectral edit multi tool is not affected. Maybe P4 would do for this. 

Has Spectral edit shelves been tested?   

If there is only one track present, but the project rate is set above the rate of that track, should Spectral Selection Toolbar be allowed to set frequencies above the Nyquist frequency for the track? I don't see why, given you can't do that with a mouse.
Comment 1 Steve Daulton 2015-12-16 22:01:32 UTC
(In reply to Gale Andrews from comment #0)
The fix for bug 1275 prevents this from happening.

In your steps to reproduce, the lower and upper frequency bounds are 1060.66 Hz and 8485.28 Hz respectively. The high frequency bound is too high for the 8000 Hz sample rate track. The fixed version gives an error message:

"Error.
Frequency selection is too high for track sample rate.
For the current track, the high frequency setting cannot
be greater than 4000 Hz"

Spectral edit shelves still has it's earlier validation for "over Nyquist" frequencies, but I now see that it does not work properly. If you're happy with the "fixed" version of Spectral edit parametric EQ, I can apply a similar fix to Spectral edit shelves.
Comment 2 Steve Daulton 2015-12-16 22:53:52 UTC
(In reply to Steve Daulton from comment #1)
On second thoughts, I think that a better way to fix Spectral edit shelves is to treat invalid frequencies as "undefined". However, I've noticed that there is another bug in the Audacity code that blocks doing this.
Comment 3 Steve Daulton 2015-12-17 04:23:56 UTC
(In reply to Steve Daulton from comment #2)
New patch made for bug 1275.

The valid frequency range for shelf filters is between (excluding) 0 Hz and the Nyquist frequency. If frequencies are defined beyond the valid range, the "spectral edit shelf" effect treats them as "undefined".
Comment 4 Gale Andrews 2015-12-27 17:27:14 UTC
(In reply to Steve Daulton from comment #3)
Is this supposed to be DEVEL - FIX MADE given there is some connection made to bug 1275? 

> The valid frequency range for shelf filters is between (excluding) 0 Hz and the 
> Nyquist frequency. If frequencies are defined beyond the valid range, the 
> "spectral edit shelf" effect treats them as "undefined"  

As of "r6663f40" there are apparent no-ops being processed in Spectral edit shelves e.g. 0 Hz to Nyquist Freq or 0 Hz to undefined produces a result that (by inversion) is identical to audio before processing.  The above two cases would show "Please select frequencies" in 2.1.2 RC1.
Comment 5 Gale Andrews 2015-12-27 18:15:19 UTC
(In reply to Gale Andrews from comment #4)
> As of "r6663f40" there are apparent no-ops being processed in Spectral edit 
> shelves e.g. 0 Hz to Nyquist Freq or 0 Hz to undefined produces a result that 
> (by inversion) is identical to audio before processing.  The above two cases 
> would show "Please select frequencies" in 2.1.2 RC1.
I was deceived by their being in the Undo Stack. They are not processed, but should not be in the Undo Stack. Even if removed from the Undo Stack, it seems clearer to me to show an error as we used to. 

The Manual entries for spectral edit shelves are affected by whatever we decide.
Comment 6 Gale Andrews 2015-12-27 18:30:33 UTC
I suppose someone will tell me that Change Pitch/Speed/Tempo can do nothing (0% change) but are still in the Undo Stack. 

So we are consistent, but I don't like that either. I think the current behaviour in Spectral edit effects is especially confusing for users who may not be clear whether the change was meant to do "something".
Comment 7 Steve Daulton 2015-12-27 20:51:42 UTC
(In reply to Gale Andrews from comment #4)
> As of "r6663f40" there are apparent no-ops being processed in Spectral edit
> shelves e.g. 0 Hz to Nyquist Freq or 0 Hz to undefined produces a result
> that (by inversion) is identical to audio before processing.
> The above two cases would show "Please select frequencies" in 2.1.2 RC1.

The effect treats 0 Hz the same as "undefined" lower frequency and treats Nyquist or above as "undefined " high frequency. It is virtually impossible to set "0 Hz" by accident (the mouse snaps to "undefined", but the upper frequency could be "invalid" if one track has a low sample rate and the upper frequency is greater than the Nyquist frequency for that track.

If the user is doing batch processing, the low frequency could be vali for all tracks, but upper frequency may be defined and valid for all but one track (if the tracks have different sample rate). is it more useful to stop the batch processing with and error, or to treat that one track as a high shelf filter with no low shelf filter?
Comment 8 Gale Andrews 2015-12-28 08:43:20 UTC
Moved to DEVEL - FIX MADE (steps to reproduce have been fixed).
Comment 9 Gale Andrews 2015-12-28 09:26:37 UTC
(In reply to Steve Daulton from comment #7)
Selecting a track with low frequency undefined and high frequency above Nyquist (e.g. if you had tracks at different rates but selected the lower rate track by mistake) now appears to process (given the item is in the Undo Stack), but of course actually does nothing. In 2.1.2 RC1 there was a (not very good) error message, but the user would realise they selected the wrong track. As you suggest, this case is easy to do by accident.

We have been discussing on the Forum that actions that do not change the project state should not be in the Undo Stack. I think low frequency undefined, high above Nyquist should error if applied to a single track, as it used to, and so should 0 Hz to Nyquist Frequency or 0 Hz to undefined.  

You could argue these should not error if applied to multiple tracks, if some  change in state was made to justify being in the Undo Stack.   

> If the user is doing batch processing, the low frequency could be valid for all 
> tracks, but upper frequency may be defined and valid for all but one track (if 
> the tracks have different sample rate). is it more useful to stop the batch 
> processing with and error, or to treat that one track as a high shelf filter 
> with no low shelf filter?
That scenario does not error in 2.1.2 RC1, so (AFAIK) is not an improvement in "r6663f40"?
Comment 10 Peter Sampson 2016-02-18 10:49:21 UTC
Testing on Mac El Capitan on 01a95c5-2.1.3-alpha-13-feb-16
and
Testing on W10 on audacity-win-r4d154c4-2.1.3-alpha-18-feb-16


On both platforms using the Steps to reproduce I can apply the parametric EQ effect to the tp track the 44,100 Hz one - but the bottom one the 8,000 Hz one gives an error:

Nyquist error: Frequency selection is too high for track sample rate.
For the current track, the high frequency setting 
cannot
be greater than 4000 Hz

(spacing/line-breaks as in the actual error message (could be tidier)
Comment 11 Peter Sampson 2016-02-18 10:51:46 UTC
Sorry, that was the error message spacing on Mac El Capitan - on Windows 10 the message look better formed.
Comment 12 Peter Sampson 2017-11-08 09:13:32 UTC
I still get the same error message at Step 5 on both W10 and macOS10.13.1


Which I presume makes Step 6 invalid.

Can someone please clarify?
Comment 13 Steve Daulton 2017-11-08 16:05:36 UTC
As in comment 8, the bug as described is fixed (the incorrect result in step 6 does not occur).

Comment 9 seems to be discussion about possible enhancements (not directly about this bug), so closing this as resolved fixed.