Please, don't write about application bugs on this thread. Open a new one or write directly to Gentoo bugzilla.
UPDATED:
14th May 2006: English translation (it will have the priority over the original Italian one). Added some programs to be tested to the list.
15th May 2006: Relased under Creative Commons Attribution Sharealike 2.5, added the section about audio useflags (thx evermind)
16th May 2006: 2.6.x Kernel configuration section has been almost rewritten. Thanks to Tom aka Gimpel for letting me merge here his guide. Added some observations from Dominique and Gimpel about useflags, KDE (but will have to introduce a new section for DE, when I'll start a "tips" section) , latency, RT.
22nd May 2006: Added some little notes to test if jackd is working
Note: Because my old Italian HOWTO was taken and copied around the web (and it's been quite frustrating), I decided to relase it under Creative Commons Attribution Sharealike 2.5.
I expect from who decides to modify, copy or redistribute it:
- At least the link of this forum post or of evermind's overlay wiki I discuss about in the HOWTO
- Give me credit
- Give credits to those I gave credits
Sorry if it sounds harsh to someone, but I think it sounds pretty fair and straight forward.
#####################
Introduction
This HOWTO would be a (little?) overview about how it could be possible to use Linux (I'll focus on Gentoo Linux) as an Hard Disk Recording/Mastering Workstation.
I hope, after finishing that, to be able to give some misc tips, for example about how to use your Gentoo box as part of your multi-effects rack for live performances and stuff like that (any suggestions are VERY appreciated!)
I know very well there's A LOT of work to be done to reach the quality of the ultra-expensive MAc or Win professional softwares (and their quality continues to increase...), but you'll see that our penguin is already able to let us produce decent audio productions (demos, simple soundscores, etc)
Before starting I also want to warn you that most of the software I'll talk about are still in beta (or even alpha) versions... So keep in mind they could crash or even lead your whole system to a crash.
Our Workstation will be made at least by the following elements:
- - Low Latency Sound Server (Jack)
- SEQUENCER (Rosegarden) + DRUM MACHINE (Hydrogen)
- MULTI-TRACK Editor/Recorder (Ardour)
- DSP MultiEffects (LADSPA plugins and VSTi/VST Plugins under Rosegarden and Ardour)
- AUDIO EDITOR (Rezound)
- MASTERING Software (Jamin)
PREREQUISITES:
- I'll suppose your workstation has a working audio card, with working ALSA drivers.
This HOWTO has been written for Gentoo-Linux with 2.6 kernel, but could be easy adapted to other distros with different kernels (I'll discuss, for example, how to configure a 2.4 kernel, that were better than early 2.6 kernels regarding latency)
- I HIGLY reccomend you to use the unstable (~arch) versions of all the programs I'll discuss here.
So be always ready to run a
Code: Select all
nano /etc/portage/package.keywordsI know that won't ensure you a 100% reliability, but the new features (an example was the introduction in some programs of DSSI, VST support, etc) introduced by the latest versions are often too much important if you want to be productive.
Another good reason to do that is that, if you find something wrong, you can make a good bug report that will help the whole community (the number of musicians doesn't seem to be too high, in fact)
INSTALLATION OF EVERMIND's OVERLAY
What is this?
It's a portage Overlay with tweaked and more updated versions of most Linux Audio-related programs. Here you'll find almost everything you need for at least a simple home-recording (or, off course, studio-recording, if you will go deeper with the subject)
Even if I'll try to write step-by-step instructions, I suggest you to check these links about (overlay installation, base packages installation and packages list)
- Let's start by installing subversion:
Code: Select all
emerge subversionCode: Select all
mkdir /usr/local/portage-proaudio
cd /usr/local/portage-proaudio
svn co svn://svn.tuxfamily.org/svnroot/ckpp/proaudio- Now let's add the overlay in /etc/make.conf
Code: Select all
PORTDIR_OVERLAY=""
PORTDIR_OVERLAY="${PORTDIR_OVERLAY} /usr/local/portage"
PORTDIR_OVERLAY="${PORTDIR_OVERLAY} /usr/local/portage-proaudio"- To update the overlay, you just have to do:
Code: Select all
cd /usr/local/portage-proaudio
svn upCode: Select all
cd /directory/of/the/ebuild/foo
ebuild foo.ebuild digestPreliminary steps:
What follows is necessary to prepare your system for audio; follow the 2.4 or the 2.6 guide, depending on the kernel you use
- Instrucions for 2.4 Kernels (OBSOLETE)
Before compiling it, we need to make the following modifications:
Code: Select all
Processor type and features --->
[*] Preemptible Kernel
Device Drivers --->
Character devices --->
<*> Enhanced Real Time Clock Support
Sound --->
Advanced Linux Sound Architecture --->
<*> RTC Timer supportThat's not difficult, we just need to modify a configuration file.
The file to modify is:
Code: Select all
/usr/src/linux/include/linux/capability.hCode: Select all
#define CAP_INIT_EFF_SET to_cap_t(~0 & ~CAP_TO_MASK(CAP_SETPCAP))
#define CAP_INIT_INH_SET to_cap_t(0)Code: Select all
#define CAP_INIT_EFF_SET to_cap_t(~0)
#define CAP_INIT_INH_SET to_cap_t(~0)(the link should be correct, but I've never tried it)
IMPORTANT: Every time we install/reinstall a new/different version of kernel sources, we need to remember to make this operation manually, or the new kernel won't be "caps-enabled", OK?
- Instructions for 2.6 Kernels (WARNING: THIS PART OF THE GUIDE MUST BE UPDATED, because realtime-lsm is discouraged. The recomended method is to use sys-libs/pam with rt-limits activated. It can be found on the overlay. Documentation about that will come soon.
Before starting this important part, I want to highlight you can make it in 3 ways, depending on how much important is audio for your environment. Take a look at this post by Gimpel and MetaSymbol for further information.
- Model 1: " Want to start a synth from time to time"
Standard Gentoo kernel with PAM from Rui (also available in evermind's overlay)
Model 2 "Want to work with MusE or Rosegarden from time to time"
RT-sources kernel and PAM
Model 3 " I want make some fat production / live performing with many native FX and soundgenerators with less then 10ms audiolatency"
RT-sources kernel and realtime-lsm (WARNING: RT-LSM can maybe crash your system)
realtime-lsm is nothing else but a linux security module (LSM) which makes it possible to grant users access to the realtime capabilities of the Linux kernel. It works on any kernel. This is going to be replaced by PAM's pam_limits.so which uses the kernel's RLIMITS feature to allow users access to the realtime capabilities in a more secure way than realtime-lsm does.
realtime-preemption is a feature provided by a kernel patch from Ingo Molnar. It makes the kernel fully preemtible which reduces latencies, especially on audio tasks. A kernel patched with the realtime-preemption patch is called RT-kernel. This has to do with CPU scheduling, but nothing with user permissions.
Note2: Kernel preemption gives some little overhead (reducing throughput), but the benefits for audio-production are greater than the drawbacks (for a musician, lower latency and NO xruns are more important than having that 1% more CPU power).
RT-Kernel... Why?
This is an update of the HowTo from gimpel (gimpel.funpic.de), translated by oc2pus. Updated by BB Codes and gentoo'ified by gimpel again
The main goal in audio-processing is the latency. The latency is the delay beetween signal-creating and reaching the processing in the system (e.g time between pressing a key on the keyboard and hearing the tone). The standard kernels have the disadvantage that the processing is slower (~11ms) as in Windows or using a MAC . The faster the system, means the lower the latency, the more things can happen simular on a the system (e.g. more synths ..) Ingo Molnar, a RedHat developer and some others have started a project to minimize the latency in Linux: Realtime Preemption. By using excellent audio-hardware the JACK demon (Jack Audio Connection Kit) reach latency < 1ms, similar to the MacOS X coreaudio system. For interested people follows a little step-by-step HowTo to patch a vanilla kernel with Realtime Preemption stuff and how to compile and install this new kernel.
Note: This is an experimental kernel.
From the developers view the rt-lsm is deprecated. It's preferred to use PAM for SCHED_FIFO priorities. This will be explained later on (TODO)
Sample kernel is the stable linux-2.6.16.
Obtain the kernel-source and necessary patches
Choice 1: The simple approach
Evermind's overlay provides an ebuild for rt-sources. So to get the latest kernel source including the -rt patch, just type:
Code: Select all
emerge -av rt-sourcesChoice 2: Patching manually
Download the sources
Download current vanilla kernel
Code: Select all
wget http://kernel.org/pub/linux/kernel/v2.6/linux-2.6.16.tar.bz2Code: Select all
wget http://people.redhat.com/mingo/realtime-preempt/patch-2.6.16-rt22Unpack and patch kernel
Code: Select all
cd /usr/src/linux
su
<password>
tar xvjf /path/to/linux-2.6.16.tar.bz2
linux-2.6.16 linux-2.6.16-rt22
cd linux-2.6.16-rt22
patch -p1 < /path/to/patch-2.6.16-rt22Kernel configuration
Clone the config
It's a good thing to clone your current (working) kernel configuration.
If you have support for access to the config via /proc/config.gz enabled it'll be easier:
Code: Select all
zcat /proc/config.gz > .config
make oldconfigAdjust important settings
Enter the configuration menu
Code: Select all
make menuconfig- Activate rt full preempt
Code: Select all
Processor type and features --->
Preemption Mode (Complete Preemption (Real-Time)) --->
( ) No Forced Preemption (Server)
( ) Voluntary Kernel Preemption (Desktop)
( ) Preemptible Kernel (Low-Latency Desktop)
(X) Complete Preemption (Real-Time)Code: Select all
Processor type and features --->
Timer frequency (1000 HZ) --->
(X) 1000 HZCode: Select all
Block layer --->
IO Schedulers --->
< > Anticipatory I/O scheduler
< > Deadline I/O scheduler
<*> CFQ I/O scheduler
Default I/O scheduler (CFQ)Code: Select all
File systems --->
Pseudo filesystems --->
[*] Virtual memory file system support (former shm fs) Code: Select all
Device Drivers --->
Character devices --->
<M> Enhanced Real Time Clock Support
<M> Generic /dev/rtc emulation
[*] Extended RTC operation Code: Select all
Device Drivers --->
ATA/ATAPI/MFM/RLL support --->
<*> ATA/ATAPI/MFM/RLL support
<*> Include IDE/ATA-2 DISK support
[*] Use multi-mode by default
[ ] IDE Taskfile Access
< > generic/default IDE chipset support
[*] PCI IDE chipset support
[*] Generic PCI bus-master DMA support
[*] Use PCI DMA by default when available
<*> Intel PIIXn chipsets support- Make sure you get no overhead by debug features
(Note: need to look at a -rt kernel config for a full list)
Code: Select all
Kernel hacking --->
[*] Magic SysRq key #that one is always good to have ;)
[ ] Kernel debugging- What is this? Working with experimental audio applications (especially in realtime mode) the system can occasionally become unresponsive to the user input. The Magic Keys permit to do some emergency tasks with some particular key combinations. For example, to sync the hard drive, umount it and reboot the system you can hit these keys: ALT+SysRq+s, ALT+SysRq+u, ALT+SysRq+b. The SysRq key is often indicated as Print Screen on most keyboards.
Another useful shortcut is Alt+SysRq+n that changes all the realtime tasks to normal priority (this works in a vanilla kernel, does not work using the realtime-preemption patch).
See the kernel documentation (Documentation/sysrq.txt in the kernel's sources dir) for a more complete description.
OPTIONAL STEP - Realtime-lsm support:(DEPRECATED)
-At this point, activate realtime-lsm to grant realtime privileges to normal user
Code: Select all
Security options --->
[*] Enable different security models
<M> Default Linux Capabilities
<M> Realtime CapabilitiesEnd of Optional Step
Compile and install the new kernel
- Compile the kernel:
Code: Select all
make && make modules_install- Install the kernel:
Code: Select all
cp arch/i386/boo/bzImage /boot/kernel-2.6.16-rt22
cp System.map /boot/System.map-2.6.16-rt22Code: Select all
cd /boot
mkinitrd -k kernel-2.6.16-rt22 -i initrd-2.6.16-rt22Code: Select all
nano -w /boot/grub/grub.conf- Pray and reboot...
Activate and test RT
After reboot it's time to activate the user real-time module:
- Determine the gid of the audio group
Code: Select all
id <username>Code: Select all
uid=1000(tom) gid=100(users)...,18(audio)Code: Select all
gpasswd -a <username> audio- Then load realtime-lsm (deprecated)
Code: Select all
modprobe commoncap
modprobe realtime gid=18Code: Select all
[i]- To ensure this gets loaded automagically after reboot[/i]
echo "realtime" /etc/modules.autoload.d/kernel-2.6
echo "options realtime gid=18" >> /etc/modules.d/realtime
modules-updateCode: Select all
lsmod|grep realtime
real-time 5512 0
commoncap 7040 1 realtimeImportant note about ALSA
DON'T use alsa-modules included on your kernel sources. Just follow the official Gentoo guide (that suggests to use the alsa-driver package). You'll find it here: qui.
Why?
If you have a professional audio-card, maybe you'll need the package
Code: Select all
alsa-firmwareAlsa modules included on your kernel sources may be older than current alsa-driver (and alsa-firmware).
If you decided to use the modules included in your kernel source anyway, remember that ALSA should have RTC support too. To have it, go to your kernel configuration menu and set it as follows
Code: Select all
Device drivers --->
Sound --->
Advanced Linux Sound Architecture --->
<*> RTC Timer support
[*] Use RTC as default sequencer timerIf you decided to not use rt-sources you'll be missing some of the options above. Your kernel will not be patched to use realtime-lsm, so this is what you need to have it working:
- Go back to the kernel configuration menu
Code: Select all
Security options --->
[*] Enable different security models
<M> Default Linux Capabilities Code: Select all
/usr/src/linux/.configCode: Select all
CONFIG_MODULES=y
CONFIG_MODULE_UNLOAD=y
CONFIG_SECURITY=y
CONFIG_SECURITY_CAPABILITIES=m
CONFIG_SECURITY_SELINUX=y Install realtime-lsm, after adding it to /etc/portage/package.keywords. Do this BEFORE the make modules_install!
Code: Select all
emerge realtime-lsmSound Server (jack) configuration
Jack is an audio-server made to work with low-latency. Unlike other famous sound-servers (Arts, ESD, Gstreamer, etc), it has some features (and we'll discover some of them, such low latency, flexible audio routing between applications, AUDIO/MIDI syncronization during this HOWTO) that make it a core compoent of a Linux DAW.
- Installation of jack (note we're using the overlay version, not the portage one)
Once installed the new kernel, rebooted, etc etc, we're ready to install Jack; remember we'll need the following USEFLAGS (add them to make.conf manually or with ufed or remember to specify them before every emerge)
Code: Select all
USE=+jack,+jack-tmpfsnow let's install jack and its dependencies:
Code: Select all
emerge jack-audio-connection-kit If you find too many xruns when working with audio-programs, you could add to try these lines to your /etc/fstab
Code: Select all
#questa riga dovrebbe già esser presente
shmfs /dev/shm shm defaults 0 0
none /tmp/jack tmpfs defaults 0 0 Code: Select all
mkdir /mnt/ramfs Code: Select all
none /mnt/ramfs tmpfs defaults 0 0 Now let's test if jack works. If you have any soundserver running (arts, gstreamer, esd, etc), I recommend to shutdown or to kill it, or your device will be easy and jack will not run:
Code: Select all
jackstart -v -R -d alsa -H -M -mNote for 2.6.x Kernels: use jackd instead of jackstart or it'll give you an error message (it'll say you need capabilities anabled... but if you folowed the guide, now you're using a perfectly configured 2.6 kernel!
Now, if you want, you can use jack from commandline (for example to launch it on boot time), so read carefully
Code: Select all
man jackdBut, believe me... it's not too much comfortable!
That's the reason why I suggest you to use qjackctl:
Code: Select all
emerge qjackctlThe only thing I can tell you, for now, is that it must be executed BEFORE other audio apps (or they won't work.)
INSTALLATION OF THE MOST IMPORTANT PACKAGES FROM THE OVERLAY:
Description of audio-related USEFLAGS:(note that some are introduced by the overlay)
- caps: You need this useflag to give realtime privileges to user applications. It's needed for 2.4 kernels, so donìt use it if you have a 2.6.x one, since it's deprecated.
dssi: DSSI is a "temporary" API for wirtual instruments with a GUI. Without going deep in details, I'll just tell you there are some nice virtual synths using it and that there's an extra-plugin that lets you use VSTi and VST plugins under rosegarden (or other DSSI-compatible hosts). Take a look at http://dssi.sourceforge.net/ for further informations.
ladcca: Don't use it if you plan to use the newest lash useflag. Read what I wrote about lash useflag for explanations.
lash: Almost all the newest audio applications now use Lash, instead of Ladcca. After recommending you to take a look at their web sites, I also suggest to remove ladcca (emerge -C ladcca) and re-emerging your (~arch) version of wkeybd, jack-rack and museseq so they'll use Lash libraries.
jack: Jack Audio Connection Kit Support. You absolutly need it to work with most pro audio applications.
jack-tmpfs: Gives tmpfs support to jack (for better performances). You should have tmpfs support enabled in your kernel too. (need confirmation of this too)
jackmidi: Adds MIDI API for the Jack Audio Connection Kit (JACK). That gives MIDI support to Jack. Homepage
vst: Gives VST (Steinberg's Virtual Studio Technology) to audio applications that support fst, dssi or vstserver.
NOTE: Museseq may not compile with fst-1.7, so, if it gives you problems, try to install it with a
Code: Select all
USE=-vst emerge museseqVST Support
What is a VST plugin? Without being too much technical, I can say VST is a plugin format used by most Win/Mac audio-related applications. It allows you to use inside your program (called host) real time effects, virtual synths and other things. If you are interested and want a more detailed explanation, take a look here.
Do I really need that stuff? I hate Wincows, Micro$oft and Macintrash! Yes. You need it. Just take a look at http://kvraudio.com to see how many tons of free plugins (some are really really good!) you can have access to.
How could it be? Sounds like magic; I suppose I didn't understand anything
There are at least 2 systems to use VST plugins under Linux:
-dssi-vst: it's a dssi plugin (so the host you're going to use must supporte DSSI!) that can make use of VST plugins. To do that, it uses Wine, DSSI headers and Steinberg VST SDK headers (VST protocol, in fact, was created by Steinberg)
-fst: it's a server that, with the combination of Wine, Jack and Steinberg VST SDK, allows you to use VST plugins under Linux
-Vst server. This should be the first program who gave VST support to Linux. I did never understand how to use it, so if you know how to, please write me a note, so I can add it to this documentation.
OK, it sounds cool. What do I have to do? First go here http://www.steinberg.net/532+M52087573ab0.html, read the agreement and download the 2.3 version of the SDK (or a following one, depending on what the overlay will require by the time you read this). If the link doesn't work anymore, go to Google to find the vstsdk2.3.zip file (it's part of the vst_sdk2_3.zip archive).
Remember that YOU CANNOT REDISTRIBUTE IT, SO READ CAREFULLY THE AGREEMENT I told you above. If you don't like it, simply don't use it (and you won't have VST support).
Once you found vstsdk2.3.zip (good luck), copy it in
Code: Select all
/usr/portage/distfilesCode: Select all
/etc/make.confCode: Select all
dssi vst jackmidiRosegarden (sequencer) installation
With this one we can start to be a bit productive... Rosegarden is an audio and MIDI sequencer, based on KDElibs+QT. In the beginning it was written only to manage/edit MIDI files, but now audio support has been integrated (OK... it cannot be compared to Cubase or Sonar... But... It's growing quite well). It also have a good score editor, that allows you to export files to Lilypond and nice editing features.
A little note about KDE: even if KDE is very memory-hungry, once loaded it runs quite fast (comparable, if not even better than other "light" Desktop Environments). If you are lacking RAM, consider to use another Window Manager
So, if you want to start using it, you just need to do an
Code: Select all
USE=+jack +dssi emerge rosegardenOn the overlay you'll also find rosegarden-cvs. Take a look at it too, because audio support is getting better and better in newest relases
Remember that, if you want audio support, you have to run jackd BEFORE Rosegarden. It would be a good idea to run it through qjackctl.
Ardour Installation (multi-track audio editor)
If you need VST support, you just have to do a
Code: Select all
USE=vst emerge ardour-cvsYou can also try to emerge ardour2-cvs if you want a bunch of new features.
Interesting Virtual synths
zynaddsubfx: Real time Virtual Analog synth
fluidsynth: MIDI virtual Synth based on SoundFont. You can use it either via qsynth (a nice QT GUI) or via his DSSI version, called fluidsynth-dssi
hexter: A Yamaha DX7 reprodution via DSSI. It can also import your old Yamaha DX5 and DX7 patches. Take a look if you need a nice FM synth
hydrogen: A very good drum machine
ams: Alsa Modular Synth (still have to try it)
amsynth: another virtual synth that seems to sound very nice (I found filters to be a bit "cold", but I still have to experiment well with it)
Csound: As the homepage says: "Csound is a sound and music synthesis system, providing facilities for composition and performance over a wide range of platforms". Ehm... Still have to try it too
Rezound (audio editor) installation
If you need to cut&paste samples, resample, apply offline effects, remove noise, to put quickly your latest demo on a CD, converting it to mp3, ogg and other things, a sequencer couldn't be enough... You need an audio editor!
Lots of people use Audacity, because it's muti-platform, it's well known, etc etc. Well, I really hate it. That's why I suggest to try rezound. First because I find its GUI is more intuitive, second because it can use jack as an output.
To install it, a
Code: Select all
USE=+jack emerge rezoundOnce again, I recommend to put rezound and its deps to /etc/portage/package.keywords so you can use the latest version.
Jamin installation
Jamin is a "simple" mastering suite, made by a multi-band compressor and a 30-bands EQ. As all the other mastering suites, it requires you know very well what you're doing.
You can install it with a simple
Code: Select all
emerge jamin-cvsRemember that mastering is the final stage of the audio-production process, so, when you route the signal via qjackctl, insert jamin right before the ouutput you want to send audio to. (Jamin is used as an audio effect, so it must be used in real time with jack! you cannot import, for example, wave files on it to modofy them!)
Mastering is a very important aspect of music production, because it decides how your music will sound when played all around the world (from the ultra-expensive stero to the cheapest walkman or mp3 player).
That's why you need a studio and amplification system made just for mastering. If you don't have it... Well... You better give your precious single to a studio specialized in mastering
TODO:
- Adding at least a part of, this, and this guide, tweaking them to work with Gentoo and the overlay (adding an rt-sources HOWTO?).
- A "technical" Tip section, with OS-related tips (HD tips and more kernel hacks are the high priority)
- tips on EQ, mixing, mastering, automation, syncinc apps
- an introduction to the main effects used during HD recording
(flangers, reverbs, panning) and how/when to use them
(help appreciated)
- To insert other programs, after testing them: Wired (DAW with native Akai support), Seq24 (light sequencer for live performances), Bristol (moog emulator, etc), Freecycle (sample slicer)
- To give more space to free/opensource synths than to VST ones
- Case studies?
CREDITS:
Jack-audio-connection-kit HOWTO:http://forums.gentoo.org/viewtopic.php? ... sc&start=0
Jack Homepage:http://jackit.sourceforge.net/
Evermind's post about his audio overlay and related links:http://forums.gentoo.org/viewtopic-t-427211.html



