1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-26 00:58:37 +02:00

Fix bug 2041

Nyquist: Generating audio at a point within a track, deletes audio
after the generated audio.

This fix corrects errors in b9ec434.
This commit is contained in:
Steve Daulton 2018-11-28 18:52:05 +00:00
parent f5443c8859
commit 800ddae34b
4 changed files with 18 additions and 44 deletions

View File

@ -1202,7 +1202,9 @@ bool Effect::DoEffect(wxWindow *parent,
ReplaceProcessedTracks( false ); ReplaceProcessedTracks( false );
} ); } );
if ((GetType() == EffectTypeGenerate) && (mNumTracks == 0) && GetPath() != NYQUIST_EFFECTS_PROMPT_ID) { // We don't yet know the effect type for code in the Nyquist Prompt, so
// assume it requires a track and handle errors when the effect runs.
if ((GetType() == EffectTypeGenerate || GetPath() == NYQUIST_PROMPT_ID) && (mNumTracks == 0)) {
newTrack = static_cast<WaveTrack*>(mTracks->Add(mFactory->NewWaveTrack())); newTrack = static_cast<WaveTrack*>(mTracks->Add(mFactory->NewWaveTrack()));
newTrack->SetSelected(true); newTrack->SetSelected(true);
} }
@ -1218,8 +1220,8 @@ bool Effect::DoEffect(wxWindow *parent,
double quantMT1 = QUANTIZED_TIME(mT1, mProjectRate); double quantMT1 = QUANTIZED_TIME(mT1, mProjectRate);
mDuration = quantMT1 - quantMT0; mDuration = quantMT1 - quantMT0;
isSelection = true; isSelection = true;
mT1 = mT0 + mDuration;
} }
mT1 = mT0 + mDuration;
mDurationFormat = isSelection mDurationFormat = isSelection
? NumericConverter::TimeAndSampleFormat() ? NumericConverter::TimeAndSampleFormat()

View File

@ -175,19 +175,10 @@ bool NyquistEffectsModule::AutoRegisterPlugins(PluginManagerInterface & pm)
wxArrayString files; wxArrayString files;
wxString ignoredErrMsg; wxString ignoredErrMsg;
#if 0 if (!pm.IsPluginRegistered(NYQUIST_PROMPT_ID))
if (!pm.IsPluginRegistered(NYQUIST_EFFECTS_PROMPT_ID))
{ {
// No checking of error ? // No checking of error ?
DiscoverPluginsAtPath(NYQUIST_EFFECTS_PROMPT_ID, ignoredErrMsg, DiscoverPluginsAtPath(NYQUIST_PROMPT_ID, ignoredErrMsg,
PluginManagerInterface::DefaultRegistrationCallback);
}
#endif
if (!pm.IsPluginRegistered(NYQUIST_TOOLS_PROMPT_ID))
{
// No checking of error ?
DiscoverPluginsAtPath(NYQUIST_TOOLS_PROMPT_ID, ignoredErrMsg,
PluginManagerInterface::DefaultRegistrationCallback); PluginManagerInterface::DefaultRegistrationCallback);
} }
@ -215,9 +206,8 @@ wxArrayString NyquistEffectsModule::FindPluginPaths(PluginManagerInterface & pm)
wxArrayString pathList = NyquistEffect::GetNyquistSearchPath(); wxArrayString pathList = NyquistEffect::GetNyquistSearchPath();
wxArrayString files; wxArrayString files;
// Add the Nyquist prompt effect and tool. // Add the Nyquist prompt
//files.Add(NYQUIST_EFFECTS_PROMPT_ID); files.Add(NYQUIST_PROMPT_ID);
files.Add(NYQUIST_TOOLS_PROMPT_ID);
// Load .ny plug-ins // Load .ny plug-ins
pm.FindFilesInPathList(wxT("*.ny"), pathList, files); pm.FindFilesInPathList(wxT("*.ny"), pathList, files);
@ -249,7 +239,7 @@ bool NyquistEffectsModule::IsPluginValid(const wxString & path, bool bFast)
// Ignores bFast parameter, since checking file exists is fast enough for // Ignores bFast parameter, since checking file exists is fast enough for
// the small number of Nyquist plug-ins that we have. // the small number of Nyquist plug-ins that we have.
static_cast<void>(bFast); static_cast<void>(bFast);
if((path == NYQUIST_EFFECTS_PROMPT_ID) || (path == NYQUIST_TOOLS_PROMPT_ID)) if(path == NYQUIST_PROMPT_ID)
return true; return true;
return wxFileName::FileExists(path); return wxFileName::FileExists(path);

View File

