Saturday, October 30, 2010

How to get Rosegarden/Jack/Fluidsynth working on openSUSE

Ok it has taken me practically all day, but I finally got Rosegarden working for midi playback on openSUSE 11.3.  I just placed an order for a usb midi interface, so I am hoping to get my computer ready for when it arrives, and I have to say that I did not expect there to be so much of a hurdle just to get Rosegarden working.

I use openSUSE, but I hope that this will be helpful to users of other linux distributions, but I am not going to figure out how to do all system administration stuff from the command line without using yast, or using different package managers, etc.

Ok step one get the stuff:

Needed:
rosegarden (mine is 10.04.2)
jack
fluidsynth

Nice to Have, and basically assumed for this tutorial:
qjackctl
qsynth

KDE users will probably be happier than those of us on gnome, since all of this stuff uses the KDE toolkit (though the GUI for fluidsynth-dssi is in GTK+, so KDE users should probably keep that around in case they figure out how to use it!  I haven't ;) ).  Also there isn't a repo with qsynth, so I built from source.  You need the fluidsynth development package to build it from source, plus probably a whole bunch of development packages (I have a bunch already).  There was a user on the openSUSE build service who had it in his home project, if you would prefer doing it that way.

Step 2, get the audio group on!
 Add yourself to the audio group in Yast->Security and Users->User and Group Management by selecting the users who will be using the midi stuff and going to edit and then details.

Then, and here is the tricky part, add the following lines to the file /etc/security/limits.conf:
@audio - rtprio 90
@audio - nice 15
@audio - memlock 4000000

Edit (12/23/2010):  The above worked for a while, but I now use:
@audio - rtprio 90
@audio - nice -10
@audio - memlock unlimited

 It's probably easiest to call a text editor with sudo and just cut and paste them in, that's what I did.

The point of all of this is that now you will be able to use the audio stuff without calling them from root, which makes everything much simpler.

Step 3 Get some SoundFonts!

There are a lot of them out there it appears!
There are a bunch on a site called Hammersound.  I found one on there called FluidR3 or something similar in the collections category that is General Midi (i.e. a little bit of everything, with things on standardized channels.)  Actually General Midi is not really essential for using fluidsynth with rosegarden, since there is a convenient way to set the instrument channels in rosegarden (see step 4)  I haven't really used any of this stuff enough to give a recommendation to anything though.

You may also need the program from http://www.melodymachine.com/sfark.htm, which has a linux version, if the file that you have has a .sfark extension.  It is a specialized compression program as far as I can tell.

Step 4:  Get jacked up!  I mean get jackd up, and everything else too!
If you haven't signed off and back on after editing the file limits.conf file in step 2, go ahead and do that.  Then start up jackd using qjackctl, or from the command line using "jackd -d alsa" (additional options I don't know anything about really, but jackd --help and jackd -d alsa --help have some info).

Then start up your qsynth.  Actually, starting fluidsynth from the command line still looks fairly useful, because I don't see a way to start multiple copies of qsynth (though I might be missing something) but adding more fluidsynths from the command line seems to work.  The command that works without any hitches for me is "fluidsynth -l -a jack -m alsa_seq [soundfontfile.sf2]".  Actually, just start up one at first though, it is probably easier to add them one at a time because you have to keep track of which one is using which soundfont file.

Then start up Rosegarden and go to Studio->Manage Midi Devices (there is an icon as well.  It should list your fluidsynths in the Midi Outputs section.  Select your synth, and then click on banks, and then on import.  And then switch to .sf2 files, and load the sf2 file that the synth is using in order to load the names of the different instruments.

Step 5: Make sure everything is hooked up right-
Go to your qjackctl (I have no idea how to do this from the command line, sorry), and click on connect.  Make sure that your synth is going where you want it to go, for playback send it to system  Haven't figured out how to record this yet, I'll probably use audacity as a software recorder/mixer if the rosegarden one is not good enough.

Step 6:  Making music!
Just right click on the name of the midi channel, and then select the device.  Choose the instrument in the panels on the left of the screen, and you should be ready to make music!  This is as far as I have gotten, wanted to call it a day at this point and type this up before I forgot how I got it working because I hope no one else has to go through a day like this.  I assure you it is much easier if you know what you are doing, each of these steps was hit upon after a lot of trial and error and googling for only tangentially related stuff, though I did get step 2 off of an openSUSE forum, I would never have thought of it on my own.  Ok, phew, I am going to watch sports now.

6 comments:

  1. I know exactly how you feel about spending all day trying to get something to work.

    I was finally able to get Rosegarden/Jack/Fluidsynth working on my Debian system with your guide. Thank you very much. :)

    ReplyDelete
  2. Thanks for the info. With your help I've got things working as well. :)

    BTW - I got qsynth from this link http://sourceforge.net/projects/qsynth/files/qsynth%20(stable)/0.3.5/ and the binary worked out of the box even though it says Suse 11.2. I didn't have to compile anything. I'm using openSUSE 11.3 with KDE 4.4.4

    ReplyDelete
  3. Glad to be of help, and thanks for the link I hope people find it useful, probably won't test it myself since mine isn't broken though.

    ReplyDelete
  4. Thank you very much.

    Finally I hear sound! :-D

    ReplyDelete
  5. Malcom: i m trying this in November 2013 and /etc/security/limits.conf has changed it has 4 columns. i will try with this settings:

    # /etc/security/limits.conf
    #
    #Each line describes a limit for a user in the form:
    #
    #
    #
    #Where:
    # can be:
    # - an user name
    # - a group name, with @group syntax
    # - the wildcard *, for default entry
    # - the wildcard %, can be also used with %group syntax,
    # for maxlogin limit
    #
    # can have the two values:
    # - "soft" for enforcing the soft limits
    # - "hard" for enforcing hard limits
    #
    # can be one of the following:
    # - core - limits the core file size (KB)
    # - data - max data size (KB)
    # - fsize - maximum filesize (KB)
    # - memlock - max locked-in-memory address space (KB)
    # - nofile - max number of open files
    # - rss - max resident set size (KB)
    # - stack - max stack size (KB)
    # - cpu - max CPU time (MIN)
    # - nproc - max number of processes
    # - as - address space limit (KB)
    # - maxlogins - max number of logins for this user
    # - maxsyslogins - max number of logins on the system
    # - priority - the priority to run user process with
    # - locks - max number of file locks the user can hold
    # - sigpending - max number of pending signals
    # - msgqueue - max memory used by POSIX message queues (bytes)
    # - nice - max nice priority allowed to raise to values: [-20, 19]
    # - rtprio - max realtime priority
    #
    #
    #

    #* soft core 0
    #* hard rss 10000
    #@student hard nproc 20
    #@faculty soft nproc 20
    #@faculty hard nproc 50
    #ftp hard nproc 0
    #@student - maxlogins 4
    @audio soft rtprio 90
    @audio soft nice 10
    @audio soft memlock unlimited

    # End of file

    ReplyDelete
  6. Thanks for this post! I was able to get things going in about an hour. Not exactly the same three years later, but close enough to figure it out from what you wrote. Great job!

    ReplyDelete