Remastersys and AVLinux Forum
May 22, 2013, 09:05:19 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Remastersys depends on user donations to survive.  Please help keep Remastersys going.

http://www.remastersys.com
 
   Home   Remastersys Home Remastersys downloads Donate Login Register AV LINUX Home Help Search  
Pages: [1]
  Print  
Author Topic: makesfz.sh makes using wavs under Linuxsampler simple  (Read 2125 times)
0 Members and 1 Guest are viewing this topic.
danboid
Full Member
***
Offline Offline

Posts: 46


« on: January 30, 2012, 02:38:56 PM »

I thought it time I gave the suggestions board a break and post my next plea for an addition here disguised as an announcement instead? Wink

Well, this is legitimately an announcement too as I'm plugging my own wares here but I do fully expect that many other AV Linux users could find themselves also making frequent use of this little script I wrote to convert a folder full of wav files into either several or one big .sfz file for use under Linuxsampler.

As far as I'm concerned this was the key missing script/feature from Linuxsampler for the last however many years its been around. I tried asking the LS devs if they'd be interested in including it or an improved version of it but they haven't responded so I've took that as a no.

As I wrote on its original home of:

http://bb.linuxsampler.org/viewtopic.php?f=7&t=667&sid=a9b9c8e0c9d7d16fe7f3dbcca5a6d00f

I needed a way to quickly and easily create simple drum kit .sfz files for use with Linuxsampler. I had found a perl script called makesfz.pl that I failed to get to work and I couldn't find a suitable script or app within these forums or linked to on linuxsampler.org so I wrote the following little bash script that scans for wav files in the current dir then writes out a corresponding .sfz file for every wav found, mapping that sample to MIDI note 0.

Otherwise you can run it like 'makesfz.sh 1' in which case it simply creates one big .sfz named after the containing folder which assigns each sample to a MIDI note ('key'), ascending through the filenames alphabetically and pairing these with a progressively higher MIDI note (Linuxsampler 'key') so it is recommended that you name your files like:

000-kick.wav
001-snare.wav

etc. etc. so you know which sample will be assigned to which key although this isn't a requirement.

If others do find this useful it'd be nice to see it included in AV Linux (in the $PATH as an executable called just makesfz please GMaq!)

Code:
#!/bin/bash
#
# makesfz.sh
#
# Running 'makesfz.sh' with no or any other parameter than 1 will create a .sfz
# file for every wav file in the present dir. mapping the wav to MIDI note 0.
#
# Alternatively, 'makesfz.sh 1' reads all wav files in the current dir and creates
# a single .sfz named after the present folder mapping each sample to a MIDI note.
#
#
# by Dan MacDonald 2012

key=0

if [ "$1" = "1" ]; then

rm -f "${PWD##*/}".sfz
echo -e "# This file was auto-generated by makesfz.sh\n\n<group>\nloop_mode=one_shot\n" > "${PWD##*/}".sfz

for wavs in *.wav

do
echo -e "<region>\nsample=$wavs\nkey=$key\nlovel=0 hivel=127\n" >> "${PWD##*/}".sfz
key=$(($key+1))
done

else

for wavs in *.wav

do
echo -e "# This file was auto-generated by makesfz.sh\n\n<group>\nloop_mode=one_shot\n" > $wavs.sfz
echo -e "<region>\nsample=$wavs\nkey=0\nlovel=0 hivel=127\n" >> $wavs.sfz
done

fi
« Last Edit: February 01, 2012, 11:59:57 AM by danboid » Logged
GMaq
Administrator
Hero Member
*****
Offline Offline

Posts: 2160


A/V 'Nixer


WWW
« Reply #1 on: January 30, 2012, 03:06:11 PM »

Hi,

Nice...Thanks for sharing. As it happens I'm just minting the final ISO for 5.0.3 so your little script will just squeak on at the last possible second...

**EDIT**

I tested it on the drum samples that come with AV Linux, not using '1' mode is OK but there is a problem with '1' mode which spews this:

