Browse Source

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).
darkaudacity
Steve Daulton 7 years ago
parent
commit
7ee8032f3c
  1. 3
      plug-ins/sample-data-export.ny
  2. 22
      src/effects/nyquist/Nyquist.cpp
  3. 1
      src/effects/nyquist/Nyquist.h

3
plug-ins/sample-data-export.ny

@ -3,6 +3,7 @@
;type analyze
;name "Sample Data Export..."
;action "Analyzing..."
;maxlen 1000001
;categories "http://lv2plug.in/ns/lv2core#AnalyserPlugin"
;author "Steve Daulton"
;copyright "Released under terms of the GNU General Public License version 2"
@ -90,7 +91,7 @@
(if (< number 1)
(add-error "No samples selected."))
(if (> number 1000000)
(add-error "Too many samples selected.\nSet limit to less than 1 million"))
(add-error "Cannot export more than 1 million samples."))
(setq number (truncate number)))

22
src/effects/nyquist/Nyquist.cpp

@ -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;

1
src/effects/nyquist/Nyquist.h

@ -205,6 +205,7 @@ private:
WaveTrack *mCurTrack[2];
sampleCount mCurStart[2];
sampleCount mCurLen;
sampleCount mMaxLen;
int mTrackIndex;
bool mFirstInGroup;
double mOutputTime;

Loading…
Cancel
Save