remembering the Import directory

Audio software developers forum.
Forum rules
If you require help using Audacity, please post on the forum board relevant to your operating system:
Windows
Mac OS X
GNU/Linux and Unix-like
Post Reply
Edgar
Forum Crew
Posts: 2043
Joined: Thu Sep 03, 2009 9:13 pm
Operating System: Windows 10 / 11

remembering the Import directory

Post by Edgar » Fri Feb 18, 2011 6:49 am

When I import an audio file to do a quick edit I almost always want to Export it right back where it came from.

Currently Audacity stores the previously used save path for Export. So if I Export a file to d:songs/rock/artist/album then Import one from c:music/pop/artist/album, do a bit of editing then choose File>Export..., the file dialog opens on the OLD directory ( d:songs/rock/artist/album ) and (at least on Windows) the file save dialog is really clunky and getting from way down in d:songs/rock/artist/album to the location I want ( c:music/pop/artist/album ) is a lot of clicking.

I realize that for some workflows having the Export dialog always open in the same directory is good but for my workflow (after Import) I want it to open for Export in the Import directory. As it turns out this is easy to accomplish.

First, add a new public wxString mImportPath to the AudacityProject class (it does not really matter where as long as it is in a public section), so in Project.h around line 389 it seems that on Linux it might really matter where in the header the new variable goes); so, in Project.h at the very end of the file:

Code: Select all

   // Are we currently closing as the result of a menu command?
   bool mMenuClose;

public:
    wxString mImportPath;//efm5
    DECLARE_EVENT_TABLE()
};

#endif

We will not initialize mImportPath as we rely on wxString to be created empty.

Next we need to store the path of the Import directory, so in Project.cpp around line 3372:

Code: Select all

