How to open an AUP file from the command line on macOS

Hi there!

I am trying to call /Applications/Audacity.app/Contents/MacOS/Audacity with the first argument being an AUP project file, but Audacity does not open that project - it opens empty. I tried using Audacity.sh too, with no success. And I need to keep the “Audacity” instance running on the terminal, so “open -a” does not work for me.

Am I missing something? Is this a bug?

Thanks for your attention.

I’ve not tried this on a Mac, but my guess is that you’ve probably not got the path to the file correct. Try using the fully qualified file name, in double quotes, after the audacity command.

On Linux (and it’s probably the same on a Mac), if you navigate to the folder where the project file is, and run the command from there, you can just use the name of the file without the file path.

Don’t forget that you need the “.aup” at the end of the file name.
Don’t forget that if the file name has spaces, it needs to be quoted.

Hi steve

Thanks for the reply. I tried everything you said. In fact, I was using some scripts on Linux successfully, but they do not work on macOS because of this odd behaviour. I really think this is a bug, but would like to confirm if there is some “special” command I am missing to open AUP from the binary.

Thanks again!

I’ve just checked, and on macOS you can just do:

open "<path>/<file name>.aup"

As I explained, open command will not work for me because it will just open the file and return to the terminal… I need the command to keep locked until I close the Audacity, just like Linux and Windows.

But I found the source of this problem. In fact, for me it is a planned bug:
https://github.com/audacity/audacity/blob/1866be61453b6b2564deb961394c81e357f2baf9/src/AudacityApp.cpp#L1677

So, on a macOS it is not possible to call a file from the binary (inside the Audacity.app).

I compiled a version for me removing this limitation, so for me it is solved.

Anyway, thanks for your attention and time. :smiley: :wink:

I’m sure I’m completely misunderstanding this, but cat or more?

Koz


lucille:Desktop koz$ more Untitled.aup
<?xml version="1.0" standalone="no" ?>
<!DOCTYPE project PUBLIC "-//audacityproject-1.3.0//DTD//EN" "http://audacity.sourceforge.net/xml/audacityproject-1.3.0.dtd" >
<project xmlns="http://audacity.sourceforge.net/xml/" projname="Untitled_data" version="1.3.0" audacityversion="2.3.0" sel0="0.0000000000" sel1="2.0000000000" vpos="0" h="0.0000000000" zoom="446.0000000000" rate="44100.0" snapto="off" selectionformat="hh:mm:ss + milliseconds" frequencyformat="Hz" bandwidthformat="octaves">
        <tags/>
        <wavetrack name="Audio Track" channel="2" linked="0" mute="0" solo="0" height="150" minimized="0" isSelected="1" rate="44100" gain="1.0" pan="0.0" colorindex="0">
                <waveclip offset="0.00000000" colorindex="0">
                        <sequence maxsamples="262144" sampleformat="262159" numsamples="88200">
                                <waveblock start="0">
                                        <simpleblockfile filename="eff1f1ae.au" len="88200" min="-0.406615" max="0.444019" rms="0.112141"/>
                                </waveblock>
                        </sequence>
                        <envelope numpoints="0"/>
                </waveclip>
        </wavetrack>
</project>
Untitled.aup (END)

How does it “open the file”? For me, it opens the Audacity project file in Audacity - isn’t that what you want?

Why?

Perhaps we’ve reached the point where you tell us what the objective is.

In my case, I need some information Audacity’s stdout provides while the aup is opened. But for you to understand, consider that I need to call audacity executable from the terminal and I need to know (the script needs to continue some tasks) after the project is closed.

Just consider how it works on Linux when you call

audacity some_project.aup

or on Windows

Audacity.exe some_project.aup

It does not work when I call on mac

/Applications/Audacity.app/Contents/MacOS/Audacity some_project.aup

Sorry I didn’t explained clear enough before :frowning:

Could this be fallout of an unfortunate feature some versions of Audacity had of placing shows (projects) inside the /Applications directory?

What happens if you place the show on the desktop? Do you get the same failures?


Screen Shot 2019-04-16 at 21.13.08.png
Koz

What information?
How do you know that Audacity sends that information to stdout on macOS?

I explained before, I just want the macOS executable to open an AUP from the terminal just like it happens on Linux and WIndows.

What information?

Sorry, why does it matter? This is something very specific for my case… if I get some stdout info or if I verify the lack of it… I just need to open an AUP with the binary from the terminal.

How do you know that Audacity sends that information to stdout on macOS?

I am not able to know because it does not open an AUP file when I call it just like

/Applications/Audacity.app/Contents/MacOS/Audacity some_project.aup

I did not understand the point, but the AUP location does not matter. I tried on various places.

Because:

  • You may be trying to do something that is impossible
  • You may be trying to do something that can be done another way


but you are not willing to say what that use case is?

I’ve had a look into the code, and in AudacityApp::OnInit(), passing file list arguments via the command line is implemented for Windows and Linux only:

#if !defined(__WXMAC__)
         for (size_t i = 0, cnt = parser->GetParamCount(); i < cnt; i++)
         {
            // PRL: Catch any exceptions, don't try this file again, continue to
            // other files.
            SafeMRUOpen(parser->GetParam(i));
         }
#endif

I have asked on the developer’s mailing list for clarification on why this is.

Correct, so I removed this and recompiled on a mac to make it work for me. That’s because it is working now for my case. As I said, must be a reason, this is a planned bug.

An “intended behaviour”. By definition, bugs are unintended.

If I receive more information from the developers of “why” this is intended, I’ll post that info here.

Does this still work in your modified version:

open "<path>/<file name>.aup"

Can you still open projects by double clicking on them?

An “intended behaviour”. By definition, bugs are unintended.

May I say an “intended discrepancy” instead? :laughing:

Yes, I can confirm. Double clicking or using the open command does work.

:laughing:
Indeed, “intended behaviours” are not always “good” decisions.

What did you do? Just comment out the “#if !defined(WXMAC)” and “#endif”?