Command line processing

This section is now closed.
Forum rules
This forum is now closed.

For help with current Audacity, please post to the 2.x. board for your operating system.

Please post feedback about the current 2.x version on the 2.x.feedback board.
trym
Posts: 5
Joined: Tue Aug 10, 2010 8:06 pm
Operating System: Please select

Command line processing

Post by trym » Tue Aug 10, 2010 8:15 pm

Is there a way to call Audacity from, e.g., a DOS command line with a string of commands to be executed? I am trying to do the same set of commands to a large number (1000 or so) of audacity project files.

kozikowski
Forum Staff
Posts: 69357
Joined: Thu Aug 02, 2007 5:57 pm
Operating System: macOS 10.13 High Sierra

Re: Command line processing

Post by kozikowski » Tue Aug 10, 2010 10:06 pm

No.

Audacity in the latest version just got very limited Batch Processing in only some of the tools. So even inside Audacity you can't do this.

Koz

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

Re: Command line processing

Post by Edgar » Wed Aug 11, 2010 4:24 pm

It is possible to re-compile Audacity with a givenspecific set of actions performed "automatically" then have it quit itself. I do this to split large numbers of large M4A files (entire album/tape is two tracks) by silence. What specific set of actions do you want to apply?
-Edgar
running Audacity personally customized 2.0.6 daily in a professional audio studio
occasionally using current Audacity alpha for testing and support situations
64-bit Windows Pro 10

trym
Posts: 5
Joined: Tue Aug 10, 2010 8:06 pm
Operating System: Please select

Re: Command line processing

Post by trym » Fri Aug 13, 2010 9:20 pm

That sounds quite interesting. I would like to do a variety of things. But the first one is quite simple, and common. I would like to open a specific project (file name should be an input argument), Then mark all tracks, everything. Then resample to convert from 45rpm to 33rpm. I have digitized a large no of LPs, at 45rpm to save time. To call audacity with these actions and then have it exit sounds good. I am running this on Windows Vista.

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

Re: Command line processing

Post by Edgar » Sun Aug 15, 2010 7:06 am

trym wrote:That sounds quite interesting. I would like to do a variety of things. But the first one is quite simple, and common. I would like to open a specific project (file name should be an input argument), Then mark all tracks, everything. Then resample to convert from 45rpm to 33rpm. I have digitized a large no of LPs, at 45rpm to save time. To call audacity with these actions and then have it exit sounds good. I am running this on Windows Vista.
I'm more of a programmer/musician/sound tech than a production/post-production expert! What you ask seems doable, but I would not know how to go about causing Audacity to perform the functions you desire. I would be happy to help by compiling a custom Audacity which would do what you want, but I am not sure exactly what you are doing. Can you manually perform what you are trying to accomplish without listening for track split points by ear?

We need to describe a very explicit set of steps which will accomplish what you want. I will attempt to get started and maybe you can fill in the missing parts!

0) start CLI and CD into data directory
1) launch Audacity with an audacity project file as the first (input) argument which will be "opened"
a. do we want to hard code the result?
i. will the result be another Audacity project or a WAV/MP3/M4A/etc. file
ii. will the result's file name be derived from the input argument of do we want to specify an output name?
b. are we going to assume the input is a fully qualified file name (not a Window shortcut which can cause problems for Audacity)
2) process the track to determine split points
a. The Silence Finder (Analyze menu) will do this but we will have to determine the right settings and hard-code them as the defaults (I have done this for the multitude of tapes and LPs I converted into single tracks using M4A as the resulting file type)
b. do you envision using some other method to "mark all tracks, everything"--in fact, is this what you mean?
3) process to convert from 45 -> 33 1/3 rpm
a. I have seen reference to this as something Audacity can do, but am clueless as to the steps involved. You would have to send me a small project which needs converting and tell me exactly (in excruciating detail) how to perform this task.
b. now that I think about it, the silences we use in #2 will be longer after the rpm conversion so we might want to convert rpm first
Decision fork:
Keep it as a single Audacity project (no other action needed--do a "Save Project As" whatever we want to call it and exit), Make a bunch of individual Audacity projects--one for each track (a bit of work), export each track as WAV, MP3/etc. (a bit more work--maybe just different not more!)

