Chains - reverse "cleaned" folder paradigm

This read-only archive contains discussions from the Adding Feature forum.
New feature request may be posted to the Adding Feature forum.
Technical support is available via the Help forum.
Locked
Edgar
Forum Crew
Posts: 2043
Joined: Thu Sep 03, 2009 9:13 pm
Operating System: Windows 10

Chains - reverse "cleaned" folder paradigm

Post by Edgar » Sun Nov 24, 2013 5:06 pm

BACKGROUND
When a Chain includes a command to export it places the new audio file (currently there is no Chain command to save a Project) in a folder called (for historic reasons) "cleaned" which will be located in either: 1) If applying to the current Project, the folder to which the user most recently exported (or, possibly, saved a Project); or 2) If applying to file(s), the folder in which the file(s) reside, and adds that newly created file to the recent history list.

When there has been no import and a Chain is applied to the current Project Audacity creates a file name built out of the date and time: yyyy-Month-dd-hh-mm-ss.ext.

Chains include two types of commands - recognized effects and a small handful of "special commands":
"ExportMP3_56k_before", "ExportMP3_56k_after", "StereoToMono", "ExportFLAC", "ExportMP3", "ExportOgg", "ExportWAV" all of which, with the exception of StereoToMono (which is actually a built-in effect masquerading as a menu item), are built-in exporters.

SUGGESTIONS
1) For all the export-type special commands, instead of placing the new audio in the "cleaned" folder, put the old audio (when there has been an import) in that folder (which I would suggest renaming "remnants" or some such as the "cleaned" designation relates to the now-defunct Clean Speech and it would make an obvious distinction) and placing the new audio file in the folder from which the import came.
existing code:

Code: Select all

   else if (command == wxT("ExportWav")) {
      filename.Replace(wxT(".mp3"), wxT(".wav"), false);
      double endTime = GetEndTime();
      if (endTime <= 0.0f) {
         return false;
      }
      return mExporter.Process(project, numChannels, wxT("WAV"), filename, false, 0.0, endTime);
   }
proposed new code* (needs re-factoring**):

Code: Select all

   else if (command == wxT("ExportWav")) {
      filename.Replace(wxT(".mp3"), wxT(".wav"), false);
      double endTime = GetEndTime();
      if (endTime <= 0.0f) {
         return false;
      }
      //efm5  start 
      bool exportedOkay = mExporter.Process(project, numChannels, wxT("WAV"), filename, false, 0.0, endTime);
      if (exportedOkay) {
         wxString temporaryStub(wxT(".TEMPORARYNEWFILE"));
         wxString paddedNewFilename(filename);
         paddedNewFilename.Append(temporaryStub);
         ::wxRenameFile(filename, paddedNewFilename);

         wxFileName oldFile(project->GetImportFileName());
         oldFile.AppendDir(chainFolder);
         wxString oldFilesNewName(oldFile.GetFullPath());
         ::wxRenameFile(project->GetImportFileName(), oldFilesNewName);

         wxString newFileName(paddedNewFilename);
         wxString folderRemoval(wxFileName::GetPathSeparator());
         folderRemoval.Append(chainFolder);
         newFileName.Replace(folderRemoval, wxEmptyString);
         newFileName.Replace(temporaryStub, wxEmptyString);
         ::wxRenameFile(paddedNewFilename, newFileName);
      }
      //wxGetApp().AddFileToHistory(filename);
      project->SetJustExported(true);
      return exportedOkay;
      //efm5  end 
   }
*Note that in keeping with the current general strategy throughout Audacity, there is no error checking related to ::wxRenameFile. If this code were to see the light of day I would propose that error checking be added.
**The proposed new code should include re-factoring all of the exporters because there is a lot of duplicated code. I just added my new code to one of them (because it is the only one I use) as a proof-of-concept.

2) When there has been no import, instead of building the file name from the date and time, immediately ask the user for a file name string as the first part of the batch process (with suitable error checking) - that way the user may go out for a suitable beverage during long batch processing sessions.

Locked