Batch Scripts with other programs

Effects, Recipes, Interfacing with other software, etc.

If you require help using Audacity, or think you have found a "bug", please post on the forum board relevant to your operating system.
Windows
Mac OS X
GNU/Linux and Unix-like

Batch Scripts with other programs

Permanent link to this post Posted by steve » Mon Feb 21, 2011 2:53 pm

I'm making this thread as a location for anyone wanting to submit any batch scripts for audio processing with other audio applications.

Examples might be batch converting files to WAV using Lame with a cmd or Powershell script (Windows), or batch converting using a Python script with pacpl (Pear Audio Converter - Linux).

Please state the program and scripting language used in the script, plus a description of what the script does.
Add other details as appropriate.
steve
Senior Forum Staff
 
Posts: 28589
Joined: Sat Dec 01, 2007 11:43 am

Add 10% silence to start of files

Permanent link to this post Posted by steve » Mon Feb 21, 2011 2:58 pm

Applications: SoX, Soxi, bc
Platform: Linux
Scripting language: Bash

Here's a batch processing script that will add a period of silence to the beginning of each WAV file in a folder and place the output files in an output folder.
It could be easily adapted to add a fixed number of second of silence to the beginning or end of each file.
For different file formats, provided they are supported by SoX, simply change the file extension at the start of the loop.

Code: Select all
#!/bin/bash

## script to add 10% silence to beginning of each WAV track in current folder

if [ -d "output" ]
  then echo "Folder already exists"
  else mkdir "output"
fi

# start loop
for filename in *.wav
  do
    # get file properties
    slength=$(soxi -D $filename)
    schan=$(soxi -c $filename)
    srate=$(soxi -r $filename)
    # Bash only does integer arithematic, so us bc to calculate 10% length
    slength=$(echo "$slength*0.1" | bc)
    # make silence
    sox -n -c $schan -r $srate "output/temp.wav" trim 0 $slength
    # concatenate silence and file
    sox "output/temp.wav" $filename "output/$filename"
  done

# clean up temp files
rm "output/temp.wav"
# end

9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Senior Forum Staff
 
Posts: 28589
Joined: Sat Dec 01, 2007 11:43 am

bash script to convert audacity labels to cue sheet

Permanent link to this post Posted by djkaboodle » Mon May 30, 2011 9:48 am

[NB: this post is going to be most useful to Linux users and people who know how to convert/use a bash script]

While I am aware that there is already a great way of convert Audacity labels to cue sheets (label2cue - http://forum.audacityteam.org/viewtopic.php?f=21&t=551), I wanted something that would provide a little more information on the finished cue sheet, particularly artist and track titles. I mainly burn DJ mixes to CD, and need all the information easily available to CD-Text.

So, I wrote this bash script >
labelcue.txt
Audacity labels.txt to cue sheet converter - bash script - remove the ".txt" part and change permissions to get it working
(2.79 KiB) Downloaded 555 times
<, which will scan a folder for wav files with a labels.txt file, and convert the labels.txt file to a cue sheet. It gives interactive control over the album title and album artist, and will automatically save the cue sheet's 'FILE' parameter as the name of the wav file, with 'WAVE' as the type. I use the same calculations as the label2cue Java program (thanks to 'AndrewTheArt' for authoring that), so the index times on the resulting cue sheets should be identical.

To get the bash script to run, you will need the following programs on Linux: zenity, tr, cut, bc, sed - all except zenity are likely to be part of a standard installation. However, you will also this 'bc' file >
bc.txt
additional bc file to perform extra calculations - remove the ".txt" part and change permissions to get it working, and place in your home directory. (original file came from here: http://www.pixelbeat.org/)
(1.74 KiB) Downloaded 382 times
<, uploaded to your home directory. If you upload it to another directory, you will need to change all instance of "bc ~/bc" in the bash script, replacing the tilde (~) with the full path to your home directory. Someone who knows bc better than I do might be able to make this work without the additional bc file...

If anyone can improve on or alter this script, please do so and post it up here for the benefit of others and myself. I am no bash expert, and, while I have found this works fine for me and does not do anything unpleasant, I am sure there will be the odd mistake in there. Anyway, I hope someone finds it useful.

I wrote a blog post about burning gapless mix CDs, which someone also might find useful: http://www.djkaboodle.co.uk/blog/2011/may/29/burning-mixes-cd-how. Again, any corrections or improvements are appreciated.

Regards,
DJ Kaboodle.
djkaboodle
 
Posts: 1
Joined: Mon May 30, 2011 8:45 am

Re: Batch Scripts with other programs

Permanent link to this post Posted by JohanP » Mon Jan 14, 2013 12:44 pm

Thank you for SoX script steve! I searched through half of web to find it here! Lol
JohanP
 
Posts: 3
Joined: Mon Jan 14, 2013 12:37 pm

Re: Batch Scripts with other programs

Permanent link to this post Posted by steve » Mon Jan 14, 2013 5:48 pm

You're welcome. :)
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Senior Forum Staff
 
Posts: 28589
Joined: Sat Dec 01, 2007 11:43 am


Return to Audio Processing



Who is online

Users browsing this forum: No registered users and 4 guests