If we do not stick with the single Audacity project:
4) we will have to name the tracks
a. if the tracks are all listed in a text file, it might be easiest to use a stand-alone program I have written which will re-name all the files in a folder based on a list supplied in a text file
b. it would be a lot more work to incorporate this function into Audacity--beyond my interest level!

If we go the individual project route, we would have to play around with the exact process to determine exactly how to do it, but...
5) select first track
6) cut (which does a copy)
7) open new project
8) paste
9) save project "as" whatever we use as a naming convention
10) go back to #5 and repeat until all tracks are processed
a. how do we determine how many tracks there are?
11) exit Audacity

If we go the WAV/etc. route:
5) Export Multiple based on naming convention
6) exit Audacity

I know this looks long and daunting in text, but it is not too hard to code--I've already go most of it working with the exception of the 45->33 1/3 rpm conversion. I would make the changes and post the code here for others to review (not likely, but...) then create a custom executable for you if you cannot compile Audacity for yourself.
-Edgar
running Audacity personally customized 2.0.6 daily in a professional audio studio
occasionally using current Audacity alpha for testing and support situations
64-bit Windows Pro 10

brian1454
Posts: 2
Joined: Wed Aug 18, 2010 4:21 pm
Operating System: Please select

Re: Command line processing

Post by brian1454 » Wed Aug 18, 2010 4:31 pm

Edgar,

I'd like to do something very similar but am not familiar enough with the Audacity project to compile it like you're doing. How easy/feasible would this be? I want to use Windows Scheduler to daily fire off Audacity from the command line with switches to start/stop recording and then Export to MP3 when recording has stopped (and exit Audacity when that's done). I'm using the Windows Mixer to record what I hear. Here are the steps I'd like to do through command line switches:
1. Fire up Audacity
2. Start recording (using the default recording device - no need to be able to change that)
3. Record for a specified period of time OR tell the active Audacity (via separate scheduled event) to stop recording
4. Export to MP3 and specify a filename (I could make the filename dynamic via Windows Batch)
5. Tear down Audacity

--bw

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

Re: Command line processing

Post by Edgar » Thu Aug 19, 2010 3:33 pm

brian1454 wrote:Edgar,

I'd like to do something very similar but am not familiar enough with the Audacity project to compile it like you're doing. How easy/feasible would this be? I want to use Windows Scheduler to daily fire off Audacity from the command line with switches to start/stop recording and then Export to MP3 when recording has stopped (and exit Audacity when that's done). I'm using the Windows Mixer to record what I hear. Here are the steps I'd like to do through command line switches:
1. Fire up Audacity
2. Start recording (using the default recording device - no need to be able to change that)
3. Record for a specified period of time OR tell the active Audacity (via separate scheduled event) to stop recording
4. Export to MP3 and specify a filename (I could make the filename dynamic via Windows Batch)
5. Tear down Audacity

--bw
First, a possible problem...step 3 "Record for a specified period of time"; there are reported issues with timed recording--few and hard to pin down, but be aware of this.

I will have to play around with Audacity to determine what happens if we do something like this via scheduled event
CLI> Audacity startRecording
(wait awhile then a new scheduled event:)
CLI> Audacity stopReporting

Normally Audacity only runs a single instance of itself, let's see... I start a new Commandline and start Audacity; next I start a second Commandline and start a second instance of Audacity. In the second instance of Audacity I go to the File menu and issue Quit -- both instances of Audacity quit, this is good. This means that we can use the second choice for step three. That being the case what you want to do should not be too hard; probably easiest way would be by way of a third-party scripting tool. That should not be hard assuming that you can accept whatever defaults your preferences are set up as for your recording and export.

It can also be done by changing the internal Audacity code and recompiling but this would require quite a bit more work.

For the scripting method, there are a number of third-party tools available some of which are free. If you are not already using one, you might want to do some research and find one that suits your overall needs (I use AutoIt3).

As I see it in general steps would be use Windows Scheduler to:
1) start Audacity
2) run a script which does whatever keypress shortcut you have to tell Audacity to start recording
3) run a second script which tells Audacity (via keypress shortcut) to stop recording, wait a few seconds, tell Audacity "export" (keypress), wait a second so that the export dialog opens, send the file name (the dialog opens ready to accept filename input), send the <Enter> key to save the file (the storage location, file type and compression options will be taken from your Preferences -- they will be whatever you last used)

