#!/bin/bash - ############################################################ # This script is destructive recursively, to any files # and directories, from where it is run from. Backup first! # All samples should be named like "blah 12.wav" or # "blah 25.wav" etc "blah n.wav" where n is the note number. # It should be run from the folder above the folders with # the samples in. # # This script will play samples out and record them back in # capturing external fx and also create release samples # from the captured fx samples (for reverb). It will remove # silence from the ends of the samples (fx'ed and non fx'ed). # Sounds should not have gaps in the middle of them as it # will count everything after as silence for that sample.It # will also put all samples through a slight limiter, # normalise them and dither them. It was made to record an # external reverb unit on guitar samples and create release # samples to be used in gigasudio/linuxsampler. It should # work on anything else that fits this description (with a # few tweaks, such as silence detection level etc or # commenting out lines i.e. if no release samples are needed). # # sh GigaSampleSort.sh (from top sample folder) or # sh GigaSampleSort.sh 2>&1 | tee /tmp/output2.txt (for log) ############################################################ #change permissions of all directories recursively /usr/bin/find . -type d -exec /bin/chmod 755 {} \; #change permissions of all files recursively /usr/bin/find . -type f -exec /bin/chmod 644 {} \; #find all .wav files recursively from current directory /usr/bin/find . -name "*.wav" > list #replace spaces with ? in list filenames /bin/sed 's/\ /?/' list >list2 #remove ./ from list2 filenames /bin/sed 's/.\///' list2 >alloriginalsamples #copy directory structure to new folder tailrev. /usr/bin/find . -type d -print | /bin/cpio -pdumv tailrev for i in `/bin/cat alloriginalsamples` do #convert to signed 16bit wavs ready for ssrc sox "$i" -s -2 "$i".wav #increase vol and limit peaks then remove silence from #end of files. Back slash at end of line makes 2 lines as 1 /usr/bin/sox "$i".wav "$i" vol 1.5 amplitude 0.2 \ silence 0 1 00:00:00.1 -46d #normalize and dither /usr/bin/ssrc --normalize --twopass --dither 3 \ --pdf 2 "$i" "$i".wav /bin/mv "$i".wav "$i" #chop and fade out tailrev samples /usr/bin/sox "$i" tailrev/"$i" fade p 0 0:00.5 0:00.125 done #list all .wav files recursively from current directory /usr/bin/find . -name "*.wav" > list #replace spaces with ? in list filenames /bin/sed 's/\ /?/' list >list2 #remove ./ from list2 filenames /bin/sed 's/.\///' list2 >alldrysamples #copy directory structure to new folder reverb. /usr/bin/find . -type d -print | /bin/cpio -pdumv reverb for i in `cat alldrysamples` do #play all samples out of channel 3 and record in channel 2 #and stop recording when silence is detected (reverb hooked #to 3 out and returns to in2). save in reverb folder. /usr/bin/sox "$i" -c 1 -r 44100 -2 -s -t alsa sox3 | \ /usr/bin/sox -c 1 -r 44100 -2 -s -t alsa sox2 -t wav -r 44100 \ -2 -s reverb/"$i" silence 0 1 00:00:00.1 -70d done #list all .wav files recursively from reverb directory /usr/bin/find ./reverb -name "*.wav" >list #replace spaces with ? in list filenames /bin/sed 's/\ /?/' list >list2 #remove ./ from list2 filenames /bin/sed 's/.\///' list2 >allreverbsamples for i in `/bin/cat allreverbsamples` do #increase vol and limit peaks (of all Reverbed) /usr/bin/sox "$i" "$i".wav vol 1.5 amplitude 0.2 #normalize all reverb samples /usr/bin/ssrc --normalize --twopass "$i".wav "$i" /bin/rm "$i".wav done /usr/bin/find ./reverb/tailrev -name "*.wav" >list #replace spaces with ? in list filenames /bin/sed 's/\ /?/' list >list2 #remove ./ from list2 filenames /bin/sed 's/.\///' list2 >allreverbtailsamples for i in `/bin/cat allreverbtailsamples` do #trim first 0.51 seconds off beginning leaving just tail /usr/bin/sox "$i" "$i".wav trim 0:00.51 #fade in fast the start of reverb tail samples to avoid clicks /usr/bin/sox "$i".wav "$i" fade 0:00.05 /bin/rm "$i".wav done for i in `/bin/cat allreverbsamples` do #dither all reverb samples /usr/bin/ssrc --twopass --dither 3 --pdf 2 "$i" "$i".wav /bin/mv "$i".wav "$i" #rename reverb sample from "blah nn.wav" to "blahReverb nn.wav" /usr/bin/rename \ Reverb\ "$i" done cd reverb/tailrev #rename all folders in tailrev to include reverb for i in `/bin/ls`; do /bin/mv "$i" "$i"ReverbTail; done cd .. #name folders in tailrev to include ReverbTail for i in `/bin/ls`; do /bin/mv "$i" "$i"Reverb; done #back to main folder cd .. /bin/mv reverb/tailrevReverb reverb/tailrev /usr/bin/find ./reverb/tailrev -name "*.wav" >list #replace spaces with ? in list filenames /bin/sed 's/\ /?/' list >list2 #remove ./ from list2 filenames /bin/sed 's/.\///' list2 >allreverbtailsamples for i in `/bin/cat allreverbtailsamples` do #name files below tailrev to include ReverbTail /usr/bin/rename Reverb\ ReverbTail\ "$i" done #clean up /bin/rm all* /bin/rm list* /bin/rm -R tailrev