bool AudacityProject::Import(wxString fileName, WaveTrackArray* pTrackArray /*= NULL*/)
{
   //efm5 start
   AudacityProject * project = GetActiveProject();
   wxFileName tempFilename(fileName);
   project->mImportPath = tempFilename.GetPath();
   //efm5 end
   Track **newTracks;
Finally, when we Export we need to use the stored path, in Export.cpp around line 542:

Code: Select all

   maskString.RemoveLast();

   //efm5 start
   if (mProject->mImportPath.IsEmpty())
      mFilename.SetPath(gPrefs->Read(wxT("/Export/Path"), ::wxGetCwd()));
   else
      mFilename.SetPath(mProject->mImportPath);
   //efm5 end
   mFilename.SetName(mProject->GetName());

   while (true) {

      FileDialog fd(mProject,
This is all tested against SVN HEAD 17Feb2011 but only on Windows7. If you Drag 'n' Drop a supported audio file on the program icon or a Project window or choose the menu items File>Import>Audio... then choose File>Export the Import path will be used when opening the file dialog. If you open an empty Project and record or generate audio and choose File>Export the OLD path saved in the configuration file will be used.

In the above code I have included a line or two before and after my changes for continuity. I have noted or wrapped changes with //efm5 comments.
Last edited by Edgar on Tue Feb 22, 2011 3:46 am, edited 1 time in total.

Gale Andrews
Quality Assurance
Posts: 41761
Joined: Fri Jul 27, 2007 12:02 am
Operating System: Windows 10 / 11

Re: remembering the Import directory

Post by Gale Andrews » Sat Feb 19, 2011 8:36 am

Ed has linked to this topic on Wiki Feature Requests so it should be moved to "General Audio Programming" rather than deleted when its month here is up. As I recall, the Forum will cope with the redirection OK.


Peter: Duly noted, will do.


Gale
________________________________________FOR INSTANT HELP: (Click on Link below)
* * * * * Tips * * * * * Tutorials * * * * * Quick Start Guide * * * * * Audacity Manual

steve
Site Admin
Posts: 85701
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: remembering the Import directory

Post by steve » Mon Feb 21, 2011 11:35 pm

I've got a problem with this on Linux.
I think I applied the changes correctly, then built against SVN HEAD 21Feb2011
It seems to build OK, but as soon as I click on the File menu, Audacity crashes with a segmentation fault.

I like the idea a lot and would find it very useful.

[Update: I've backed out of the changes and Audacity is working, so unfortunately it looks like these code changes caused the seg fault]
Learn more about Nyquist programming at audionyq.com

Edgar
Forum Crew
Posts: 2043
Joined: Thu Sep 03, 2009 9:13 pm
Operating System: Windows 10 / 11

Re: remembering the Import directory

Post by Edgar » Tue Feb 22, 2011 12:51 am

steve wrote:I've got a problem with this on Linux.
I think I applied the changes correctly, then built against SVN HEAD 21Feb2011
It seems to build OK, but as soon as I click on the File menu, Audacity crashes with a segmentation fault.
Hi Steve!

First, can you build a Debug version then run under a debugger?

Regardless, try an incremental approach. First just do the addition of the new Public variable to Project.h (step 1); compile, run then test; do you still segfault?

If you DO segfault, then it is likely to be the location of the new variable in Project.h (I doubt this will happen, but...) the absolute safest place to put the new variable would be at the very end of the file:

Code: Select all


   // Are we currently closing as the result of a menu command?
   bool mMenuClose;

 public:
/*here*/wxString mImportPath;//efm5
    DECLARE_EVENT_TABLE()
};

#endif

If (as I expect) your placement of the variable is good and not affecting the segfault, leave the new variable in place (step 1 or the new step 1) and additionally implement the second step (store the path of the Import directory in Project.cpp around line 3372), Again, compile, run then test--If you DO segfault, stop here and get back to me with the answer to my question about running under the debugger.

If you DO NOT segfault, replace step 3 in the previous post with:

Code: Select all

   maskString.RemoveLast();

   mFilename.SetPath(gPrefs->Read(wxT("/Export/Path"), ::wxGetCwd()));
   wxMessageBox(mProject->mImportPath);//efm5
   mFilename.SetName(mProject->GetName());

   while (true) {

      FileDialog fd(mProject,
This results in "stock" behavior but will display the text stored in the variable. Let me know what happens!

PS We can take this to e-mail or PM if you desire.
PPS Who can we draft to test this on Mac and XP?

steve
Site Admin
Posts: 85701
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: remembering the Import directory

Post by steve » Tue Feb 22, 2011 2:23 am

Good news Edgar.
The old step 1 was the problem.

Applying the NEW step 1 with steps 2 and 3 WORKS :D

I think Bill (billw58) and Bruno (bgravato) use Macs, but I don't know if either of them build on Macs. You could PM them and ask.
Learn more about Nyquist programming at audionyq.com

Edgar
Forum Crew
Posts: 2043
Joined: Thu Sep 03, 2009 9:13 pm
Operating System: Windows 10 / 11

Re: remembering the Import directory

Post by Edgar » Tue Feb 22, 2011 3:38 am

steve wrote:Good news Edgar.
The old step 1 was the problem.

Applying the NEW step 1 with steps 2 and 3 WORKS :D
Great! I will edit the original to reflect this. Will also PM Bill & Bruno.

bgravato
Posts: 2112
Joined: Wed Jan 13, 2010 8:56 pm
Operating System: Linux Debian

Re: remembering the Import directory

Post by bgravato » Tue Feb 22, 2011 11:52 am

I think I never built audacity on Mac, but I can try. I'll have a look at it later today.
Include as much details as you can in your post (Audacity version, Operating System, Equipment used, etc).
Please post your question in the appropriate forum (regarding audacity version and operating system).

Edgar
Forum Crew
Posts: 2043
Joined: Thu Sep 03, 2009 9:13 pm
Operating System: Windows 10 / 11

Re: remembering the Import directory

Post by Edgar » Tue Feb 22, 2011 4:22 pm

bgravato wrote:I think I never built audacity on Mac, but I can try. I'll have a look at it later today.
Thanks, Bill was not able to help as he does not compile.

Post Reply