I do not use Windows Scheduler so I'm not extremely familiar with it. On my system Audacity will not "record what you hear" so testing the above on my system will not be perfect but if you give it a try and have any problems I will try to help.
-Edgar
running Audacity personally customized 2.0.6 daily in a professional audio studio
occasionally using current Audacity alpha for testing and support situations
64-bit Windows Pro 10

brian1454
Posts: 2
Joined: Wed Aug 18, 2010 4:21 pm
Operating System: Please select

Re: Command line processing

Post by brian1454 » Thu Aug 19, 2010 3:57 pm

Edgar,

Thanks for the research and info. I'll try AutoIt3. I have a lot of app automation experience, so if it's intuitive, I should be able to figure it out quickly. I was hoping everything could be done via cmd line, but this is a work around for sure. I'll see what I can figure out and post later.

--brian

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

Re: Command line processing

Post by Edgar » Fri Aug 20, 2010 7:52 pm

I posted a "proof of concept" in a new thread:
http://forum.audacityteam.org/viewtopic ... 15&t=38341
-Edgar
running Audacity personally customized 2.0.6 daily in a professional audio studio
occasionally using current Audacity alpha for testing and support situations
64-bit Windows Pro 10

trym
Posts: 5
Joined: Tue Aug 10, 2010 8:06 pm
Operating System: Please select

Re: Command line processing

Post by trym » Wed Aug 25, 2010 7:53 pm

Edgar,

thanks for your research on this. I suspect that this might be easier than your quite detailed algorithm - but the approach is good: You have started a description, I will try yo iterate on it below. First a couple of questions:

1) What is CLI?
2) Are you compiling this in a Linux (Unix) environment, or is this on a Windows platform?
3) What compiler are you using?
4) I studied your other answer to brian. Can AutoIt3 be used to input commands to Audacity?

Here is the preferred part of your initial algorithm, with my proposals in between:

0) start CLI and CD into data directory
THE: I would assume that we are in the data directory initially
1) launch Audacity with an audacity project file as the first (input) argument which will be "opened"
THE: Good. This is what we want.
a. do we want to hard code the result?
THE: To make it simple: The result could be another Audacity project file, with the same name as the input, i.e., we overwrite the input project. Eventually I want to do track splitting by the Silence Finder, as you describe below and then export as a flac. But to make it this step simple, let's constrain ourselves to do the resampling and saving only.
i. will the result be another Audacity project or a WAV/MP3/M4A/etc. file
THE: No, see answer above
ii. will the result's file name be derived from the input argument of do we want to specify an output name?
THE: Yes, see proposal under a.
b. are we going to assume the input is a fully qualified file name (not a Window shortcut which can cause problems for Audacity)
THE: Not sure what you mean by this. I think we could assume a "fully qualified file name".
2) process the track to determine split points
THE: Omit this point for now, to make it simple
a. The Silence Finder (Analyze menu) will do this but we will have to determine the right settings and hard-code them as the defaults (I have done this for the multitude of tapes and LPs I converted into single tracks using M4A as the resulting file type)
b. do you envision using some other method to "mark all tracks, everything"--in fact, is this what you mean?
3) process to convert from 45 -> 33 1/3 rpm
a. I have seen reference to this as something Audacity can do, but am clueless as to the steps involved. You would have to send me a small project which needs converting and tell me exactly (in excruciating detail) how to perform this task.
THE: This is not hard at all. I have never used Audacity, but I was able to figure this out quite easily:
The whole project is saved as a single track.
i. So to mark every thing, hit "Ctrl A"
ii. For resampling from 45 to 33 rpm: Do Effect-> Change Speed. Then a dialog box appears. In this dialog we need to put "33 1/3" in the "To" box and "45" in the "From" box, and then hit "ok". This will issue the resampling process, with a progress bar for which we need to wait until it exits.
b. now that I think about it, the silences we use in #2 will be longer after the rpm conversion so we might want to convert rpm first
THE: Not applicable with this approach. Proposal is to not use Silence Finder
Decision fork:
THE: This is the simplest solution, and it is adequate for the time being.
Keep it as a single Audacity project (no other action needed--do a "Save Project As" whatever we want to call it and exit), Make a bunch of individual Audacity projects--one for each track (a bit of work), export each track as WAV, MP3/etc. (a bit more work--maybe just different not more!)
THE: This would be interesting, as eventually I want to split the track with the Silence Finder, and then export multiple projects as flac files, ready for burning CD's

Locked