Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
wiki:scripts_and_tools [2011/06/30 19:06]
emrum
wiki:scripts_and_tools [2017/12/03 12:22] (current)
nilsge [Lisalo - Linux Sampler Loader]
Line 19: Line 19:
 \\ \\
  
-==== lscp2rgd - linuxsampler ​to rosegarden instrument ​====+==== midi to hydrogen ​====
  
   * [[/​wiki/​script_midi2hydrogen| convert drums of a midi file to hydrogen format ]]   * [[/​wiki/​script_midi2hydrogen| convert drums of a midi file to hydrogen format ]]
 +
 +\\
 +
 +
 +
 +==== SFZ (sound-bank-definition) to Hydrogen (drumkit xml-file) ====
 +
 +
 +  * [[/​wiki/​user/​emrum/​sfz_to_h2| sfz to hydrogen script ]]
 +
 +
 +\\
 +
 +==== script: create a hydrogen drumkit from wav files ===
 +
 +thanks to Thijs van Severen
 +
 +[[http://​audio-and-linux.blogspot.de/​2012/​04/​hydrogen-drumkit-creator-script.html| ​ Hydrogen drumkit creator script ]] - note: filenames have to follow a rule
 +
 +\\
 +
 +[[http://​www.hydrogen-music.org/​hcms/​node/​5#​sect.pattern_editor.drumkit| Instrument mapping (Hydrogen Manual) ]]
 +
 +\\
 +
 +[[http://​www.mindwaremusic.com/​SoundsetterHelp/​scr/​GMDrumMap.html| GM (general midi) mapping ]]
  
 \\ \\
Line 127: Line 153:
 . .
  
-=== convert sound files with libsndfile ===+==== convert sound files with libsndfile ​====
  
-sndfile-convert+ 
 +=== 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://​soundconverter.org/​| SoundConverter ]] \\ 
 +It is included in the ubuntu repository. 
 +\\ 
 +\\ 
 +\\ 
 +<code bash> 
 +#​!/​bin/​bash 
 + 
 +## 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) 
 +
 +# USAGE: 
 +# 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 
 + 
 + 
 +# CONFIGURE HERE 
 + 
 +# select file extension:​ 
 +EXT_OLD="​.flac"​ 
 +EXT_NEW="​.oga"​ 
 + 
 +# select directory for new vfiles 
 +OUT_DIR="​./​oggs/"​ 
 + 
 +# add -vorbis parameter to sndfile-convert call 
 +CONVERT_OPT="​-vorbis"​ 
 + 
 + 
 +# CODE START 
 + 
 +mkdir -p "​$OUT_DIR"​ 
 + 
 +# apply to all flac files in current directory 
 +FILES=*${EXT_OLD} 
 + 
 +for f in $FILES 
 +do 
 + 
 +  fn=`basename "​$f"​ $EXT_OLD` 
 +  fn="​${OUT_DIR}${fn}${EXT_NEW}"​ 
 +   
 +  comm="​sndfile-convert $CONVERT_OPT $f $fn " 
 +  echo "​-->​ $comm " 
 +  $comm 
 +  echo ""​ 
 + 
 +done 
 + 
 + 
 + 
 + 
 +</​code>​ 
 +\\ 
 +\\ 
 +<​code>​ 
 +# 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 \; 
 + 
 +</​code>​
  
 . .
Line 209: Line 316:
 . .
  
-==== Tips ==== 
  
 +==== Extract Audio from Video and recombine ====
 +(help by Robin Gareus @lau-ml)
  
-=== use a proper python shell ===+=== with ffmpeg ​===
  
-(by Torben Hohn, 28. September 2010 01:16 )+<​code>​
  
 +#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 \
 + ​new_video.wmv
 +
 +</​code>​
 +
 +
 +<​code>​
 +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
 +Audio.
 +
 +</​code>​
 +
 +
 +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).
 +
 +<​code>​
 +
 +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
 +bandwidth).
 +
 +</​code>​
 +
 +and also try a different output format eg. '​new_video.avi'​ or '​..mov'​
 +instead of '​new_video.wmv'​.
 +
 +<​code>​
 +
 +you may need both, this should work:
 + '​ffmpeg -i vid.wmv -i aud.wav -sameq -map 0.0 -map 1.0 output.avi'​
 +
 +</​code>​
 +
 +\\
 +
 +=== with mencoder ===
 +
 +[[http://​savvyadmin.com/​extract-audio-from-video-files-to-wav-using-mplayer/​]]
 +
 +\\
 +
 +=== posssibly other options ===
 +
 +\\
 +  * kdenlive
 +  * ardour3 + video patch
 +
 +\\
 +\\
 +
 +
 +==== JACKdbus - Desktop integration - backend-switching ====
 +  * [[http://​gareus.org/​blog/​jack2dbus| jack2 backend switching ]]
 +  * [[http://​gareus.org/​wiki/​jack2contol|jack2 dbus control ]]
 +
 +\\
 +\\
 +
 +==== save and restore irq process priorities ====
 +\\
 +<code bash>
 +
 +#!/bin/bash
 +#
 +# 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
 +#   ​MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ​ See the
 +#   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.
 +
 +. "​${PM_FUNCTIONS}"​
 +
 +case $1 in
 +    hibernate|suspend)
 + /bin/ps -eo rtprio=,​comm= --sort -rtprio | /bin/egrep ' irq/​[0-9]*'​ | savestate rtirq
 +        ;;
 +    thaw|resume)
 + 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}
 +     fi
 + fi
 +     fi
 + done
 +        ;;
 +    *) exit $NA
 +        ;;
 +esac
 +
 +
 +</​code>​
 +
 +\\
 +.
 +
 +<​quote>​
 +
 +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.
 +
 +</​quote>​
 +\\
 +\\
 +\\
 +\\
 +
 +
 +
 +\\
 +
 +
 +===== Tips =====
 +
 +\\
 +
 +==== use a proper python shell ====
 +\\
 +(by Torben Hohn, 28. September 2010 01:16 )
 +\\
 ipython is there for quite some time. ipython is there for quite some time.
  
 and i recently discovered bpython and i recently discovered bpython
  
-[[http://​ipython.scipy.org/​moin/​]]+  * [[http://​ipython.scipy.org/​moin/​]]
  
-[[http://​bpython-interpreter.org/​]]+  * [[http://​bpython-interpreter.org/​]]
  
 this is where the fun starts this is where the fun starts
Line 229: Line 502:
  
 doctests also pretty much kick ass. doctests also pretty much kick ass.
 +\\
 [[http://​docs.python.org/​library/​doctest.html]] [[http://​docs.python.org/​library/​doctest.html]]
 +
 +
 +\\
 +\\
 +
 +
 +==== 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. Pianoteq.so to Pianoteq_2chan.so) , the plugin will output
 +only 2 channels and work happily in Ardour.
 +\\
 +\\
 +
  
  
wiki/scripts_and_tools.1309453597.txt.gz · Last modified: 2011/06/30 19:06 by emrum