Let's say you've recorded a track in LMMS that is composed of 10 measures *of equal length*, at 140 BPM (beats per minute) and you want to convert each measure to its own wav file loop, i.e. 10 individual loop files.
The script below does exactly this.
To use this script in linux:
0) make sure you have installed sox:
sudo apt-get install sox
1) paste the bash script code below into a new file called makeloops.sh and save it somewhere, e.g. ~/Downloads/ (the Downloads folder in your home directory, i.e. /home/me/Downloads)
2) make the bash script file executable:
chmod +x ~/Downloads/makeloops.sh
3) cd to the folder where your wav file (e.g. input.wav) is, e.g.:
cd ~/lmms/projects/your-lmms-project/
4) run makeloops.sh, e.g.:
. ~/Downloads/makeloops.sh input.wav 140 10 1
###### makeloops.sh (START COPYING BELOW THIS LINE) ####
#!/bin/bash
# INPUT PARAMETERS: $1==inputfile name (e.g. input.wav), $2==bpm (e.g. 140), $3==total measures of input file (e.g. 10), $4==loop length measures (e.g. 1), $5==loop folder name (e.g. loops)
#
# e.g. say you have a wav file, input.wav, that contains 10 measures *of equal length* of 140 BPM audio and you want to convert each measure to its own wav file loop:
#
# SEE "HELP" SECTION FOR EXAMPLE
#
EXPECTED_ARG_COUNT=5
# HELP
# IF NUMBER OF PARAMS < 5, OUTPUT HELP TEXT
if [ $# -ne $EXPECTED_ARG_COUNT ]
then
echo "";
echo "USAGE: makeloops.sh input-file-name BPM total-number-of-measures-in-input-file number-of-measures-for-loop-length loop-folder-name";
echo "";
echo "EXAMPLE: nickleus@mylaptop:/path/to/input/wav/file/$ . /path/to/makeloops.sh input.wav 140 10 1 loops";
echo "";
else
LOOPSTART=0;
BPS=$(echo $2/60|bc -l);
BEATS=$(echo 4*$4|bc -l);
LOOPLENGTH=$(echo $BEATS/$BPS | bc -l | awk '{printf("%.7f", $1);}'); # max 7 digits to the right of the decimal place for float numbers, no leading zeros on left side of decimal place
# INPUT ($2) 140 ($3) 10 ($4) 1
#echo $BPS # 2.33333333333333333333
#echo $BEATS # 4
#echo $LOOPLENGTH # 1.7142857
LOOPSFOLDER=$5;
mkdir $LOOPSFOLDER;
for (( w = 0 ; w < $3 ; w++ ));
do
sox -V4 "$1" "./$LOOPSFOLDER/$w.wav" trim $LOOPSTART $LOOPLENGTH;
LOOPSTART=$(echo $LOOPSTART+$LOOPLENGTH|bc -l);
done;
fi
###### (STOP COPYING ABOVE THIS LINE) ####
Note: If you don't want sox to run in full verbose mode, then just remove -V4; but it can be interesting to see what sox is actually doing during conversion.
Posts about music analysis, theory, composition, production in Ubuntu Linux n Mac OSX (software, tips, technical tutorials, etc), showcasing of my own music and other artists' music.
My Music (Listen with quality headphones)
Showing posts with label script. Show all posts
Showing posts with label script. Show all posts
Sunday, 17 February 2013
Saturday, 9 February 2013
How to remove the click at the end of loops exported from LMMS
UPDATE 20130210: Apparently the problem is with VST plugins because you can't use their envelope settings to set release to 0 (which would fix the problem):
"Note: the first thing that must be emphasized is that no VeSTige instrument will respond to anything on this tab! You can't use envelopes or filters, because VST generates sounds using an internal method that excludes LMMS's envelopes completely."
In LMMS 0.4.14-rc1 you can export tracks as loops:
Project > Export > choose filename > Save > click "Export as loop" > Start
If you open the loop in e.g. Audacity and loop it, you might hear a little click sound at the end of the file. This can be because the wav doesn't end in the middle, i.e.:
To fix this for a specific file, you can do it manually in Audacity by selecting the last part of the wav where it's in the middle, then hold in the Shift key and press the End key > Effect > Fade Out.
To fix this in a batch process, for many files, automatically, do this:
0) If you don't have sox installed:
sudo apt-get install sox
1) Open a terminal. Change directory to the folder containing the loop files to post-process:
cd /path/to/loops/to/fix/
2) Loop through the files and add a fade out effect using sox:
for w in *.wav;do sox "$w" "${w%.wav}_.wav" fade 0 $(soxi -D $w) 0.00045;done
Note: soxi -D $w outputs the length of the audio input file.
"Note: the first thing that must be emphasized is that no VeSTige instrument will respond to anything on this tab! You can't use envelopes or filters, because VST generates sounds using an internal method that excludes LMMS's envelopes completely."
In LMMS 0.4.14-rc1 you can export tracks as loops:
Project > Export > choose filename > Save > click "Export as loop" > Start
If you open the loop in e.g. Audacity and loop it, you might hear a little click sound at the end of the file. This can be because the wav doesn't end in the middle, i.e.:
To fix this for a specific file, you can do it manually in Audacity by selecting the last part of the wav where it's in the middle, then hold in the Shift key and press the End key > Effect > Fade Out.
To fix this in a batch process, for many files, automatically, do this:
0) If you don't have sox installed:
sudo apt-get install sox
1) Open a terminal. Change directory to the folder containing the loop files to post-process:
cd /path/to/loops/to/fix/
2) Loop through the files and add a fade out effect using sox:
for w in *.wav;do sox "$w" "${w%.wav}_.wav" fade 0 $(soxi -D $w) 0.00045;done
Note: soxi -D $w outputs the length of the audio input file.
Subscribe to:
Posts (Atom)
My content is under the Creative Commons Attribution 3.0 license. I work hard to publish relevant and useful information in order to help people learn difficult things and find solutions to their problems, so please attribute me if you reuse my content elsewhere.