@ -156,19 +156,8 @@ NyquistEffect::NyquistEffect(const wxString &fName)
mMaxLen = NYQ_MAX_LEN; mMaxLen = NYQ_MAX_LEN;
// Interactive Nyquist (for effects) // Interactive Nyquist
if (fName == NYQUIST_EFFECTS_PROMPT_ID) { if (fName == NYQUIST_PROMPT_ID) {
mName = XO("Nyquist Effects Prompt");
mType = EffectTypeProcess;
mPromptName = mName;
mPromptType = mType;
mOK = true;
mIsPrompt = true;
return;
}
// Interactive Nyquist (for general tools)
if (fName == NYQUIST_TOOLS_PROMPT_ID) {
mName = XO("Nyquist Prompt"); mName = XO("Nyquist Prompt");
mType = EffectTypeTool; mType = EffectTypeTool;
mIsTool = true; mIsTool = true;
@ -204,9 +193,7 @@ NyquistEffect::~NyquistEffect()
wxString NyquistEffect::GetPath() wxString NyquistEffect::GetPath()
{ {
if (mIsPrompt) if (mIsPrompt)
return (mPromptType == EffectTypeTool) ? return NYQUIST_PROMPT_ID;
NYQUIST_TOOLS_PROMPT_ID :
NYQUIST_EFFECTS_PROMPT_ID;
return mFileName.GetFullPath(); return mFileName.GetFullPath();
} }
@ -214,9 +201,7 @@ wxString NyquistEffect::GetPath()
ComponentInterfaceSymbol NyquistEffect::GetSymbol() ComponentInterfaceSymbol NyquistEffect::GetSymbol()
{ {
if (mIsPrompt) if (mIsPrompt)
return (mPromptType == EffectTypeTool) ? return XO("Nyquist Prompt");
XO("Nyquist Prompt") :
XO("Nyquist Effects Prompt");
return mName; return mName;
} }
@ -1358,12 +1343,11 @@ bool NyquistEffect::ProcessOne()
mDebugOutput = wxString::Format(_("nyx_error returned from %s.\n"), mDebugOutput = wxString::Format(_("nyx_error returned from %s.\n"),
mName.IsEmpty()? _("plug-in") : mName) + mDebugOutput; mName.IsEmpty()? _("plug-in") : mName) + mDebugOutput;
mDebug = true; mDebug = true;
return false;
} }
else { else {
wxLogMessage("Nyquist returned nyx_error:\n%s", mDebugOutput); wxLogMessage("Nyquist returned nyx_error:\n%s", mDebugOutput);
} }
return true; return false;
} }
if (rval == nyx_string) { if (rval == nyx_string) {
@ -1477,7 +1461,7 @@ bool NyquistEffect::ProcessOne()
if (mOutputTime <= 0) { if (mOutputTime <= 0) {
Effect::MessageBox(_("Nyquist returned nil audio.\n")); Effect::MessageBox(_("Nyquist returned nil audio.\n"));
return true; return false;
} }
} }
@ -3207,16 +3191,15 @@ void * nyq_reformat_aud_do_response(const wxString & Str) {
LVAL xlc_aud_do(void) LVAL xlc_aud_do(void)
{ {
// Based on string-trim... // Based on string-trim...
unsigned char *leftp,*rightp; unsigned char *leftp;
LVAL src,dst; LVAL src,dst;
/* get the string */ /* get the string */
src = xlgastring(); src = xlgastring();
xllastarg(); xllastarg();
/* setup the string pointers */ /* setup the string pointer */
leftp = getstring(src); leftp = getstring(src);
rightp = leftp + getslength(src) - 2;
// Go call my real function here... // Go call my real function here...
dst = (LVAL)ExecForLisp( (char *)leftp ); dst = (LVAL)ExecForLisp( (char *)leftp );

View File

@ -34,8 +34,7 @@
name into another alphabet. */ name into another alphabet. */
#define NYQUISTEFFECTS_FAMILY ( ComponentInterfaceSymbol{ XO("Nyquist") } ) #define NYQUISTEFFECTS_FAMILY ( ComponentInterfaceSymbol{ XO("Nyquist") } )
#define NYQUIST_EFFECTS_PROMPT_ID wxT("Nyquist Effects Prompt") #define NYQUIST_PROMPT_ID wxT("Nyquist Prompt")
#define NYQUIST_TOOLS_PROMPT_ID wxT("Nyquist Prompt")
#define NYQUIST_WORKER_ID wxT("Nyquist Worker") #define NYQUIST_WORKER_ID wxT("Nyquist Worker")
enum NyqControlType enum NyqControlType