mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-17 08:30:06 +02:00
Change ";type tool" to not iterate through tracks or selection.
Also adds the options ;type tool ;type tool process ;type tool generator ;type tool analyze These tools will appear in the Tools menu, but behave as their second argument (if any)
This commit is contained in:
parent
1bc0f0f4d0
commit
c21855bbca
@ -103,7 +103,10 @@ class AUDACITY_DLL_API EffectDefinitionInterface /* not final */ : public Ident
|
|||||||
public:
|
public:
|
||||||
virtual ~EffectDefinitionInterface() {};
|
virtual ~EffectDefinitionInterface() {};
|
||||||
|
|
||||||
|
// Type determines how it behaves.
|
||||||
virtual EffectType GetType() = 0;
|
virtual EffectType GetType() = 0;
|
||||||
|
// Classification determines which menu it appears in.
|
||||||
|
virtual EffectType GetClassification() { return GetType();};
|
||||||
|
|
||||||
virtual IdentInterfaceSymbol GetFamilyId() = 0;
|
virtual IdentInterfaceSymbol GetFamilyId() = 0;
|
||||||
|
|
||||||
|
@ -1435,7 +1435,7 @@ const PluginID & PluginManager::RegisterPlugin(ModuleInterface *provider, Effect
|
|||||||
|
|
||||||
plug.SetProviderID(PluginManager::GetID(provider));
|
plug.SetProviderID(PluginManager::GetID(provider));
|
||||||
|
|
||||||
plug.SetEffectType(effect->GetType());
|
plug.SetEffectType(effect->GetClassification());
|
||||||
plug.SetEffectFamilyId(effect->GetFamilyId().Internal());
|
plug.SetEffectFamilyId(effect->GetFamilyId().Internal());
|
||||||
plug.SetEffectInteractive(effect->IsInteractive());
|
plug.SetEffectInteractive(effect->IsInteractive());
|
||||||
plug.SetEffectDefault(effect->IsDefault());
|
plug.SetEffectDefault(effect->IsDefault());
|
||||||
|
@ -3250,7 +3250,11 @@ void EffectUIHost::OnApply(wxCommandEvent & evt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Honor the "select all if none" preference...a little hackish, but whatcha gonna do...
|
// Honor the "select all if none" preference...a little hackish, but whatcha gonna do...
|
||||||
if (!mIsBatch && mEffect && mEffect->GetType() != EffectTypeGenerate && mProject->mViewInfo.selectedRegion.isPoint())
|
if (!mIsBatch &&
|
||||||
|
mEffect &&
|
||||||
|
mEffect->GetType() != EffectTypeGenerate &&
|
||||||
|
mEffect->GetType() != EffectTypeTool &&
|
||||||
|
mProject->mViewInfo.selectedRegion.isPoint())
|
||||||
{
|
{
|
||||||
auto flags = AlwaysEnabledFlag;
|
auto flags = AlwaysEnabledFlag;
|
||||||
bool allowed = mProject->ReportIfActionNotAllowed(
|
bool allowed = mProject->ReportIfActionNotAllowed(
|
||||||
|
@ -149,6 +149,7 @@ NyquistEffect::NyquistEffect(const wxString &fName)
|
|||||||
mStop = false;
|
mStop = false;
|
||||||
mBreak = false;
|
mBreak = false;
|
||||||
mCont = false;
|
mCont = false;
|
||||||
|
mIsTool = false;
|
||||||
|
|
||||||
mMaxLen = NYQ_MAX_LEN;
|
mMaxLen = NYQ_MAX_LEN;
|
||||||
|
|
||||||
@ -167,6 +168,7 @@ NyquistEffect::NyquistEffect(const wxString &fName)
|
|||||||
if (fName == NYQUIST_TOOLS_PROMPT_ID) {
|
if (fName == NYQUIST_TOOLS_PROMPT_ID) {
|
||||||
mName = XO("Nyquist Tools Prompt");
|
mName = XO("Nyquist Tools Prompt");
|
||||||
mType = EffectTypeTool;
|
mType = EffectTypeTool;
|
||||||
|
mIsTool = true;
|
||||||
mPromptName = mName;
|
mPromptName = mName;
|
||||||
mPromptType = mType;
|
mPromptType = mType;
|
||||||
mOK = true;
|
mOK = true;
|
||||||
@ -265,6 +267,13 @@ EffectType NyquistEffect::GetType()
|
|||||||
return mType;
|
return mType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EffectType NyquistEffect::GetClassification()
|
||||||
|
{
|
||||||
|
if (mIsTool)
|
||||||
|
return EffectTypeTool;
|
||||||
|
return mType;
|
||||||
|
}
|
||||||
|
|
||||||
IdentInterfaceSymbol NyquistEffect::GetFamilyId()
|
IdentInterfaceSymbol NyquistEffect::GetFamilyId()
|
||||||
{
|
{
|
||||||
return NYQUISTEFFECTS_FAMILY;
|
return NYQUISTEFFECTS_FAMILY;
|
||||||
@ -584,6 +593,8 @@ bool NyquistEffect::CheckWhetherSkipEffect()
|
|||||||
|
|
||||||
static void RegisterFunctions();
|
static void RegisterFunctions();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool NyquistEffect::Process()
|
bool NyquistEffect::Process()
|
||||||
{
|
{
|
||||||
// Check for reentrant Nyquist commands.
|
// Check for reentrant Nyquist commands.
|
||||||
@ -609,12 +620,7 @@ bool NyquistEffect::Process()
|
|||||||
mProgress->Hide();
|
mProgress->Hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
// We must copy all the tracks, because Paste needs label tracks to ensure
|
|
||||||
// correct sync-lock group behavior when the timeline is affected; then we just want
|
|
||||||
// to operate on the selected wave tracks
|
|
||||||
CopyInputTracks(Track::All);
|
|
||||||
SelectedTrackListOfKindIterator iter(Track::Wave, mOutputTracks.get());
|
|
||||||
mCurTrack[0] = (WaveTrack *) iter.First();
|
|
||||||
mOutputTime = 0;
|
mOutputTime = 0;
|
||||||
mCount = 0;
|
mCount = 0;
|
||||||
mProgressIn = 0;
|
mProgressIn = 0;
|
||||||
@ -765,15 +771,30 @@ bool NyquistEffect::Process()
|
|||||||
mProps += wxString::Format(wxT("(putprop '*SELECTION* %d 'CHANNELS)\n"), mNumSelectedChannels);
|
mProps += wxString::Format(wxT("(putprop '*SELECTION* %d 'CHANNELS)\n"), mNumSelectedChannels);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If in tool mode, then we don't do anything with the track and selection.
|
||||||
|
bool bOnePassTool = (GetType() == EffectTypeTool);
|
||||||
|
|
||||||
|
|
||||||
|
// We must copy all the tracks, because Paste needs label tracks to ensure
|
||||||
|
// correct sync-lock group behavior when the timeline is affected; then we just want
|
||||||
|
// to operate on the selected wave tracks
|
||||||
|
if( !bOnePassTool )
|
||||||
|
CopyInputTracks(Track::All);
|
||||||
|
SelectedTrackListOfKindIterator iter(Track::Wave, mOutputTracks.get());
|
||||||
|
mCurTrack[0] = (WaveTrack *)iter.First();
|
||||||
|
|
||||||
// Keep track of whether the current track is first selected in its sync-lock group
|
// Keep track of whether the current track is first selected in its sync-lock group
|
||||||
// (we have no idea what the length of the returned audio will be, so we have
|
// (we have no idea what the length of the returned audio will be, so we have
|
||||||
// to handle sync-lock group behavior the "old" way).
|
// to handle sync-lock group behavior the "old" way).
|
||||||
mFirstInGroup = true;
|
mFirstInGroup = true;
|
||||||
Track *gtLast = NULL;
|
Track *gtLast = NULL;
|
||||||
|
|
||||||
while (mCurTrack[0]) {
|
while (mCurTrack[0] || bOnePassTool) {
|
||||||
mCurNumChannels = 1;
|
mCurNumChannels = 1;
|
||||||
if (mT1 >= mT0) {
|
if ((mT1 >= mT0)||bOnePassTool) {
|
||||||
|
if (bOnePassTool) {
|
||||||
|
|
||||||
|
} else {
|
||||||
if (mCurTrack[0]->GetLinked()) {
|
if (mCurTrack[0]->GetLinked()) {
|
||||||
mCurNumChannels = 2;
|
mCurNumChannels = 2;
|
||||||
|
|
||||||
@ -810,7 +831,7 @@ _("Selection too long for Nyquist code.\nMaximum allowed selection is %ld sample
|
|||||||
}
|
}
|
||||||
|
|
||||||
mCurLen = std::min(mCurLen, mMaxLen);
|
mCurLen = std::min(mCurLen, mMaxLen);
|
||||||
|
}
|
||||||
mProgressIn = 0.0;
|
mProgressIn = 0.0;
|
||||||
mProgressOut = 0.0;
|
mProgressOut = 0.0;
|
||||||
|
|
||||||
@ -879,7 +900,7 @@ _("Selection too long for Nyquist code.\nMaximum allowed selection is %ld sample
|
|||||||
// Reset previous locale
|
// Reset previous locale
|
||||||
wxSetlocale(LC_NUMERIC, prevlocale);
|
wxSetlocale(LC_NUMERIC, prevlocale);
|
||||||
|
|
||||||
if (!success) {
|
if (!success || bOnePassTool) {
|
||||||
goto finish;
|
goto finish;
|
||||||
}
|
}
|
||||||
mProgressTot += mProgressIn + mProgressOut;
|
mProgressTot += mProgressIn + mProgressOut;
|
||||||
@ -908,7 +929,7 @@ finish:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Has rug been pulled from under us by some effect done within Nyquist??
|
// Has rug been pulled from under us by some effect done within Nyquist??
|
||||||
if( nEffectsSoFar == nEffectsDone )
|
if( !bOnePassTool && ( nEffectsSoFar == nEffectsDone ))
|
||||||
ReplaceProcessedTracks(success);
|
ReplaceProcessedTracks(success);
|
||||||
else{
|
else{
|
||||||
ReplaceProcessedTracks(false); // Do not use the results.
|
ReplaceProcessedTracks(false); // Do not use the results.
|
||||||
@ -1006,7 +1027,11 @@ bool NyquistEffect::ProcessOne()
|
|||||||
wxString cmd;
|
wxString cmd;
|
||||||
cmd += wxT("(snd-set-latency 0.1)");
|
cmd += wxT("(snd-set-latency 0.1)");
|
||||||
|
|
||||||
if (mVersion >= 4) {
|
// A tool may be using AUD-DO which will potentially invalidate *TRACK*
|
||||||
|
// so tools do not get *TRACK*.
|
||||||
|
if (GetType() == EffectTypeTool)
|
||||||
|
; // No Track.
|
||||||
|
else if (mVersion >= 4) {
|
||||||
nyx_set_audio_name("*TRACK*");
|
nyx_set_audio_name("*TRACK*");
|
||||||
cmd += wxT("(setf S 0.25)\n");
|
cmd += wxT("(setf S 0.25)\n");
|
||||||
}
|
}
|
||||||
@ -1015,7 +1040,7 @@ bool NyquistEffect::ProcessOne()
|
|||||||
cmd += wxT("(setf *TRACK* '*unbound*)\n");
|
cmd += wxT("(setf *TRACK* '*unbound*)\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mVersion >= 4) {
|
if( (mVersion >= 4) && (GetType() != EffectTypeTool) ) {
|
||||||
cmd += mProps;
|
cmd += mProps;
|
||||||
cmd += mPerTrackProps;
|
cmd += mPerTrackProps;
|
||||||
|
|
||||||
@ -1166,7 +1191,11 @@ bool NyquistEffect::ProcessOne()
|
|||||||
cmd += wxString::Format(wxT("(putprop '*SELECTION* %s 'RMS)\n"), rmsString);
|
cmd += wxString::Format(wxT("(putprop '*SELECTION* %s 'RMS)\n"), rmsString);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GetType() == EffectTypeGenerate) {
|
// If in tool mode, then we don't do anything with the track and selection.
|
||||||
|
if (GetType() == EffectTypeTool) {
|
||||||
|
nyx_set_audio_params(44100, 0);
|
||||||
|
}
|
||||||
|
else if (GetType() == EffectTypeGenerate) {
|
||||||
nyx_set_audio_params(mCurTrack[0]->GetRate(), 0);
|
nyx_set_audio_params(mCurTrack[0]->GetRate(), 0);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -1327,7 +1356,7 @@ bool NyquistEffect::ProcessOne()
|
|||||||
|
|
||||||
// True if not process type.
|
// True if not process type.
|
||||||
// If not returning audio from process effect,
|
// If not returning audio from process effect,
|
||||||
// return first reult then stop (disables preview)
|
// return first result then stop (disables preview)
|
||||||
// but allow all output from Nyquist Prompt.
|
// but allow all output from Nyquist Prompt.
|
||||||
return (GetType() != EffectTypeProcess || mIsPrompt);
|
return (GetType() != EffectTypeProcess || mIsPrompt);
|
||||||
}
|
}
|
||||||
@ -1747,18 +1776,32 @@ bool NyquistEffect::Parse(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (len >= 2 && tokens[0] == wxT("type")) {
|
if (len >= 2 && tokens[0] == wxT("type")) {
|
||||||
if (tokens[1] == wxT("process")) {
|
wxString tok = tokens[1];
|
||||||
|
mIsTool = false;
|
||||||
|
if (tok == wxT("tool")) {
|
||||||
|
mIsTool = true;
|
||||||
|
mType = EffectTypeTool;
|
||||||
|
// we allow
|
||||||
|
// ;type tool
|
||||||
|
// ;type tool process
|
||||||
|
// ;type tool generate
|
||||||
|
// ;type tool analyze
|
||||||
|
// The last three are placed in the tool menu, but are processed as
|
||||||
|
// process, generate or analyze.
|
||||||
|
if (len >= 3)
|
||||||
|
tok = tokens[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tok == wxT("process")) {
|
||||||
mType = EffectTypeProcess;
|
mType = EffectTypeProcess;
|
||||||
}
|
}
|
||||||
else if (tokens[1] == wxT("generate")) {
|
else if (tok == wxT("generate")) {
|
||||||
mType = EffectTypeGenerate;
|
mType = EffectTypeGenerate;
|
||||||
}
|
}
|
||||||
else if (tokens[1] == wxT("analyze")) {
|
else if (tok == wxT("analyze")) {
|
||||||
mType = EffectTypeAnalyze;
|
mType = EffectTypeAnalyze;
|
||||||
}
|
}
|
||||||
else if (tokens[1] == wxT("tool")) {
|
|
||||||
mType = EffectTypeTool;
|
|
||||||
}
|
|
||||||
if (len >= 3 && tokens[2] == wxT("spectral")) {;
|
if (len >= 3 && tokens[2] == wxT("spectral")) {;
|
||||||
mIsSpectral = true;
|
mIsSpectral = true;
|
||||||
}
|
}
|
||||||
|
@ -99,6 +99,7 @@ public:
|
|||||||
// EffectDefinitionInterface implementation
|
// EffectDefinitionInterface implementation
|
||||||
|
|
||||||
EffectType GetType() override;
|
EffectType GetType() override;
|
||||||
|
EffectType GetClassification() override;
|
||||||
IdentInterfaceSymbol GetFamilyId() override;
|
IdentInterfaceSymbol GetFamilyId() override;
|
||||||
bool IsInteractive() override;
|
bool IsInteractive() override;
|
||||||
bool IsDefault() override;
|
bool IsDefault() override;
|
||||||
@ -120,7 +121,6 @@ public:
|
|||||||
bool TransferDataFromWindow() override;
|
bool TransferDataFromWindow() override;
|
||||||
|
|
||||||
// NyquistEffect implementation
|
// NyquistEffect implementation
|
||||||
|
|
||||||
// For Nyquist Workbench support
|
// For Nyquist Workbench support
|
||||||
void RedirectOutput();
|
void RedirectOutput();
|
||||||
void SetCommand(const wxString &cmd);
|
void SetCommand(const wxString &cmd);
|
||||||
@ -219,6 +219,7 @@ private:
|
|||||||
bool mIsSal;
|
bool mIsSal;
|
||||||
bool mExternal;
|
bool mExternal;
|
||||||
bool mIsSpectral;
|
bool mIsSpectral;
|
||||||
|
bool mIsTool;
|
||||||
/** True if the code to execute is obtained interactively from the user via
|
/** True if the code to execute is obtained interactively from the user via
|
||||||
* the "Nyquist Effect Prompt", or "Nyquist Tools Prompt", false for all other effects (lisp code read from
|
* the "Nyquist Effect Prompt", or "Nyquist Tools Prompt", false for all other effects (lisp code read from
|
||||||
* files)
|
* files)
|
||||||
@ -242,7 +243,7 @@ private:
|
|||||||
wxString mHelpFile;
|
wxString mHelpFile;
|
||||||
bool mHelpFileExists;
|
bool mHelpFileExists;
|
||||||
EffectType mType;
|
EffectType mType;
|
||||||
EffectType mPromptType; // If a prompt, need ot remember original type.
|
EffectType mPromptType; // If a prompt, need to remember original type.
|
||||||
|
|
||||||
bool mEnablePreview;
|
bool mEnablePreview;
|
||||||
bool mDebugButton; // Set to false to disable Debug button.
|
bool mDebugButton; // Set to false to disable Debug button.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user