1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-11-08 22:23:59 +01:00

add support for Nyquist effects in Chains, written by Leyland and Martyn based on an idea by Edgar

This commit is contained in:
richardash1981
2012-05-26 20:25:13 +00:00
parent 15fb587eb1
commit 627f4dd757
5 changed files with 111 additions and 12 deletions

View File

@@ -108,7 +108,14 @@ class AUDACITY_DLL_API Effect {
return mFlags;
}
virtual bool TransferParameters( Shuttle & shuttle ){
// Return true if the effect supports processing via batch chains.
virtual bool SupportsChains() {
// All builtin effect support chains (???)
return (mFlags & BUILTIN_EFFECT) != 0;
}
// Called to set or retrieve parameter values. Return true if successful.
virtual bool TransferParameters( Shuttle & shuttle ) {
return true;
}

View File

@@ -85,6 +85,11 @@ EffectNyquist::EffectNyquist(wxString fName)
mBreak = false;
mCont = false;
if (!SetXlispPath()) {
wxLogWarning(wxT("Critical Nyquist files could not be found. Nyquist effects will not work."));
return;
}
if (fName == wxT("")) {
// Interactive Nyquist
mOK = true;
@@ -418,12 +423,84 @@ bool EffectNyquist::SetXlispPath()
return ::wxFileExists(fname);
}
bool EffectNyquist::PromptUser()
bool EffectNyquist::SupportsChains()
{
if (!SetXlispPath()) {
return false;
return (GetEffectFlags() & PROCESS_EFFECT) != 0;
}
bool EffectNyquist::TransferParameters( Shuttle & shuttle )
{
for (size_t i = 0; i < mControls.GetCount(); i++) {
NyqControl *ctrl = &mControls[i];
double d = ctrl->val;
bool good = false;
if (d == UNINITIALIZED_CONTROL) {
if (ctrl->type != NYQ_CTRL_STRING) {
if (!shuttle.mbStoreInClient) {
d = GetCtrlValue(ctrl->valStr);
}
}
}
if (ctrl->type == NYQ_CTRL_REAL) {
good = shuttle.TransferDouble(ctrl->var, d, 0.0);
}
else if (ctrl->type == NYQ_CTRL_INT) {
int val = (int) d;
good = shuttle.TransferInt(ctrl->var, val, 0);
d = (double) val;
}
else if (ctrl->type == NYQ_CTRL_CHOICE) {
//str is coma separated labels for each choice
wxString str = ctrl->label;
wxArrayString choices;
while (1) {
int ci = str.Find( ',' ); //coma index
if (ci == -1) {
choices.Add( str );
break;
}
else {
choices.Add(str.Left(ci));
}
str = str.Right(str.length() - ci - 1);
}
int cnt = choices.GetCount();
if (choices.GetCount() > 0) {
wxString *array = NULL;
array = new wxString[cnt];
for (int j = 0; j < cnt; j++ ) {
array[j] = choices[j];
}
int val = (int) d;
good = shuttle.TransferEnum(ctrl->var, val, cnt, array);
d = (double) val;
delete [] array;
}
}
else if (ctrl->type == NYQ_CTRL_STRING) {
good = shuttle.TransferString(ctrl->var, ctrl->valStr, wxEmptyString);
}
if (ctrl->type != NYQ_CTRL_STRING) {
if (shuttle.mbStoreInClient && good) {
ctrl->val = d;
}
}
}
return true;
}
bool EffectNyquist::PromptUser()
{
if (mInteractive) {
NyquistInputDialog dlog(wxGetTopLevelParent(NULL), -1,
_("Nyquist Prompt"),

View File

@@ -111,11 +111,15 @@ class AUDACITY_DLL_API EffectNyquist:public Effect
virtual wxString GetEffectAction() {
return mAction;
}
virtual bool PromptUser();
virtual bool Process();
// Batch chain support
virtual bool SupportsChains();
virtual bool TransferParameters( Shuttle & shuttle );
private:
static wxString NyquistToWxString(const char *nyqString);