Update of /cvsroot/audacity/audacity-src/src/commands In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv24813/src/commands
Modified Files: CommandDirectory.cpp CommandManager.h CommandManager.cpp CompareAudioCommand.cpp GetAllMenuCommands.cpp Added Files: ImportExportCommands.h ImportExportCommands.cpp Log Message: Basic effect testing script. Added Import & Export commands. Two new files: src/commands/ImportExportCommands.h src/commands/ImportExportCommands.cpp Mac & Win projects need updating again - sorry! Modified CompareAudioCommand to return results on separate lines as well as in summary sentence. Modified GetAllMenuCommands (and CommandManager) to allow getting information about whether the menu commands are enabled or disabled, for testing menu item enabling. The effects testing script works is used as follows: exportEffects sub applies each effect in the list (in the script) and saves the results in a given directory. testEffects applies the effects and compares them to an imported reference output. A summary table is printed, showing the total samples and seconds of audio that didn't match for each effect. Index: CommandDirectory.cpp =================================================================== RCS file: /cvsroot/audacity/audacity-src/src/commands/CommandDirectory.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- CommandDirectory.cpp 16 Aug 2009 14:44:20 -0000 1.3 +++ CommandDirectory.cpp 17 Aug 2009 18:32:23 -0000 1.4 @@ -27,6 +27,7 @@ #include "CompareAudioCommand.h" #include "SetTrackInfoCommand.h" #include "PreferenceCommands.h" +#include "ImportExportCommands.h" CommandDirectory *CommandDirectory::mInstance = NULL; @@ -49,6 +50,8 @@ AddCommand(new SetTrackInfoCommandType()); AddCommand(new SetPreferenceCommandType()); AddCommand(new GetPreferenceCommandType()); + AddCommand(new ImportCommandType()); + AddCommand(new ExportCommandType()); } CommandDirectory::~CommandDirectory() --- NEW FILE: ImportExportCommands.cpp --- /********************************************************************** Audacity - A Digital Audio Editor Copyright 1999-2009 Audacity Team File License: wxWidgets Dan Horgan ******************************************************************//** \file ImportExportCommands.cpp \brief Contains definitions for the ImportCommand and ExportCommand classes *//*******************************************************************/ #include "ImportExportCommands.h" #include "../Project.h" #include "../export/Export.h" // Import wxString ImportCommandType::BuildName() { return wxT("Import"); } void ImportCommandType::BuildSignature(CommandSignature &signature) { Validator *filenameValidator(new Validator()); signature.AddParameter(wxT("Filename"), wxT(""), filenameValidator); } Command *ImportCommandType::Create(CommandOutputTarget *target) { return new ImportCommand(*this, target); } bool ImportCommand::Apply(CommandExecutionContext context) { wxString filename = GetString(wxT("Filename")); return context.proj->Import(filename); } ImportCommand::~ImportCommand() { } // Export wxString ExportCommandType::BuildName() { return wxT("Export"); } void ExportCommandType::BuildSignature(CommandSignature &signature) { OptionValidator *modeValidator(new OptionValidator()); modeValidator->AddOption(wxT("All")); modeValidator->AddOption(wxT("Selection")); signature.AddParameter(wxT("Mode"), wxT("All"), modeValidator); Validator *filenameValidator(new Validator()); signature.AddParameter(wxT("Filename"), wxT("exported.wav"), filenameValidator); IntValidator *channelsValidator(new IntValidator()); signature.AddParameter(wxT("Channels"), 1, channelsValidator); } Command *ExportCommandType::Create(CommandOutputTarget *target) { return new ExportCommand(*this, target); } bool ExportCommand::Apply(CommandExecutionContext context) { wxString mode = GetString(wxT("Mode")); wxString filename = GetString(wxT("Filename")); long numChannels = GetLong(wxT("Channels")); bool selection = mode.IsSameAs(wxT("Selection")); double t0, t1; if (selection) { t0 = context.proj->mViewInfo.sel0; t1 = context.proj->mViewInfo.sel1; } else { t0 = 0.0; t1 = context.proj->GetTracks()->GetEndTime(); } // Find the extension and check it's valid int splitAt = filename.Find(wxT(".")); if (splitAt < 0) { Error(wxT("Export filename must have an extension!")); return false; } wxString extension = filename.Mid(splitAt+1).MakeUpper(); Exporter exporter; bool exportSuccess = exporter.Process(context.proj, numChannels, extension.c_str(), filename, selection, t0, t1); if (exportSuccess) { Status(wxString::Format(wxT("Exported to %s format: %s"), extension.c_str(), filename.c_str())); return true; } Error(wxString::Format(wxT("Could not export to %s format!"), extension.c_str())); return false; } ExportCommand::~ExportCommand() { } // Indentation settings for Vim and Emacs and unique identifier for Arch, a // version control system. Please do not modify past this point. // // Local Variables: // c-basic-offset: 3 // indent-tabs-mode: nil // End: // // vim: et sts=3 sw=3 // arch-tag: TBD Index: CommandManager.h =================================================================== RCS file: /cvsroot/audacity/audacity-src/src/commands/CommandManager.h,v retrieving revision 1.28 retrieving revision 1.29 diff -u -d -r1.28 -r1.29 --- CommandManager.h 6 Jun 2009 13:51:25 -0000 1.28 +++ CommandManager.h 17 Aug 2009 18:32:23 -0000 1.29 @@ -188,6 +188,8 @@ wxString GetKeyFromName(wxString name); wxString GetDefaultKeyFromName(wxString name); + bool GetEnabled(const wxString &name); + #if defined(__WXDEBUG__) void CheckDups(); #endif Index: CommandManager.cpp =================================================================== RCS file: /cvsroot/audacity/audacity-src/src/commands/CommandManager.cpp,v retrieving revision 1.73 retrieving revision 1.74 diff -u -d -r1.73 -r1.74 --- CommandManager.cpp 4 Jun 2009 15:51:21 -0000 1.73 +++ CommandManager.cpp 17 Aug 2009 18:32:24 -0000 1.74 @@ -788,6 +788,17 @@ } } +bool CommandManager::GetEnabled(const wxString &name) +{ + CommandListEntry *entry = mCommandNameHash[name]; + if (!entry || !entry->menu) { + wxLogDebug(wxT("Warning: command doesn't exist: '%s'"), + (const wxChar*)name); + return false; + } + return entry->enabled; +} + void CommandManager::Check(wxString name, bool checked) { CommandListEntry *entry = mCommandNameHash[name]; --- NEW FILE: ImportExportCommands.h --- /********************************************************************** Audacity: A Digital Audio Editor Audacity(R) is copyright (c) 1999-2009 Audacity Team. File License: wxwidgets ImportExportCommands.h Dan Horgan ******************************************************************//** \class ImportCommand \brief Command for importing audio \class ExportCommand \brief Command for exporting audio *//*******************************************************************/ #include "Command.h" #include "CommandType.h" // Import class ImportCommandType : public CommandType { public: virtual wxString BuildName(); virtual void BuildSignature(CommandSignature &signature); virtual Command *Create(CommandOutputTarget *target); }; class ImportCommand : public CommandImplementation { public: ImportCommand(CommandType &type, CommandOutputTarget *target) : CommandImplementation(type, target) { } virtual ~ImportCommand(); virtual bool Apply(CommandExecutionContext context); }; // Export class ExportCommandType : public CommandType { public: virtual wxString BuildName(); virtual void BuildSignature(CommandSignature &signature); virtual Command *Create(CommandOutputTarget *target); }; class ExportCommand : public CommandImplementation { public: ExportCommand(CommandType &type, CommandOutputTarget *target) : CommandImplementation(type, target) { } virtual ~ExportCommand(); virtual bool Apply(CommandExecutionContext context); }; // Indentation settings for Vim and Emacs and unique identifier for Arch, a // version control system. Please do not modify past this point. // // Local Variables: // c-basic-offset: 3 // indent-tabs-mode: nil // End: // // vim: et sts=3 sw=3 // arch-tag: TBD Index: GetAllMenuCommands.cpp =================================================================== RCS file: /cvsroot/audacity/audacity-src/src/commands/GetAllMenuCommands.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- GetAllMenuCommands.cpp 4 Aug 2009 04:19:22 -0000 1.2 +++ GetAllMenuCommands.cpp 17 Aug 2009 18:32:24 -0000 1.3 @@ -24,7 +24,8 @@ void GetAllMenuCommandsType::BuildSignature(CommandSignature &signature) { - return; + BoolValidator *showStatusValidator = new BoolValidator(); + signature.AddParameter(wxT("ShowStatus"), 0, showStatusValidator); } Command *GetAllMenuCommandsType::Create(CommandOutputTarget *target) @@ -34,12 +35,21 @@ bool GetAllMenuCommands::Apply(CommandExecutionContext context) { + bool showStatus = GetBool(wxT("ShowStatus")); wxArrayString names; - context.proj->GetCommandManager()->GetAllCommandNames(names, false); + CommandManager *cmdManager = context.proj->GetCommandManager(); + cmdManager->GetAllCommandNames(names, false); wxArrayString::iterator iter; for (iter = names.begin(); iter != names.end(); ++iter) { - Status(*iter); + wxString name = *iter; + wxString out = name; + if (showStatus) + { + out += wxT("\t"); + out += cmdManager->GetEnabled(name) ? wxT("Enabled") : wxT("Disabled"); + } + Status(out); } return true; } Index: CompareAudioCommand.cpp =================================================================== RCS file: /cvsroot/audacity/audacity-src/src/commands/CompareAudioCommand.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- CompareAudioCommand.cpp 4 Aug 2009 04:19:22 -0000 1.1 +++ CompareAudioCommand.cpp 17 Aug 2009 18:32:24 -0000 1.2 @@ -135,8 +135,9 @@ // Output the results double errorSeconds = mTrack0->LongSamplesToTime(errorCount); - msg = wxString::Format(wxT("Finished comparison: %i samples (%.3f seconds) exceeded the error threshold of %f."), errorCount, errorSeconds, errorThreshold); - Status(msg); + Status(wxString::Format(wxT("%i"), errorCount)); + Status(wxString::Format(wxT("%.4f"), errorSeconds)); + Status(wxString::Format(wxT("Finished comparison: %i samples (%.3f seconds) exceeded the error threshold of %f."), errorCount, errorSeconds, errorThreshold)); return true; } ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Audacity-cvs mailing list Audacity-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/audacity-cvs