This is an old revision of the document!

Assorted Linux Scripts, Tools, Tips and Utilities



wav file to specimen bank (sampler format) script

lscp2rgd - linuxsampler to rosegarden instrument

midi to hydrogen

SFZ (sound-bank-definition) to Hydrogen (drumkit xml-file)

script: create a hydrogen drumkit from wav files

thanks to Thijs van Severen

Hydrogen drumkit creator script - note: filenames have to follow a rule

Instrument mapping (Hydrogen Manual)

GM (general midi) mapping

aj-snapshot - Store ALSA and JACK connections state

Download songs of an *.m3u File (mp3 collection)

Make a directory and then do this:

wget -O - | while read i; do wget -c "$i"; done

(by Ken Restivo - 16. Mai 2011 22:06 - @lau-ml)


make a *.wav swing (?)

Comparable (?) examples

(by Chris Cannam - 2. Juni 2010 16:41 - @lau-ml )


jackctl - jack control python script

(by Aaron Krister Johnson, 28. Mai 2010 18:16 - @lau-ml)


a python script for making seamless loops in samples by cross fading

It uses sox and ecasound for processing and should work with wav, aiff and flac (maybe more).

planned (?): libsndfile support.

(by Atte André Jensen, 11. Juni 2010 11:02 - @ lau-ml )


convert a Hydrogen drumkit into a SF2 soundfont

conversion examples with mplayer / mencoder

wav to mp3

for F in *.aac; do
  mplayer -ao pcm:file=$F.wav $F
  lame -h $F.wav $F.mp3;

(by Julien Claassen , 25. Dezember 2010 02:37 - @ lau-ml )


  # flac_to_mp3
  for f in *.mp3; do lame -v "$f"; done

(James Morris,22. September 2010 11:20)

$ find . -name "*flac" -exec lame -V0 {} \;

(Roger, 22. September 2010 12:52)

Using MEncoder to create DVD-compliant files

convert DV files to DVD compliant

convert sound files with libsndfile

convert all FLAC files in a directory to OGA format (vorbis-encoded stream in ogg-container)

Note: There is a simple and excellent GUI tool available for audio conversion: SoundConverter
It is included in the ubuntu repository.

## UPDATE: sndfile-convert -vorbis  normalizes the sound to 0 DB !
## there are no options to control that, or compression rate.
## so rather use "oggenc" instead !
## there is also a py-script called "dir2ogg" in ubuntu
# initial code by Emanuel Rumpf 2012-04
# any re-use and modification permitted
# convert all FLAC files in a directory to OGA format 
# (compressed, vorbis-encoded stream in ogg-container)
# first install libsndfile - in ubuntu:
# sudo   apt-get install   libsndfile1 sndfile-programs sndfile-tools
# copy this script to the files directory, make it executable
# edit config options below if necessary, run it
# TODO: allow file-names with spaces
# select file extension:
# select directory for new vfiles
# add -vorbis parameter to sndfile-convert call
mkdir -p "$OUT_DIR"
# apply to all flac files in current directory
for f in $FILES
  fn=`basename "$f" $EXT_OLD`
  comm="sndfile-convert $CONVERT_OPT $f $fn "
  echo "--> $comm "
  echo ""

# There is a possilbe alternative, with "find" and -exec statement
# warning: this is not verbose  and  can take some time !

# for all files in current directory (.)  execute libsndfile-convert
find . -name "*.flac" -exec sndfile-convert -vorbis '{}' '{}'.oga \;


conversion examples with sox

convert a .wav file to raw PCM - here 8bit (-b 8) signed integer (-e signed), stereo (-c 2):

sox INFILE.wav -t raw -r 48k -e signed -b  8 -c 2 OUTFILE.raw

convert raw CD digital audio (16-bit, signed-integer) to floating point wav:

sox input.cdda -e float output1.wav

generate (-n = NULL input) a .wav file with a 3 second sine-sweep:

sox -n OUTFILE.wav synth 3 sine 300-3300 gain -5

The format-options must be given before the filename for which they're intended. If unspecified they are read from the file header (if possible):


sox [global-options] [format-options] infile1 \ 
    [[format-options] infile2] ... \
    [format-options] outfile \
    [effect [effect-options]] ...

Common encoding-types for -e: signed, unsigned, float. see man sox for a complete reference.

conversion examples with ecasound



move regions, markers, temi in an Ardour session

A script to slide every regions, markers, tempi, meters, automations, and so on in an Ardour session.

“Actually, it's not really a solution, as one can move only ALL REGIONS,…”

by Aurélien

announce mail

Download (tar.gz ?)


spaces to underscores

#! /bin/bash
echo "This command changes all spaces in file names into underscores"
echo "  Type ENTER to continue or ^C to quit"
read dummy
for f in *; do
 oldname=`echo $f |sed 's/ /~/g'`
 newname=`echo $f |sed 's/ /_/g'`
 if [ $oldname != $newname ]
   echo mv $f $newname
   mv "$f" $newname

(Marc Groenewegen, 25. September 2010 08:49 )



Extract Audio from Video and recombine

(help by Robin Gareus @lau-ml)

with ffmpeg

#extract audio
ffmpeg -i orig_video.wmv audio_out.wav

#replace audio
ffmpeg \
 -i orig_video.wmv \
 -i new_audio.wav \
 -vcodec copy \
 -map 0.0 -map 1.0 \
Details:  The "map" may be different depending on the .wmv file.
run `ffprobe` to see which is the video-track in the .wmv file
usually this is "0.0".
   Stream #0.0: Video:...
   Stream #0.1: Audio: ..
and "1.0" corresponds to the 2nd input file - your new audio.

You may want to add "-acodec wmav2" and "-ar 128k" options for 128kbit/s
Windows Media Audio 2 or whatever audio-codec/quality your want. `ffmpeg
-codecs | grep "EA"` gives you a list of available codecs for Encoding

BTW. Ardour3 with videotimeline patch can do all this for you. import,extract,re-encode using ffmpeg.

Thanks. It is 0:0 and 0:1 and -b:a=192k I found, but I have some sync problems after recombining tho. Any other ideas?

My gut feeling is to blame ffmpeg's WMV muxer (it may not be able to mux a bit-exact copy of the original video with your new soundtrack).

Try using '-sameq' instead of '-vcodec copy' (re-encode the video with
same quality rather than a bit-exact copy - this often solves muxing
issues but will cause a small loss of either video quality or increased

and also try a different output format eg. 'new_video.avi' or '' instead of 'new_video.wmv'.

you may need both, this should work:
 'ffmpeg -i vid.wmv -i aud.wav -sameq -map 0.0 -map 1.0 output.avi'

with mencoder

posssibly other options

  • kdenlive
  • ardour3 + video patch

JACKdbus - Desktop integration - backend-switching

save and restore irq process priorities

# rtirq_power: save and restore irq process priorities
# This script is called when a change in power status happens, when
# suspending it saves a list of all irq process priorities, when
# resuming it changes the priorities of the proper irq processes
# to the saved values
# Copyright (c) 2012 Fernando Lopez-Lezcano
#   This program is free software; you can redistribute it and/or
#   modify it under the terms of the GNU General Public License
#   as published by the Free Software Foundation; either version 2
#   of the License, or (at your option) any later version.
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   GNU General Public License for more details.
#   You should have received a copy of the GNU General Public License along
#   with this program; if not, write to the Free Software Foundation, Inc.,
#   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
case $1 in
	/bin/ps -eo rtprio=,comm= --sort -rtprio | /bin/egrep ' irq/[0-9]*' | savestate rtirq
	restorestate rtirq | while read IRQPRIO IRQCOMM ; do
	    if [ -n "${IRQPRIO}" -a -n "${IRQCOMM}" ] ; then
		IRQPID=`/bin/ps -e -o pid,comm | grep " ${IRQCOMM}" | awk '{print $1}'`
		if [ -n "${IRQPID}" ] ; then
		    PRIO=`/bin/ps -p ${IRQPID} -o rtprio=`
		    if [ ${PRIO} -ne ${IRQPRIO} ] ; then
			/usr/bin/chrt -f -p ${IRQPRIO} ${IRQPID}
    *) exit $NA



A first try at using a pm-utils script. This script saves the priority state of all irq* processes and restores them after a resume. It only restores the priority for processes that still exist after the resume, and will do nothing for new processes (ie: you plugin a usb card while the computer is sleeping). That would be taken care by my previously posted udev script which would change priority of newly inserted soundcards. I put 05rtirq it in /etc/pm/sleep.d/ directory… it seems to be working fine in my laptop.



use a proper python shell

(by Torben Hohn, 28. September 2010 01:16 )
ipython is there for quite some time.

and i recently discovered bpython

this is where the fun starts

also help() works nicely on instances.

doctests also pretty much kick ass.

Tip: Pianoteq - software synth - on Linux

(tip by: Edward Diehl, LAD, 2012-09-02)
I wanted to mention that Pianoteq does provide a linux VST which does work in Ardour and Qtractor. However, the default version provides 5 output channels which Ardour does not seem to like (because it expects stereo output). However, if you append “_2chan” to the plugin library name (e.g. to , the plugin will output only 2 channels and work happily in Ardour.

Lisalo - Linux Sampler Loader

(Thanks to Nils Gey)

This is the Release of Lisalo 1.0 Grab it here, no installing required: git clone

Linux Sampler Loader is a command line program (python) that loads entire directories of sample files or takes instructions from a meta .lsl file with relative paths to samples.

This program exists because you can't share linuxsampler lscp files or even move files around on your own disk. Lscp files only work with absolute paths and are too low level anyway.

Now you can quickly and easily load sampled instruments without even starting a GUI. The lsl files are very simple, see example.lsl, and can be shipped around with your sfz sample package like the Sonatina Symphonic Orchestra (lsl file already included in this release)

Version 1.0 Licensed under GPLv3 by Nils Gey, June 2012
Only dependencies are Python and Linuxsampler. # laborejo

wiki/scripts_and_tools.1346972780.txt.gz · Last modified: 2012/09/07 01:06 by emrum