mirror of
https://github.com/cookiengineer/audacity
synced 2025-11-08 14:13:57 +01:00
Limit selection length for Nyquist plug-ins
This can improve progress count for Nyquist effects that do not process all of selection (bug 558) and provides some protection against 2^31 overflow issues (bug 439).
This commit is contained in:
@@ -79,6 +79,9 @@ enum
|
||||
ID_Choice = 13000
|
||||
};
|
||||
|
||||
// Protect Nyquist from selections greater than 2^31 samples (bug 439)
|
||||
#define NYQ_MAX_LEN ((sampleCount) 2147483647)
|
||||
|
||||
#define UNINITIALIZED_CONTROL ((double)99999999.99)
|
||||
|
||||
static const wxChar *KEY_Version = XO("Version");
|
||||
@@ -130,6 +133,8 @@ NyquistEffect::NyquistEffect(wxString fName)
|
||||
mBreak = false;
|
||||
mCont = false;
|
||||
|
||||
mMaxLen = NYQ_MAX_LEN;
|
||||
|
||||
// Interactive Nyquist
|
||||
if (fName == NYQUIST_PROMPT_ID)
|
||||
{
|
||||
@@ -379,6 +384,7 @@ bool NyquistEffect::Init()
|
||||
{
|
||||
SaveUserPreset(GetCurrentSettingsGroup());
|
||||
|
||||
mMaxLen = NYQ_MAX_LEN;
|
||||
ParseFile();
|
||||
mFileModified = mFileName.GetModificationTime();
|
||||
|
||||
@@ -577,6 +583,14 @@ bool NyquistEffect::Process()
|
||||
sampleCount end = mCurTrack[0]->TimeToLongSamples(mT1);
|
||||
mCurLen = (sampleCount)(end - mCurStart[0]);
|
||||
|
||||
if (mCurLen > NYQ_MAX_LEN) {
|
||||
wxMessageBox(_("Selection too long for Nyquist code.\nMaximum allowed selection is 2147483647 samples\n(about 13.5 hours at 44100 Hz sample rate)."),
|
||||
_("Nyquist Error"), wxOK | wxCENTRE);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mCurLen > mMaxLen) mCurLen = mMaxLen;
|
||||
|
||||
mProgressIn = 0.0;
|
||||
mProgressOut = 0.0;
|
||||
|
||||
@@ -1401,6 +1415,14 @@ void NyquistEffect::Parse(wxString line)
|
||||
return;
|
||||
}
|
||||
|
||||
// Maximum number of samples to be processed. This can help the
|
||||
// progress bar if effect does not process all of selection.
|
||||
if (len >= 2 && tokens[0] == wxT("maxlen")) {
|
||||
long long v; // Note that Nyquist may overflow at > 2^31 samples (bug 439)
|
||||
tokens[1].ToLongLong(&v);
|
||||
mMaxLen = (sampleCount) v;
|
||||
}
|
||||
|
||||
#if defined(EXPERIMENTAL_NYQUIST_SPLIT_CONTROL)
|
||||
if (len >= 2 && tokens[0] == wxT("mergeclips")) {
|
||||
long v;
|
||||
|
||||
@@ -205,6 +205,7 @@ private:
|
||||
WaveTrack *mCurTrack[2];
|
||||
sampleCount mCurStart[2];
|
||||
sampleCount mCurLen;
|
||||
sampleCount mMaxLen;
|
||||
int mTrackIndex;
|
||||
bool mFirstInGroup;
|
||||
double mOutputTime;
|
||||
|
||||
Reference in New Issue
Block a user