tester@av502devel:~/Extra Goodies/Numbered Drum Samples$ makesfz.sh 1
/usr/bin/makesfz.sh: line 19: ${PWD##*/}.sfz: ambiguous redirect
/usr/bin/makesfz.sh: line 24: ${PWD##*/}.sfz: ambiguous redirect
/usr/bin/makesfz.sh: line 24: ${PWD##*/}.sfz: ambiguous redirect
/usr/bin/makesfz.sh: line 24: ${PWD##*/}.sfz: ambiguous redirect
/usr/bin/makesfz.sh: line 24: ${PWD##*/}.sfz: ambiguous redirect
/usr/bin/makesfz.sh: line 24: ${PWD##*/}.sfz: ambiguous redirect
/usr/bin/makesfz.sh: line 24: ${PWD##*/}.sfz: ambiguous redirect
/usr/bin/makesfz.sh: line 24: ${PWD##*/}.sfz: ambiguous redirect
/usr/bin/makesfz.sh: line 24: ${PWD##*/}.sfz: ambiguous redirect
/usr/bin/makesfz.sh: line 24: ${PWD##*/}.sfz: ambiguous redirect
/usr/bin/makesfz.sh: line 24: ${PWD##*/}.sfz: ambiguous redirect
/usr/bin/makesfz.sh: line 24: ${PWD##*/}.sfz: ambiguous redirect
/usr/bin/makesfz.sh: line 24: ${PWD##*/}.sfz: ambiguous redirect
/usr/bin/makesfz.sh: line 24: ${PWD##*/}.sfz: ambiguous redirect
/usr/bin/makesfz.sh: line 24: ${PWD##*/}.sfz: ambiguous redirect
/usr/bin/makesfz.sh: line 24: ${PWD##*/}.sfz: ambiguous redirect
/usr/bin/makesfz.sh: line 24: ${PWD##*/}.sfz: ambiguous redirect
/usr/bin/makesfz.sh: line 24: ${PWD##*/}.sfz: ambiguous redirect
/usr/bin/makesfz.sh: line 24: ${PWD##*/}.sfz: ambiguous redirect
/usr/bin/makesfz.sh: line 24: ${PWD##*/}.sfz: ambiguous redirect
/usr/bin/makesfz.sh: line 24: ${PWD##*/}.sfz: ambiguous redirect
/usr/bin/makesfz.sh: line 24: ${PWD##*/}.sfz: ambiguous redirect
/usr/bin/makesfz.sh: line 24: ${PWD##*/}.sfz: ambiguous redirect
/usr/bin/makesfz.sh: line 24: ${PWD##*/}.sfz: ambiguous redirect
/usr/bin/makesfz.sh: line 24: ${PWD##*/}.sfz: ambiguous redirect
/usr/bin/makesfz.sh: line 24: ${PWD##*/}.sfz: ambiguous redirect
/usr/bin/makesfz.sh: line 24: ${PWD##*/}.sfz: ambiguous redirect
/usr/bin/makesfz.sh: line 24: ${PWD##*/}.sfz: ambiguous redirect
/usr/bin/makesfz.sh: line 24: ${PWD##*/}.sfz: ambiguous redirect
/usr/bin/makesfz.sh: line 24: ${PWD##*/}.sfz: ambiguous redirect
/usr/bin/makesfz.sh: line 24: ${PWD##*/}.sfz: ambiguous redirect
tester@av502devel:~/Extra Goodies/Numbered Drum Samples$

I tried it again with different filenames and the result was the same, I really need to finish this ISO today while time allows both for my mental health and to use for the release tutorial. If you can get the bugs ironed out I'll make a Debian package out of it at a later time. Again thanks for sharing it will certainly be a handy critter!
« Last Edit: January 30, 2012, 04:04:44 PM by GMaq » Logged

AV Linux, Proudly created with Remastersys: http://www.bandshed.net/AVLinux.html
danboid
Full Member
***
Offline Offline

Posts: 46


« Reply #2 on: January 31, 2012, 07:09:42 PM »

Hi GMaq!

It would indeed be great if this script could make it onto 5.0.3 so I'm sorry to hear you get that error when using 'makesfz 1'. I've been using this script under AV 5.0.2 and I have yet to see that error but I must confess this script has only been used by one other person that I'm aware of so far so I'd be lieing if I said it had been extensively tested. I thought it may be due to spaces in file names but thats not it.

You are using bash as your shell right? 'echo $SHELL' tells you that. Could you give a listing of the files in the directory that you ran 'makesfz 1' and got that error with please?
Logged
GMaq
Administrator
Hero Member
*****
Offline Offline

Posts: 2160


A/V 'Nixer


WWW
« Reply #3 on: January 31, 2012, 08:09:51 PM »

Hi,

Yes bash is the default shell on AV unlike Squeeze which uses dash. The folder I'm testing the script with in is the 'Numbered Drum Samples' folder that should be in your users home in the 'Extra Goodies' folder in the 5.0.2 release... you didn't delete it did you danboid ??
Logged

AV Linux, Proudly created with Remastersys: http://www.bandshed.net/AVLinux.html
danboid
Full Member
***
Offline Offline

Posts: 46


« Reply #4 on: February 01, 2012, 12:09:35 PM »

Hi GMaq!

Thanks for testing out my script and reporting your prob.

Turns out that when you ran the old script via 'makesfz 1' in a directory with spaces in its name it would produce that error. I fixed it by quoting the variable in question as I should've done originally so I have updated the script in both the OP in this thread and on the LS forums appropriately, hopefully in time to make it onto 5.0.3!
Logged
GMaq
Administrator
Hero Member
*****
Offline Offline

Posts: 2160


A/V 'Nixer


WWW
« Reply #5 on: February 01, 2012, 02:14:29 PM »

OK thanks,

Due to Openshot's 1.4.1 problems your little script will make it... Smile
Logged

AV Linux, Proudly created with Remastersys: http://www.bandshed.net/AVLinux.html
GMaq
Administrator
Hero Member
*****
Offline Offline

Posts: 2160


A/V 'Nixer


WWW
« Reply #6 on: February 01, 2012, 02:38:18 PM »

danboid

Here's a nice little package to share with your friends: http://www.bandshed.net/custom/makesfz_0.1avlinux-1_all.deb
Logged

AV Linux, Proudly created with Remastersys: http://www.bandshed.net/AVLinux.html
danboid
Full Member
***
Offline Offline

Posts: 46


« Reply #7 on: February 02, 2012, 04:23:10 AM »

Thats great to hear my script will make it onto 5.0.3 and thanks for packaging it for Deb!

What are the chances of making any additions to the fine manual at this late stage as I suggested last night over at:

http://www.remastersys.com/forums/index.php?topic=1892.0

?

As I say there, I don't want to see the manual turn into an extended JACK manual but I think explaining the JACK client timeout value is very important to anyone hoping to use softsynths under AV Linux which is likely an increasingly large part of its userbase, otherwise I suppose just upping its default value would do the trick in a more discrete and less informative way too.
Logged
GMaq
Administrator
Hero Member
*****
Offline Offline

Posts: 2160


A/V 'Nixer


WWW
« Reply #8 on: February 02, 2012, 08:55:31 AM »

Hi,

Yes the change is in the manual, you can read it here: http://bandshed.net/pdf/AV503Manual.pdf
Logged

AV Linux, Proudly created with Remastersys: http://www.bandshed.net/AVLinux.html
danboid
Full Member
***
Offline Offline

Posts: 46


« Reply #9 on: February 02, 2012, 12:56:25 PM »

Thats brilliant GMaq but may I so boldly suggest you sub 'for better stability' at the end of p37 for 'to give the plugins longer to load' if you can cram that it there and if its not too late for more danboid nitpicking of course!

 Howdy

I originally wrote 'to give the plugins more time to load' which reads better but is slightly longer - we want to keep this concise don't we? Smile
« Last Edit: February 02, 2012, 12:58:49 PM by danboid » Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!