New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nyquist effects overflow at > 2^31 samples #1607
Comments
@SteveDaulton are you going to remove the NYQ_MAX_LEN restriction or can this be closed? |
It looks like Paul-Licameli has already done that here: Perhaps you could ask him to update the code comments around that change, and if he thinks it appropriate, perhaps
could be removed and (optionally) replaced with a simple assert: |
Paul changed it to be |
On Windows |
But you know, when long is not long enough you can always use long long, which can be longer than long |
judging by #1734 (comment) it seems like increasing the limit won't do much anyway as long as nyquist is limited to 2GB |
Indeed. According to https://en.cppreference.com/w/cpp/types/climits |
Nyquist can process audio tracks that far exceed 2 GB. The 2 GB limit only applies to scripts that hold the entire track in RAM. Whenever possible, Nyquist programmers should ensure that samples are released as they are processed. There are some cases where that is not possible, which is why mMaxLen is still required. |
Well, Windows is the most popular OS even if mobile OSes are considered. I think there is a long fun story of Microsoft porting WinAPI to x64 which we will never know :-) https://en.wikipedia.org/wiki/64-bit_computing#64-bit_data_models This was fixed in C99 (which MS never really supported) and C++11 using the intn_t notion |
@crsib, would changing |
I'm not very familiar with Nyquist API. It is safe to assume that |
Nyquist itself should be good up to about 2^58 samples (about 200 centuries @ 44100 Hz ?) without sample count overflow, which is big enough that we can safely leave it up to Nyquist's error checking. Nyquist now has checks built in to prevent excessive amounts of audio data being held in RAM (such as "MAX-AUDIO-MEM", which has a default of around 1 billion samples). Normally our NYQ_MAX_LEN limit should just keep out of the way and let Nyquist do its thing. mMax should be initialised to a big enough value that it keeps out of the way unless a plug-in specifically needs to limit the number of samples to a smaller value, which it can do via the ;maxlen header. I think pull request #3051 does what is required. |
If the template argument of numeric_limits is changed, make it one of: https://en.cppreference.com/w/cpp/types/integer |
If you don't like my fix Paul, feel free to modify it. |
As you guys now know what needs to be done, please fix it. Thank you. |
I was just agreeing with @crsib that modern C++ standardizes names for numerical types of really specific bit widths, unlike old types like So if the intention is 64 bits, better to say The link I gave says those typedefs are optional actually, but I'm sure we can use them on all the compilers that matter. |
What's the problem? |
Following up on a forum user's post: Any chance that this will be fixed in Audacity 3.2.0? |
Any chance this will be fixed for 3.4.0? |
The "Label Sounds" and "Noise Gate" effects are still limited to 2^31 samples. This is fixed in #4494 |
Describe the bug
Nyquist effects may not work if used on extremely long selections''' containing more than 2^31 samples (just over 13.5 hours at 44100 Hz).
Originally logged on Bugzilla as P3 439 in 2011
To Reproduce
Steps to reproduce the behavior:
Example 1.
Make a selection of 14 hours duration at 441000 Hz and enter either of the following commands into the Nyquist Prompt:
(get-duration 1)
(print len)
Example 2.
Generate 14 hours of silence at 44.1 kHz then run
(s-max s (const 0.5))
Example 3.
Just run delay.ny on a 14 hour 44100 Hz tone.
Example 4.
Evaluate (snd-play (s-rest (* 15 60 60))). SND-PLAY doesn't actually play anything; it's there for benchmarking audio computation and all it does is retrieve and discard samples, so it's much faster than writing samples to disk. This expression crashes Nyquist directly.
Expected behavior
Nyquist effects should work if used on extremely long selections.
Screenshots
Additional information (please complete the following information):
Additional context
Roger wrote on Bugzilla
I think the problem here is internal to Nyquist. Does anyone actually apply effects to 14+ hours of 44.1K audio, or is this just a what-if scenario? An ideal fix would probably be to bump the sample counts to 64 bits in Nyquist, but I think the most practical thing is to compute when overflow is going to occur and just stop and raise an error in Nyquist to avoid crashing. I will look at this on the Nyquist (upstream) side.
Steve replied
Steve later wrote in Feb21
See the Bugzilla bugthred for further discussion:
https://bugzilla.audacityteam.org/show_bug.cgi?id=439
The text was updated successfully, but these errors were encountered: