no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
Previous revisionNext revision | |||
— | wiki:scripts_and_tools [2012/06/22 21:37] – [save and restore irq process priorities] emrum | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | |||
+ | ===== Assorted Linux Scripts, Tools, Tips and Utilities ===== | ||
+ | |||
+ | . | ||
+ | |||
+ | . | ||
+ | |||
+ | ==== wav file to specimen bank (sampler format) script ==== | ||
+ | |||
+ | * see here: [[/ | ||
+ | |||
+ | \\ | ||
+ | |||
+ | |||
+ | ==== lscp2rgd - linuxsampler to rosegarden instrument ==== | ||
+ | |||
+ | * see: [[/ | ||
+ | |||
+ | \\ | ||
+ | |||
+ | ==== 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 | ||
+ | |||
+ | [[http:// | ||
+ | |||
+ | \\ | ||
+ | |||
+ | [[http:// | ||
+ | |||
+ | \\ | ||
+ | |||
+ | [[http:// | ||
+ | |||
+ | \\ | ||
+ | |||
+ | |||
+ | ==== aj-snapshot - Store ALSA and JACK connections state ==== | ||
+ | |||
+ | [[http:// | ||
+ | |||
+ | . | ||
+ | |||
+ | ==== Download songs of an *.m3u File (mp3 collection) ==== | ||
+ | |||
+ | Make a directory and then do this: | ||
+ | |||
+ | < | ||
+ | wget -O - http:// | ||
+ | </ | ||
+ | |||
+ | (by Ken Restivo - 16. Mai 2011 22:06 - @lau-ml) | ||
+ | |||
+ | . | ||
+ | |||
+ | ==== make a *.wav swing (?) ==== | ||
+ | |||
+ | [[http:// | ||
+ | |||
+ | [[http:// | ||
+ | |||
+ | (by Chris Cannam - 2. Juni 2010 16:41 - @lau-ml ) | ||
+ | |||
+ | . | ||
+ | |||
+ | ==== jackctl - jack control python script ==== | ||
+ | |||
+ | [[http:// | ||
+ | |||
+ | [[http:// | ||
+ | |||
+ | (by Aaron Krister Johnson, | ||
+ | |||
+ | . | ||
+ | |||
+ | ==== 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. | ||
+ | |||
+ | [[http:// | ||
+ | |||
+ | (by Atte André Jensen, 11. Juni 2010 11:02 - @ lau-ml ) | ||
+ | |||
+ | . | ||
+ | |||
+ | |||
+ | ==== convert a Hydrogen drumkit into a SF2 soundfont ==== | ||
+ | |||
+ | [[http:// | ||
+ | |||
+ | . | ||
+ | |||
+ | |||
+ | ==== conversion examples with mplayer / mencoder ==== | ||
+ | |||
+ | === wav to mp3 === | ||
+ | |||
+ | < | ||
+ | for F in *.aac; do | ||
+ | mplayer -ao pcm: | ||
+ | lame -h $F.wav $F.mp3; | ||
+ | done | ||
+ | </ | ||
+ | |||
+ | (by Julien Claassen , 25. Dezember 2010 02:37 - @ lau-ml ) | ||
+ | |||
+ | . | ||
+ | |||
+ | < | ||
+ | |||
+ | #!/bin/bash | ||
+ | # flac_to_mp3 | ||
+ | for f in *.mp3; do lame -v " | ||
+ | </ | ||
+ | |||
+ | (James Morris,22. September 2010 11:20) | ||
+ | |||
+ | |||
+ | < | ||
+ | $ find . -name " | ||
+ | </ | ||
+ | |||
+ | (Roger, 22. September 2010 12:52) | ||
+ | |||
+ | === Using MEncoder to create DVD-compliant files === | ||
+ | |||
+ | [[http:// | ||
+ | |||
+ | . | ||
+ | |||
+ | === convert DV files to DVD compliant === | ||
+ | |||
+ | [[http:// | ||
+ | |||
+ | . | ||
+ | |||
+ | ==== 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: [[http:// | ||
+ | It is included in the ubuntu repository. | ||
+ | \\ | ||
+ | \\ | ||
+ | \\ | ||
+ | <code bash> | ||
+ | #!/bin/bash | ||
+ | |||
+ | ## UPDATE: sndfile-convert -vorbis | ||
+ | ## there are no options to control that, or compression rate. | ||
+ | ## so rather use " | ||
+ | ## there is also a py-script called " | ||
+ | |||
+ | # initial code by Emanuel Rumpf 2012-04 | ||
+ | # any re-use and modification permitted | ||
+ | |||
+ | # convert all FLAC files in a directory to OGA format | ||
+ | # (compressed, | ||
+ | # | ||
+ | # USAGE: | ||
+ | # first install libsndfile - in ubuntu: | ||
+ | # sudo | ||
+ | # | ||
+ | # copy this script to the files directory, make it executable | ||
+ | # edit config options below if necessary, run it | ||
+ | |||
+ | # TODO: allow file-names with spaces | ||
+ | |||
+ | |||
+ | # CONFIGURE HERE | ||
+ | |||
+ | # select file extension: | ||
+ | EXT_OLD=" | ||
+ | EXT_NEW=" | ||
+ | |||
+ | # select directory for new vfiles | ||
+ | OUT_DIR=" | ||
+ | |||
+ | # add -vorbis parameter to sndfile-convert call | ||
+ | CONVERT_OPT=" | ||
+ | |||
+ | |||
+ | # CODE START | ||
+ | |||
+ | mkdir -p " | ||
+ | |||
+ | # apply to all flac files in current directory | ||
+ | FILES=*${EXT_OLD} | ||
+ | |||
+ | for f in $FILES | ||
+ | do | ||
+ | |||
+ | fn=`basename " | ||
+ | fn=" | ||
+ | | ||
+ | comm=" | ||
+ | echo " | ||
+ | $comm | ||
+ | echo "" | ||
+ | |||
+ | done | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | </ | ||
+ | \\ | ||
+ | \\ | ||
+ | < | ||
+ | # There is a possilbe alternative, | ||
+ | # | ||
+ | # warning: this is not verbose | ||
+ | |||
+ | |||
+ | # for all files in current directory (.) execute libsndfile-convert | ||
+ | # | ||
+ | find . -name " | ||
+ | |||
+ | </ | ||
+ | |||
+ | . | ||
+ | |||
+ | ==== conversion examples with sox ==== | ||
+ | |||
+ | convert a .wav file to raw PCM - here 8bit ('' | ||
+ | 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 ('' | ||
+ | sox -n OUTFILE.wav synth 3 sine 300-3300 gain -5 | ||
+ | |||
+ | The format-options must be given before the filename for which they' | ||
+ | |||
+ | Synopsis: | ||
+ | sox [global-options] [format-options] infile1 \ | ||
+ | [[format-options] infile2] ... \ | ||
+ | [format-options] outfile \ | ||
+ | [effect [effect-options]] ... | ||
+ | | ||
+ | Common encoding-types for '' | ||
+ | |||
+ | ==== conversion examples with ecasound ==== | ||
+ | |||
+ | FIXME | ||
+ | |||
+ | . | ||
+ | |||
+ | |||
+ | |||
+ | ==== move regions, markers, temi in an Ardour session ==== | ||
+ | |||
+ | A script to slide every regions, markers, tempi, meters, automations, | ||
+ | |||
+ | " | ||
+ | |||
+ | by Aurélien | ||
+ | |||
+ | [[http:// | ||
+ | |||
+ | [[http:// | ||
+ | |||
+ | . | ||
+ | |||
+ | |||
+ | |||
+ | ==== spaces to underscores ==== | ||
+ | |||
+ | <code bash> | ||
+ | #! /bin/bash | ||
+ | # | ||
+ | # spaces2underscores.sh | ||
+ | |||
+ | echo | ||
+ | echo "This command changes all spaces in file names into underscores" | ||
+ | echo " | ||
+ | echo " | ||
+ | |||
+ | read dummy | ||
+ | |||
+ | for f in *; do | ||
+ | | ||
+ | | ||
+ | if [ $oldname != $newname ] | ||
+ | then | ||
+ | echo mv $f $newname | ||
+ | mv " | ||
+ | fi | ||
+ | done | ||
+ | </ | ||
+ | |||
+ | (Marc Groenewegen, | ||
+ | |||
+ | . | ||
+ | |||
+ | . | ||
+ | |||
+ | |||
+ | ==== 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 \ | ||
+ | | ||
+ | -map 0.0 -map 1.0 \ | ||
+ | | ||
+ | |||
+ | </ | ||
+ | |||
+ | |||
+ | < | ||
+ | Details: | ||
+ | run `ffprobe` to see which is the video-track in the .wmv file | ||
+ | usually this is " | ||
+ | | ||
+ | | ||
+ | and " | ||
+ | |||
+ | You may want to add " | ||
+ | Windows Media Audio 2 or whatever audio-codec/ | ||
+ | -codecs | grep " | ||
+ | Audio. | ||
+ | |||
+ | </ | ||
+ | |||
+ | |||
+ | BTW. Ardour3 with videotimeline patch can do all this for you. | ||
+ | import, | ||
+ | |||
+ | |||
+ | |||
+ | >> 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' | ||
+ | a bit-exact copy of the original video with your new soundtrack). | ||
+ | |||
+ | < | ||
+ | |||
+ | Try using ' | ||
+ | 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 | ||
+ | bandwidth). | ||
+ | |||
+ | </ | ||
+ | |||
+ | and also try a different output format eg. ' | ||
+ | instead of ' | ||
+ | |||
+ | < | ||
+ | |||
+ | you may need both, this should work: | ||
+ | ' | ||
+ | |||
+ | </ | ||
+ | |||
+ | \\ | ||
+ | |||
+ | === with mencoder === | ||
+ | |||
+ | [[http:// | ||
+ | |||
+ | \\ | ||
+ | |||
+ | === posssibly other options === | ||
+ | |||
+ | \\ | ||
+ | * kdenlive | ||
+ | * ardour3 + video patch | ||
+ | |||
+ | \\ | ||
+ | \\ | ||
+ | |||
+ | |||
+ | ==== JACKdbus - Desktop integration - backend-switching ==== | ||
+ | * [[http:// | ||
+ | * [[http:// | ||
+ | |||
+ | \\ | ||
+ | \\ | ||
+ | |||
+ | ==== save and restore irq process priorities ==== | ||
+ | \\ | ||
+ | <code bash> | ||
+ | |||
+ | #!/bin/bash | ||
+ | # | ||
+ | # rtirq_power: | ||
+ | # | ||
+ | # 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 | ||
+ | # | ||
+ | # 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 | ||
+ | hibernate|suspend) | ||
+ | /bin/ps -eo rtprio=, | ||
+ | ;; | ||
+ | thaw|resume) | ||
+ | restorestate rtirq | while read IRQPRIO IRQCOMM ; do | ||
+ | if [ -n " | ||
+ | IRQPID=`/ | ||
+ | if [ -n " | ||
+ | PRIO=`/ | ||
+ | if [ ${PRIO} -ne ${IRQPRIO} ] ; then | ||
+ | / | ||
+ | fi | ||
+ | fi | ||
+ | fi | ||
+ | done | ||
+ | ;; | ||
+ | *) exit $NA | ||
+ | ;; | ||
+ | esac | ||
+ | |||
+ | |||
+ | </ | ||
+ | |||
+ | \\ | ||
+ | < | ||
+ | |||
+ | 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 / | ||
+ | |||
+ | </ | ||
+ | \\ | ||
+ | \\ | ||
+ | \\ | ||
+ | \\ | ||
+ | |||
+ | |||
+ | |||
+ | ==== Lisalo - Linux Sampler Loader ==== | ||
+ | (Thanks to Nils Gey) | ||
+ | \\ | ||
+ | \\ | ||
+ | |||
+ | This is the Release of Lisalo 1.0 | ||
+ | Grab it here, no installing required: | ||
+ | git clone git:// | ||
+ | \\ | ||
+ | \\ | ||
+ | |||
+ | 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. | ||
+ | \\ | ||
+ | \\ | ||
+ | https:// | ||
+ | \\ | ||
+ | irc.freenode.org #laborejo | ||
+ | |||
+ | \\ | ||
+ | \\ | ||
+ | \\ | ||
+ | |||
+ | |||
+ | ==== Tips ==== | ||
+ | |||
+ | |||
+ | === 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 | ||
+ | |||
+ | [[http:// | ||
+ | |||
+ | [[http:// | ||
+ | |||
+ | this is where the fun starts | ||
+ | |||
+ | also help() works nicely on instances. | ||
+ | |||
+ | doctests also pretty much kick ass. | ||
+ | |||
+ | [[http:// | ||
+ | |||
+ | |||
+ | |||
+ | |||