mirror of
https://github.com/cookiengineer/audacity
synced 2026-01-11 23:25:53 +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:
@@ -283,11 +283,13 @@ wxArrayString BatchCommands::GetAllCommands()
|
||||
additionalEffects = 0;
|
||||
#endif // CLEANSPEECH
|
||||
|
||||
effects = EffectManager::Get().GetEffects(PROCESS_EFFECT | BUILTIN_EFFECT | additionalEffects);
|
||||
effects = EffectManager::Get().GetEffects(PROCESS_EFFECT | BUILTIN_EFFECT | PLUGIN_EFFECT | additionalEffects);
|
||||
for(i=0; i<effects->GetCount(); i++) {
|
||||
command=(*effects)[i]->GetEffectIdentifier();
|
||||
if (!command.IsEmpty()) {
|
||||
commands.Add( command);
|
||||
if ((*effects)[i]->SupportsChains()) {
|
||||
command=(*effects)[i]->GetEffectIdentifier();
|
||||
if (!command.IsEmpty()) {
|
||||
commands.Add( command);
|
||||
}
|
||||
}
|
||||
}
|
||||
delete effects;
|
||||
|
||||
@@ -204,10 +204,15 @@ bool Shuttle::TransferEnum( const wxString & Name, int & iValue,
|
||||
iValue = 0;// default index if none other selected.
|
||||
if( ExchangeWithMaster( Name ))
|
||||
{
|
||||
int i;
|
||||
for(i=0;i<nChoices;i++)
|
||||
wxString str = mValueString;
|
||||
if( str.Left( 1 ) == wxT('"') && str.Right( 1 ) == wxT('"') )
|
||||
{
|
||||
if( mValueString.IsSameAs( pFirstStr[i] ))
|
||||
str = str.Mid( 2, str.Length() - 2 );
|
||||
}
|
||||
|
||||
for( int i = 0; i < nChoices; i++ )
|
||||
{
|
||||
if( str.IsSameAs( pFirstStr[i] ))
|
||||
{
|
||||
iValue = i;
|
||||
break;
|
||||
@@ -223,6 +228,10 @@ bool Shuttle::TransferEnum( const wxString & Name, int & iValue,
|
||||
if( iValue < 0 )
|
||||
iValue = 0;
|
||||
mValueString = pFirstStr[iValue];
|
||||
if( mValueString.Find( wxT(' ') ) != wxNOT_FOUND )
|
||||
{
|
||||
mValueString = wxT('"') + pFirstStr[iValue] + wxT('"'); //strings have quotes around them
|
||||
}
|
||||
return ExchangeWithMaster( Name );
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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"),
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user