1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-05-04 09:39:42 +02:00

Simplify and extend automatic screenshotting

Now includes 2 'outlier' analysis effects, and has simpler code.
The tricky capture cases are now first in the list.
Vocorder and Chirp are now included.  Comma was missing between them.
Now gives error report for an unknown command.
This commit is contained in:
James Crook 2017-06-04 16:52:17 +01:00
parent c38efc1fcd
commit ee9649eeb5
5 changed files with 45 additions and 23 deletions

View File

@ -164,6 +164,7 @@ enum {
};
#include "commands/CommandFunctors.h"
#include "commands/ScreenshotCommand.h"
//
// Effects menu arrays
//
@ -6137,6 +6138,8 @@ void AudacityProject::OnPlotSpectrum()
this, -1, _("Frequency Analysis"), where ) );
}
if( ScreenshotCommand::MayCapture( mFreqWindow.get() ) )
return;
mFreqWindow->Show(true);
mFreqWindow->Raise();
mFreqWindow->SetFocus();
@ -6156,6 +6159,8 @@ void AudacityProject::OnContrast()
}
mContrastDialog->CentreOnParent();
if( ScreenshotCommand::MayCapture( mContrastDialog.get() ) )
return;
mContrastDialog->Show();
}

View File

@ -99,6 +99,8 @@ static wxBitmap DoGetAsBitmap(const wxRect *subrect)
}
#endif
// static member variable.
void (*ScreenshotCommand::mIdleHandler)(wxIdleEvent& event) = NULL;
// This static variable is used to get from an idle event to the screenshot
// command that caused the idle event interception to be set up.
ScreenshotCommand * ScreenshotCommand::mpShooter=NULL;
@ -353,6 +355,16 @@ void ScreenshotCommand::CaptureMenus(wxMenuBar*pBar, const wxString &fileName)
#endif
}
// Handed a dialog, which it is given the option to capture.
bool ScreenshotCommand::MayCapture( wxDialog * pDlg )
{
if( mIdleHandler == NULL )
return false;
pDlg->Bind( wxEVT_IDLE, mIdleHandler );
mIdleHandler = NULL;
pDlg->ShowModal();
return true;
}
void ScreenshotCommand::CaptureWindowOnIdle( wxWindow * pWin )
{
@ -397,12 +409,27 @@ void ScreenshotCommand::CaptureEffects( AudacityProject * pProject, const wxStri
mDirToWriteTo = fileName;
mpShooter = this;
#define TRICKY_CAPTURE
#define CAPTURE_NYQUIST_TOO
// Commented out the effects that don't have dialogs.
// Also any problematic ones,
const wxString EffectNames[] = {
#ifdef TRICKY_CAPTURE
//"Contrast...", // renamed
"ContrastAnalyser",
//"Plot Spectrum...", // renamed
"PlotSpectrum",
"Auto Duck...", // needs a track below.
//"Spectral edit multi tool",
"Spectral edit parametric EQ...", // Needs a spectral selection.
"Spectral edit shelves...",
//"Noise Reduction...", // Exits twice...
//"SC4...", //Has 'Close' rather than 'Cancel'.
#endif
"Amplify...",
//"Auto Duck...", // needs a track below.
"Bass and Treble...",
"Change Pitch...",
"Change Speed...",
@ -415,7 +442,6 @@ void ScreenshotCommand::CaptureEffects( AudacityProject * pProject, const wxStri
//"Fade In",
//"Fade Out",
//"Invert",
//"Noise Reduction...", // Exits twice...
"Normalize...",
"Paulstretch...",
"Phaser...",
@ -427,7 +453,6 @@ void ScreenshotCommand::CaptureEffects( AudacityProject * pProject, const wxStri
"Truncate Silence...",
"Wahwah...",
// Sole LADSPA effect...
//"SC4...", //Has 'Close' rather than 'Cancel'.
#ifdef CAPTURE_NYQUIST_TOO
"Adjustable Fade...",
"Clip Fix...",
@ -439,14 +464,11 @@ void ScreenshotCommand::CaptureEffects( AudacityProject * pProject, const wxStri
"Low Pass Filter...",
"Notch Filter...",
"Nyquist Prompt...",
//"Spectral edit multi tool",
//"Spectral edit parametric EQ...", // Needs a spectral selection.
//"Spectral edit shelves...",
//"Studio Fade Out",
"Tremolo...",
"Vocal Reduction and Isolation...",
"Vocal Remover...",
"Vocoder..."
"Vocoder...",
#endif
// Generators.....
"Chirp...",
@ -461,8 +483,6 @@ void ScreenshotCommand::CaptureEffects( AudacityProject * pProject, const wxStri
"Sample Data Import...",
#endif
// Analyzers...
"Contrast...",
"Plot Spectrum...",
"Find Clipping...",
#ifdef CAPTURE_NYQUIST_TOO
"Beat Finder...",
@ -475,9 +495,12 @@ void ScreenshotCommand::CaptureEffects( AudacityProject * pProject, const wxStri
for( int i=0;i<sizeof(EffectNames)/sizeof(EffectNames[0]);i++){
// The handler is cleared each time it is used.
Effect::SetIdleHandler( IdleHandler );
SetIdleHandler( IdleHandler );
Str = EffectNames[i];
pMan->HandleTextualCommand( Str, AlwaysEnabledFlag, AlwaysEnabledFlag );
if( !pMan->HandleTextualCommand( Str, AlwaysEnabledFlag, AlwaysEnabledFlag ) )
{
wxLogDebug("Command %s not found", Str);
}
// This sleep is not needed, but gives user a chance to see the
// dialogs as they whizz by.
wxMilliSleep( 200 );

View File

@ -56,6 +56,9 @@ private:
public:
static ScreenshotCommand * mpShooter;
static void (*mIdleHandler)(wxIdleEvent& event);
static void SetIdleHandler( void (*pHandler)(wxIdleEvent& event) ){mIdleHandler=pHandler;};
static bool MayCapture( wxDialog * pDlg );
void CaptureWindowOnIdle( wxWindow * pWin );
wxTopLevelWindow *GetFrontWindow(AudacityProject *project);

View File

@ -63,6 +63,7 @@ greater use in future.
#endif
#include "../Experimental.h"
#include "../commands/ScreenshotCommand.h"
static const int kDummyID = 20000;
static const int kSaveAsID = 20001;
@ -88,9 +89,6 @@ const wxString Effect::kFactoryPresetIdent = wxT("Factory Preset:");
const wxString Effect::kCurrentSettingsIdent = wxT("<Current Settings>");
const wxString Effect::kFactoryDefaultsIdent = wxT("<Factory Defaults>");
// static member variable.
void (*Effect::mIdleHandler)(wxIdleEvent& event) = NULL;
WX_DECLARE_VOIDPTR_HASH_MAP( bool, t2bHash );
Effect::Effect()
@ -549,12 +547,8 @@ bool Effect::ShowInterface(wxWindow *parent, bool forceModal)
mUIDialog->Fit();
mUIDialog->SetMinSize(mUIDialog->GetSize());
// Idle event handler is used for example to take a screenshot.
if( mIdleHandler != NULL ){
mUIDialog->Bind( wxEVT_IDLE, mIdleHandler );
mIdleHandler = NULL;
forceModal = true;
}
if( ScreenshotCommand::MayCapture( mUIDialog ) )
return false;
if( SupportsRealtime() && !forceModal )
{

View File

@ -260,8 +260,6 @@ class AUDACITY_DLL_API Effect /* not final */ : public wxEvtHandler,
/* not virtual */ bool IsRealtimeActive();
virtual bool IsHidden();
static void SetIdleHandler( void (*pHandler)(wxIdleEvent& event) ){mIdleHandler=pHandler;};
//
// protected virtual methods
//
@ -439,7 +437,6 @@ protected:
// may be needed by any particular subclass of Effect.
//
protected:
static void (*mIdleHandler)(wxIdleEvent& event);
ProgressDialog *mProgress; // Temporary pointer, NOT deleted in destructor.
double mProjectRate; // Sample rate of the project - NEW tracks should