1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-05-05 14:18:53 +02:00

Add help button support for other Nyquist effects

This commit is contained in:
Steve Daulton 2017-05-21 23:11:21 +01:00
parent 99e5516ee2
commit 04ba10a1c3
3 changed files with 42 additions and 14 deletions

View File

@ -3072,6 +3072,9 @@ bool EffectUIHost::Initialize()
this->SetAcceleratorTable(accel);
}
if (mEffect->mUIDebug) {
buttons += eDebugButton;
}
buttonPanel->SetSizer(CreateStdButtonSizer(buttonPanel, buttons, bar).release());
vs->Add(buttonPanel, 0, wxEXPAND);
@ -3240,7 +3243,6 @@ void EffectUIHost::OnHelp(wxCommandEvent & WXUNUSED(event))
}
else {
// otherwise use the new ShowHelpDialog
wxLogDebug(mEffect->ManualPage());
HelpSystem::ShowHelpDialog(FindWindow(wxID_HELP), mEffect->ManualPage(), true);
}
}

View File

@ -136,6 +136,8 @@ NyquistEffect::NyquistEffect(const wxString &fName)
mRestoreSplits = true; // Default: Restore split lines.
mMergeClips = -1; // Default (auto): Merge if length remains unchanged.
mEnableDebug = true; // Debug button enabled by default.
mVersion = 4;
mStop = false;
@ -221,9 +223,17 @@ wxString NyquistEffect::ManualPage()
wxString NyquistEffect::HelpPage()
{
// TODO: Get the full path for the help page
// Return empty string and give debug info if it does not exist
return mHelpFile;
wxArrayString paths = NyquistEffect::GetNyquistSearchPath();
wxString fileName;
for (size_t i = 0, cnt = paths.GetCount(); i < cnt; i++) {
fileName = wxFileName(paths[i] + wxT("/") + mHelpFile).GetFullPath();
if (wxFileExists(fileName)) {
mHelpFileExists = true;
return fileName;
}
}
return wxEmptyString;
}
// EffectIdentInterface implementation
@ -379,7 +389,7 @@ bool NyquistEffect::SetAutomationParameters(EffectAutomationParameters & parms)
}
else if (ctrl.type == NYQ_CTRL_CHOICE)
{
int val;
int val {0};
wxArrayString choices = ParseChoice(ctrl);
parms.ReadEnum(ctrl.var, &val, choices);
ctrl.val = (double) val;
@ -399,8 +409,10 @@ bool NyquistEffect::Init()
{
// EffectType may not be defined in script, so
// reset each time we call the Nyquist Prompt.
if (mIsPrompt)
if (mIsPrompt) {
mType = EffectTypeProcess;
mEnableDebug = true; // Debug button always enabled for Nyquist Prompt.
}
// As of Audacity 2.1.2 rc1, 'spectral' effects are allowed only if
// the selected track(s) are in a spectrogram view, and there is at
@ -501,6 +513,9 @@ bool NyquistEffect::Process()
}
mDebugOutput.Clear();
if (!mHelpFile.IsEmpty() && !mHelpFileExists) {
mDebugOutput = wxString::Format(wxT("error: File \"%s\" specified in header but not found in plug-in path.\n"), mHelpFile);
}
if (mVersion >= 4)
{
@ -807,7 +822,7 @@ void NyquistEffect::PopulateOrExchange(ShuttleGui & S)
BuildEffectWindow(S);
}
EnableDebug();
EnableDebug(mEnableDebug);
}
bool NyquistEffect::TransferDataToWindow()
@ -1247,7 +1262,7 @@ bool NyquistEffect::ProcessOne()
std::unique_ptr<WaveTrack> outputTrack[2];
double rate = mCurTrack[0]->GetRate();
for (size_t i = 0; i < outChannels; i++) {
for (int i = 0; i < outChannels; i++) {
sampleFormat format = mCurTrack[i]->GetSampleFormat();
if (outChannels == (int)mCurNumChannels) {
@ -1283,7 +1298,7 @@ bool NyquistEffect::ProcessOne()
if (!success)
return false;
for (size_t i = 0; i < outChannels; i++) {
for (int i = 0; i < outChannels; i++) {
outputTrack[i]->Flush();
mOutputTime = outputTrack[i]->GetEndTime();
@ -1314,7 +1329,7 @@ bool NyquistEffect::ProcessOne()
else {
mCurTrack[i]->ClearAndPaste(mT0, mT1, out, mRestoreSplits, mMergeClips != 0);
}
// If we were first in the group adjust non-selected group tracks
if (mFirstInGroup) {
SyncLockedTracksIterator git(mOutputTracks.get());
@ -1635,6 +1650,15 @@ void NyquistEffect::Parse(const wxString &line)
return;
}
// TODO: Document.
// Debug button may be disabled for release plug-ins.
if (len >= 2 && tokens[0] == wxT("debug")) {
if (tokens[1] == wxT("disabled") || tokens[1] == wxT("false")) {
mEnableDebug = false;
}
return;
}
if (len >= 6 && tokens[0] == wxT("control")) {
NyqControl ctrl;
@ -1749,6 +1773,7 @@ bool NyquistEffect::ParseProgram(wxInputStream & stream)
mIsSpectral = false;
mManPage = wxEmptyString; // If not wxEmptyString, must be a page in the Audacity manual.
mHelpFile = wxEmptyString; // If not wxEmptyString, must be a valid HTML help file.
mHelpFileExists = false;
mFoundType = false;
while (!stream.Eof() && stream.IsOk())
@ -1791,8 +1816,6 @@ or for LISP, begin with an open parenthesis such as:\n\t(mult *track* 0.1)\n .")
void NyquistEffect::ParseFile()
{
mEnablePreview = true;
wxFileInputStream stream(mFileName.GetFullPath());
ParseProgram(stream);
@ -1830,7 +1853,7 @@ int NyquistEffect::GetCallback(float *buffer, int ch,
mCurBufferStart[ch] = (mCurStart[ch] + start);
mCurBufferLen[ch] = mCurTrack[ch]->GetBestBlockSize(mCurBufferStart[ch]);
if (mCurBufferLen[ch] < len) {
if (mCurBufferLen[ch] < (size_t) len) {
mCurBufferLen[ch] = mCurTrack[ch]->GetIdealBlockSize();
}

View File

@ -199,10 +199,13 @@ private:
wxString mCopyright;
wxString mManPage; // ONLY use if a help page exists in the manual.
wxString mHelpFile;
bool mHelpFileExists;
EffectType mType;
bool mEnablePreview;
bool mDebug;
bool mEnableDebug; // Set to false to disable Debug button.
bool mDebug; // Is true when Debug button clicked.
bool mRedirectOutput;
bool mProjectChanged;
wxString mDebugOutput;