<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
"http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [

  <!ENTITY title "How to create music with GNU/Linux">
  <!ENTITY kernelversion "2.6.26.5">
  <!ENTITY rtpatchname "patch-2.6.26.5-rt9">
  <!ENTITY rtpatchversion "rt9">

]>

<book lang="en">
<bookinfo>
  <title>&title;</title>
  <author>
    <firstname>Emmanuel</firstname>
    <surname>Saracco</surname>
    <affiliation>
      <address>
        <email>emmanuel@esaracco.fr</email>
      </address>
    </affiliation>
  </author>
  <revhistory>
    <revision>
      <revnumber>0.0</revnumber>
      <date>2009-01-30</date>
      <authorinitials>es</authorinitials>
      <revremark>Not yet versioned: It is still a work in progress.</revremark>
    </revision>
  </revhistory>
  <legalnotice>
    <para>
      <citetitle>&title;</citetitle>
    </para>
    <warning>
      <para>
        WORK IN PROGRESS
      </para>
    </warning>
    <para>
      Permission is granted to copy, distribute and/or modify this document
      under the terms of the GNU Free Documentation License, Version 1.2
      or any later version published by the Free Software Foundation;
      with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
      Texts.
    </para>
    <para>
      A copy of the license is available on the World Wide Web at 
      <ulink url="http://www.gnu.org/licenses/fdl.html">http://www.gnu.org/licenses/fdl.html</ulink>.
    </para>
  </legalnotice>
  <copyright>
    <year>2005-2009</year>
    <holder>Emmanuel Saracco</holder>
  </copyright>
</bookinfo>

<dedication>
  <para>
     This howto is dedicated to all GNU/Linux users that refuse to use proprietary software to work with audio.
  </para>
  <para>
    Many thanks to all Free developers and Free composers that help us day-by-day to make this possible.
  </para>
</dedication>

<preface id="forword">
  <title>Forword</title>
  <para>
    Working with audio on GNU/Linux can be really complicated, but most of the time it is just a matter of compiling a kernel, installing, settings some packages and also using software the right way :-)
  </para>
  <para>
    It is still a work in progress. If you have comments, experience to share... do not hesitate to send me an E-Mail and I will update this documentation.
  </para>
  <para>
    Also keep in mind that it exists many different ways to succeed in setting up, installing and using software, and I do not know them all. So I will describe what I use and how I do, but not how you <emphasis>must</emphasis> do.
  </para>
  <warning>
    <para>
      I warn the readers that I am French and that my English is poor: so I do appreciate any correction!
    </para>
  </warning>
</preface>

<chapter id="system-settings-and-tuning">
  <title>System settings and tuning</title>
  <para>
    Audio creation requires a lot of resources. It requires also specific kernel configuration.
  </para>
  
  <warning>
    <para>
      First of all, check that users who want to work with audio are in the <literal>audio</literal> group. For example, for a user <literal>youruser</literal>, just execute the following command as <literal>root</literal>: <userinput>addgroup youruser audio</userinput>.
    </para>
  </warning>

  <sect1 id="my-own-system-configuration">
    <title>My Studio</title>
    <para>
      I am using a Dell Dimension 8400. 
    </para>
    <para>
      <table><title>My Studio</title>
        <tgroup cols="2" colsep="1" rowsep="1">
        <thead>
          <row>
            <entry>Type</entry>
            <entry>Information</entry>
          </row>
        </thead>
        <tbody>
          <row>
            <entry>Soundcard</entry>
            <entry>
              <para>
                1 <ulink url="http://www.rme-audio.com/english/hdsp/hdsp9632.htm">RME Hammerfall HDSP 9632</ulink> (+ the AEB 4/I expansion board)
              </para>
            </entry>
          </row>
          <row>
            <entry>RAM</entry>
            <entry>3GB</entry>
          </row>
          <row>
            <entry>Hard Disk</entry>
            <entry>1 <acronym>SATA</acronym> 250GB</entry>
          </row>
          <row>
            <entry>CPU</entry>
            <entry>1 P4 3.6GHz EM64T with HyperThreading activated</entry>
          </row>
          <row>
            <entry>Amp simulator</entry>
            <entry><ulink url="http://line6.com/podxt/">Line6 POD XT</ulink></entry>
          </row>
          <row>
            <entry>Mic</entry>
            <entry><ulink url="http://www.audio-technica.com/cms/wired_mics/dd13750b31887ecb/index.html">audio-technica AT 4041</ulink>, Apex 170</entry>
          </row>
          <row>
            <entry>Mic preamp</entry>
            <entry><ulink url="http://www.smproaudio.com/index.php?option=content&amp;task=view&amp;id=18">SM Pro Audio TB101</ulink></entry>
          </row>
          <row>
            <entry>Headphone</entry>
            <entry><ulink url="http://www.sennheiser.com/sennheiser/icm_eng.nsf/root/04465">Sennheiser HD 600</ulink></entry>
          </row>
          <row>
            <entry>GNU/Linux distro</entry>
            <entry><ulink url="http://www.debian.org">Debian</ulink>/sid, 64-bit</entry>
          </row>
        </tbody>
        </tgroup>
      </table>
    </para>
  </sect1>

  <sect1 id="file-system">
    <title>File system</title>
    <para>
      My filesystem type is <literal>ext3</literal>, mounted with the <option>noatime</option> option. Here is a sample of my <filename>/etc/fstab</filename> file:
    </para>
    <para>
      <screen><computeroutput>
/dev/sda7 / ext3 defaults,errors=remount-ro,noatime 0 1
      </computeroutput></screen>
    </para>
    <para>
      If you have a <acronym>IDE</acronym> hard disk you can also try to optimize it by using <application>hdparm</application>. I will show you some basic tips, but you should refer to <application>hdparm</application> documentation to adapt it to your own hardware.
    </para>
    <para>
      <screenco>
        <areaspec>
          <area id="infosi" coords="1" />
          <area id="infosI" coords="2" />
          <area id="tuning" coords="3" />
          <area id="test" coords="4" />
        </areaspec>
        <screen># hdparm -i /dev/hda1
# hdparm -I /dev/hda
# hdparm -c3 -m16 -d1 -A1 -X69 /dev/hda1
# htparm -tT /dev/hda1
        </screen>
        <calloutlist>
          <callout arearefs="infosi">
            <para>Show you a brief summary of your disk's characteristics.</para>
          </callout>
          <callout arearefs="infosI">
            <para>Same thing than the <option>-i</option> option, but more verbose and better structured.</para>
          </callout>
          <callout arearefs="tuning">
            <para>A common way for hard disk tuning.</para>
          </callout>
          <callout arearefs="tuning">
            <para>A common for testing hard disk IO capacity.</para>
          </callout>
        </calloutlist>
      </screenco>
    </para>
  </sect1>

  <sect1 id="build-linux-kernel">
    <title>Linux Kernel</title>
    <para>
      I use a &kernelversion; (see my <ulink url="http://www.esaracco.fr/downloads/config-&kernelversion;">.config</ulink>). In fact, I upgrade the kernel each time a new release is out. I will assume you are confident in building/installing a Linux kernel. With 2.6.x it is generally no more than doing:
    </para>
    <para>
      <screen><userinput>
$ make menuconfig
$ make
$ su
# make modules_install
# make install
# vi /boot/grub/menu.lst
      </userinput></screen>
    </para>
    <para>
      But to build a Linux Audio Kernel there is some more work to do.
    </para>
    
    <sect2 id="realtime-preemption-patch">
      <title>Realtime Preemption patch</title>
      <para>
        Realtime Preemption Ingo Molnar's Linux kernel patch which tries to improve realtime performance of the Linux kernel.
      </para>
      <note>
        <para>
          With my configuration and the last Linux kernel (&kernelversion;) I work without needing this patch.
        </para>
      </note>
      <para>
        Always download the last release <ulink url="http://www.kernel.org/pub/linux/kernel/projects/rt/">here</ulink>. Then apply it:
      </para>
      <para>
        <screen><userinput>
$ cd /usr/src/
$ wget http://people.redhat.com/mingo/realtime-preempt/&rtpatchname;
$ rm linux
$ mv linux-&kernelversion; linux-&kernelversion;-&rtpatchversion;
$ ln -s linux-&kernelversion;-&rtpatchversion; linux
$ cd linux/
$ patch -p1 &lt; ../&rtpatchname;
	      </userinput></screen>
      </para>
      <para>
	Patch should apply without fatal problems. Messages like <computeroutput>Hunk #3 succeeded at 652 (offset 1 line).</computeroutput> are ok. Search for outputs like <computeroutput>Failed</computeroutput>. The most common failure is on the <filename>Makefile</filename> file. Just edit it by hand and add <userinput>-&rtpatchversion;</userinput> at the end of the <varname>EXTRAVERSION</varname> variable.
      </para>
    </sect2>

    <sect2 id="kernel-configuration">
      <title>Configuration</title>
      <warning>
        <para>
          Do not forget to adapt those samples to your own configuration (especially for the "PCI devices" section).
        </para>
      </warning>
      <para>
        The most important items for a vanilla Linux kernel (not patched with Ingo's RT patch) are:
      </para>
      <para>
        <screen><computeroutput>
  Processor type and features ---&gt;
    Preemption Model (Preemptible Kernel (Low-Latency Desktop)) ---&gt;
    [*] Preempt The Big Kernel Lock
    Timer frequency (1000 HZ) ---&gt;
  
  Device Drivers  ---&gt;
    Character devices  ---&gt;
      &lt;M&gt; Enhanced Real Time Clock Support
      &lt;M&gt; Generic /dev/rtc emulation
      [*]   Extended RTC operation
    &lt;M&gt; Real Time Clock  ---&gt;
      [*]   /sys/class/rtc/rtcN (sysfs)
      [*]   /proc/driver/rtc (procfs for rtc0)
      [*]   /dev/rtcN (character devices)
      &lt;M&gt;   PC-style 'CMOS'
    Sound  ---&gt;
      &lt;M&gt; Sound card support
        Advanced Linux Sound Architecture  ---&gt;
          &lt;M&gt; Advanced Linux Sound Architecture
            &lt;M&gt;   Sequencer support
            &lt;M&gt;     Sequencer dummy client
            &lt;M&gt;   OSS Mixer API
            &lt;M&gt;   OSS PCM (digital audio) API
            &lt;M&gt;   RTC Timer support
            [*]     Use RTC as default sequencer timer
          Generic devices  ---&gt;
            &lt;M&gt; Virtual MIDI soundcard
          PCI devices  ---&gt;
            &lt;M&gt; RME Hammerfall DSP Audio

  Security options ---&gt;
    [*] Enable different security models
    &lt;M&gt;   Default Linux Capabilities
        </computeroutput></screen>
      </para>
      <para>
        For a kernel patched with Ingo's RT patch the differences are:
      </para>
      <para>
        <screen><computeroutput>
  General setup  ---&gt;
    [*] Enable concurrent radix tree operations
    [*]    Enabled optimistic locking 

  Processor type and features  ---&gt;
    [*] Enable priority boosting of RCU read-side critical sections
        </computeroutput></screen>
      </para>
      <para>
        Also for RT patch you must uncheck the folloging options:
      </para>
      <para>
        <screen><computeroutput>
  Processor type and features ---&gt;
    [ ] Enable tracing for RCU - currently stats in debugfs

  Device Drivers  ---&gt;
    Character devices  ---&gt;
      [ ] Real Time Clock Histogram Support
      &lt; &gt; Parallel Port Based Latency Measurement Device

  Kernel hacking  ---&gt;
    [ ] Wakeup latency timing
    [ ] Non-preemptible critical section latency timing
    [ ] Interrupts-off critical section latency timing
        </computeroutput></screen>
      </para>
    </sect2>
    
    <sect2 id="kernel-installation">
      <title>Installation</title>
      <para>
        Install modules and kernel and edit the <filename>/etc/modules</filename> file to add the following content, depending on your hardware:
      </para>
      <para>
         <screen><computeroutput>
rtc
snd-rtctimer
snd-hdsp
snd-hwdep
snd-page-alloc
snd-pcm
snd-rawmidi
snd-seq
snd-seq_device
snd-seq_midi
snd-seq_midi_event
snd-timer
        </computeroutput></screen>
      </para>
      <para>
        Most of these modules depend on others that will be automatically loaded.
      </para>
      <para>
        Most of time you would also raise the value of the <literal>max-user-freq</literal> kernel value.  To do so you can either:
      </para>
      <para>
        <itemizedlist>
	  <listitem>
            <para>
              Use <command>sysctl</command> by editing <filename>/etc/sysctl.conf</filename> and adding the following line:
              <screen><computeroutput>
dev.rtc.max-user-freq=1024
              </computeroutput></screen>
              Once the file is updated, reload the configuration by running <userinput>sysctl -p</userinput> as root user.
            </para>
	  </listitem>
	  <listitem>
            <para>
              Directly write the value into <filename>/proc/sys/dev/rtc/max-user-freq</filename> at boot time:
              <screen><computeroutput>
echo 1024 > /proc/sys/dev/rtc/max-user-freq
              </computeroutput></screen>
            </para>
	  </listitem>
	</itemizedlist>
      </para>
      <para>
        Now just reboot on your new kernel.
      </para>
    </sect2>
  </sect1>

  <sect1 id="obtaining-realtime-privileges">
    <title>Obtaining Reatime privileges</title>
    <para>
      There is actually three ways to obtain root privileges for Realtime. The first way is to use the "Realtime LSM" module. But this way is pretty deprecated and should not be used nowdays. The second way is to use a little tool named <application>set_rlimits</application>. This way is ok, but it should only be used when the <application>PAM</application> library does not support "rlimits" operations. The third way is the right way: it consist on using <application>PAM</application>.
    </para>
    
    <sect2 id="build-realtime-lsm">
      <title>Realtime LSM</title>
      <para>
        <emphasis>This way is not recommended</emphasis>.
      </para>
      <para>
        The Realtime Linux Security Module (<acronym>LSM</acronym>) is a loadable extension for Linux 2.6 kernels. It selectively grants realtime permissions to specific user groups or applications.
      </para>
      <para>
        First, retreive the last CVS version:
      </para>
      <para>
        <screen><userinput>
$ cvs -d:pserver:anonymous@realtime-lsm.cvs.sourceforge.net:/cvsroot/realtime-lsm login
$ cvs -z3 -d:pserver:anonymous@realtime-lsm.cvs.sourceforge.net:/cvsroot/realtime-lsm co -P realtime-lsm
        </userinput></screen>
      </para>
      <para>
        The apply the <filename>rt-lsm-kernel.patch</filename> kernel patch on you Linux kernel:
      </para>
       <para>
        <screen><userinput>
$ cd /usr/src/linux/
$ patch -p1 ../realtime-lsm/rt-lsm-kernel.patch
$ make menuconfig
$ make
$ su -c "make modules_install"
$ su -c "make install"
        </userinput></screen>
      </para>
      <para>
        Your <menuchoice><guimenu>Security options</guimenu></menuchoice> kernel configuration section should be like the following:
      </para>
      <para>
        <screen><userinput>
  Security options ---&gt;
    [ ] Enable access key retention support
    [*] Enable different security models
    [ ]   Socket and Networking Security Hooks
    &lt;M&gt;   Default Linux Capabilities
    &lt; &gt;   Root Plug Support
    &lt; &gt;   BSD Secure Levels
    &lt;M&gt;   Realtime Capabilities
	      </userinput></screen>
      </para>
      <para>
        If you do not see the <menuchoice><guimenu>Realtime Capabilities</guimenu></menuchoice> item, then check the end of the kernel's <filename>security/Kconfig</filename> file and try to fix it (it can have a issue with the <option>depends</option> option).
      </para>
      <para>
        Reboot with your new kernel.
      </para>
      <warning>
        <para>
          Do not forget to repeat this step every time you rebuild a new kernel.
        </para>
      </warning>
      <para>
        Then if you do not care about security, just do <userinput>modprobe realtime any=1</userinput> to load the module and to allow its use for every users of your system. If you want to allow only the <literal>audio</literal> group to access realtime capacities, check that your current user is in the audio group and load realtime module by passing it the <literal>gid</literal> of the group to allow:
      </para>
      <para>
        <screen><userinput>
  # addgroup youruser audio
  # modprobe realtime gid=$(grep audio /etc/group | cut -d':' -f3) any=1
        </userinput></screen>
      </para>
      <para>
        If you want to load this module at boot time on Debian, do the following:
      </para>
      <para>
        <screen><userinput>
$ su
# echo "options realtime any=1" > /etc/modprobe.d/realtime
# echo "realtime" >> /etc/modules
        </userinput></screen>
      </para>
    </sect2>

    <sect2 id="using-set-rtlimits">
      <title>Using set_rlimits</title>
      <para>
        <emphasis>This way is not recommended</emphasis>.
      </para>
      <para>
        <command>set_rlimits</command> is a small wrapper program to allow people to take advantage of he realtime resource limit extensions available in Linux kernels 2.6.12 and later without having to resort to using a <application>PAM</application> module. This method was ok when <application>PAM</application> was not supporting kernel's rlimits operations.
      </para>
      <para>
        Download it <ulink url="http://www.physics.adelaide.edu.au/~jwoithe/">here</ulink>.
      </para>
      <para>
        First, edit the <filename>Makefile</filename> file and change the <varname>PREFIX</varname> variable to <filename class="directory">/usr/local</filename> to <filename class="directory">/usr/bin</filename>. Then uncompress it, rebuild it and install it:
      </para>
      <para>
        <screen><userinput>
$ make clean
$ make
$ su -c "make install"
          </userinput></screen>
      </para>
      <para>
        Once it is installed, edit the <filename>/etc/set_rlimits.conf</filename> file and add the following line at the end:
      </para>
      <para>
        <screen><userinput>
@audio  /usr/bin/qjackctl nice=-1 rtprio=80
	</userinput></screen>
      </para>
      <para>
        Now you will be able to execute <command>qjackctl</command> (see <xref linkend="build-qjackctl" />) with all necessary privileges, and it will be able to execute <command>jackd</command> (see <xref linkend="build-jack-audio-connection-kit" />) with realtime privileges <footnote><para>Execute it like that: <userinput>set_rlimits -r /usr/bin/qjackctl</userinput></para></footnote>.
      </para>
    </sect2>

    <sect2 id="using-pam">
      <title>Using PAM</title>
      <para>
        <emphasis>This is the right way :-)</emphasis>
      </para>
      <para>
        <application>PAM</application> configuration is the better choice. Basically it only consists on updating the <application>PAM</application> limits configuration in <filename>/etc/security/limits.conf</filename><footnote><para>You should be able to use a more distro friendly solution by creating a directory called <filename class="directory">/etc/security/limits.d/</filename> and write your configuration in a file called <filename>audio.conf</filename>.</para></footnote> to fit your needs:
      </para>
      <para>
        <screen><userinput>
@audio  -  rtprio   100
@audio  -  nice     -10
@audio  -  memlock  unlimited
        </userinput></screen>
      </para>
      <para>
        This will allow all software executed by audio group members to access realtime and to consume memory without restriction.
      </para>
      <para>
        Done!
      </para>
    </sect2>
  </sect1>

  <sect1 id="pci-latency">
    <title>PCI latency</title>
    <para>
      To display information about all <acronym>PCI</acronym> buses in your system and all device connected to them, use the <command>lspci</command> utility :
    </para>
    <para>
      <screen><computeroutput>
$ lspci
[...]
00:1f.2 SATA controller: Intel Corporation 82801FR/FRW (ICH6R/ICH6RW) SATA Controller (rev 03)
00:1f.3 SMBus: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) SMBus Controller (rev 03)
01:00.0 VGA compatible controller: nVidia Corporation NV41.1 [GeForce 6800] (rev a2)
02:00.0 Ethernet controller: Broadcom Corporation NetXtreme BCM5751 Gigabit Ethernet PCI Express (rev 01)
04:00.0 Multimedia audio controller: Creative Labs SB Audigy (rev 04)
04:00.1 Input device controller: Creative Labs SB Audigy Game Port (rev 04)
04:00.2 FireWire (IEEE 1394): Creative Labs SB Audigy FireWire Port (rev 04)
04:01.0 Multimedia audio controller: Xilinx Corporation RME Hammerfall DSP (rev 97)
      </computeroutput></screen>
    </para>
    <para>
      To obtain information about latency for each bus, use the <option>-v</option> option:
    </para>
    <para>
      <screen><computeroutput>
# lspci -v
[...]
04:00.0 Multimedia audio controller: Creative Labs SB Audigy (rev 04)
        Subsystem: Creative Labs Unknown device 2006
        Flags: bus master, medium devsel, latency 176, IRQ 16
        I/O ports at dcc0 [size=64]
        Capabilities: [dc] Power Management version 2
[...]
04:01.0 Multimedia audio controller: Xilinx Corporation RME Hammerfall DSP (rev 97)
        Flags: bus master, medium devsel, latency 255, IRQ 17
        Memory at dcdf0000 (32-bit, non-prefetchable) [size=64K]
      </computeroutput></screen>
    </para>
    <para>
      You can see here that the card I mainly use to work with audio (the RME) has the maximum latency priority.
    </para>
    <para>
      To modify the priority of a PCI bus, use the <command>setpci</command> command. Pass it the device you want to control (to control my RME latency for example I use <literal>04:01.0</literal>), followed by the <option>latency_timer</option> option and the value in hexadecimal notation.
    </para>
    <para>
      To give the maximum priority to a bus, just do as <literal>root</literal>:
    </para>
    <para>
      <screen><computeroutput>
# setpci -v -s 04:01.0 latency_timer=ff
      </computeroutput></screen>
    </para>
    <para>
      You can use a script like <ulink url="http://www.esaracco.fr/downloads/pcilatency">this one</ulink> to automate this task. Just download it and put it in your <filename class="directory">/etc/init.d/</filename> directory after updating it to fit you needs. On Debian, you can do the following :
    </para>
    <para>
      <screen><computeroutput>
# wget http://www.esaracco.fr/downloads/pcilatency
# vim pcilatency
# chmod 755 pcilatency
# mv pcilatency /etc/init.d/
# cd /etc/init.d/
# update-rc.d pcilatency defaults
      </computeroutput></screen>
    </para>
  </sect1>

  <sect1 id="alsa">
    <title>ALSA</title>
    <para>
       <acronym>ALSA</acronym> stand for the Advanced Linux Sound Architecture provides audio and <acronym>MIDI</acronym> functionality to the Linux operating system. See the <ulink url="http://www.alsa-project.org/">ALSA homepage</ulink> for more information.
    </para>
    <para>
      See <xref linkend="build-linux-kernel" /> to know how to build a Linux kernel with <acronym>ALSA</acronym> support.
    </para>
    <para>
      Once you have rebuilt your kernel, install <literal>alsa-base</literal> and <literal>alsa-utils</literal> packages. Then as root user execute <command>alsaconf</command>.
    </para>
    <figure><title>ALSA configuration</title>
      <graphic fileref="images/alsaconf-1.png" format="PNG" />
    </figure>
    <para>
      Choose your soundcard driver. <application>Alsaconf</application> will set up your system to load this driver at boot.
    </para>
    <para>
      Next execute <command>alsamixer</command> to suit your needs. However your hardware must contain conventionnal mixer. If not, try to find specific Free projects that support your card (see <xref linkend="hdspmixer" />).
    </para>
    <figure><title>alsamixer</title>
      <graphic fileref="images/alsamixer.png" format="PNG" />
    </figure>
  </sect1>
</chapter>

<chapter id="hardware">
  <title>Hardware</title>
  <para>
    This section will explain some specific hardware installation. Please, feel free to send me documentation patches for this section with your own experimentation.
  </para>

  <sect1 id="rme-hammerfall-hdsp-9632">
    <title>RME Hammerfall HDSP 9632</title>
    <para>
    <mediaobject>
      <imageobject><imagedata fileref="images/rme-9632.png" format="PNG" /></imageobject>
    </mediaobject>
      A great professionnal soundcard that works just fine with GNU/linux once you have understood its philosophy and avoid traps. We will describe here how to install and configure it.
    </para>

    <sect2 id="rme-9632-firmware">
      <title>Firmware</title>
      <para>
        Thanks to Paul Davis and others it exists some kernel stuff for RME HDSP support. However not all firmware versions are supported by old ALSA drivers. ALSA drivers (>= <literal>1.0.14rc1</literal>) are ok<footnote><para>Thanks to Andrew Gaydenko for reporting me this great news :-)</para></footnote>.
      </para>
      <para>
        Depending on your firmware and ALSA version you will sometime need to downgrade the firmware of your card (but, I repeat, <emphasis>this operation is not needed anymore with ALSA drivers >= <literal>1.0.14rc1</literal></emphasis>). To do this, download a older firmware from the RME website. You will need the 1.51 version. You will find it on the <ulink url="http://www.rme-audio.com/english/download/drivers_archive.htm">RME archives</ulink> (under the "HAMMERFALL DSP DRIVERS"). You must download a file named <ulink url="http://www.rme-audio.com/download/treiber_archiv/fut_win_dsp.zip">fut_win_dsp.zip</ulink>.
      </para>
      <para>
        Once you have downloaded this file, save it on a USB key and reboot on Windows. Then just unzip the file and click on the <filename>hdsp_fut.exe</filename> file. Do not take in account Windows alerts and click on the update button. Then reboot.
      </para>
      <para>
        If all was fine, your firmware version should be <literal>1.51</literal> (or <literal>151</literal>) on Windows and <command>lspci</command> should output <literal>rev97</literal> on GNU/Linux:
      </para>
      <para>
        <screen><computeroutput>
$ lspci | grep -i rme
04:01.0 Multimedia audio controller: Xilinx Corporation RME Hammerfall DSP (rev 97)
        </computeroutput></screen>
      </para>
    </sect2>

    <sect2 id="rme-9632-linux-kernel">
      <title>Linux Kernel</title>
      <para>
        First, take a look at <xref linkend="build-linux-kernel"/> if you are not confident with kernel compilation.
      </para>
      <para>
        You will need to compile the <literal>snd-hdsp</literal> <acronym>ALSA</acronym> module.
      </para>
      <para>
        <screen><computeroutput>
  Device Drivers  ---&gt;
    Sound  ---&gt;
      &lt;M&gt; Sound card support
        Advanced Linux Sound Architecture  ---&gt;
          &lt;M&gt; Advanced Linux Sound Architecture
          PCI devices  ---&gt;
            &lt;M&gt; RME Hammerfall DSP Audio
        </computeroutput></screen>
      </para>
      <para>
        Then reboot or load the new module as root with <command>modprobe snd-hdsp</command>.
      </para>
    </sect2>

    <sect2 id="hdsp-utilities">
      <title>HDSP utilities</title>
      <para>
        Thanks to Thomas Charbonnel and others RME HDSP soundcards have special mixer and configurator GUI. Those tools are in the alsa-tools-gui archive downloadable from the <acronym>ALSA</acronym> Web site or packaged for you own GNU/Linux distro.
      </para>

      <sect3 id="hdspconf">
        <title>hdspconf</title>
        <figure><title>hdspconf main window</title>
          <graphic fileref="images/hdspconf-main.png" format="PNG" />
        </figure>
        <para>
          Use this tool to control the basics of your board. In my case I had to check the <guibutton>Adat1 Int.</guibutton> checkbox and <guibutton>ADAT In</guibutton> radio button in order to have the AEB 4/I expansion fonctionnal.
        </para>
      </sect3>

      <sect3 id="hdspmixer">
        <title>hdspmixer</title>
        <figure><title>hdspmixer main window</title>
          <graphic fileref="images/hdspmixer-main.png" format="PNG" />
        </figure>
        <para>
          There is no conventional mixer on this card, so alsamixer and other "generic mixer" applications will do nothing. You will have to use <application>hdspmixer</application> every time you will need to capture/produce sound.
        </para>
      </sect3>

    </sect2>
  </sect1>  
</chapter>

<chapter id="building-required-audio-softwares">
  <title>Building required audio software</title>
  <para>
    For convenience<footnote><para>Most of the time, GNU/Linux distros are not up-to-date, and audio software teams are often very active. Building those software by yourself enables you firstly to have a better understanding of their use and their interactions and secondly to experiment most advanced features and to fix bugs quickly.</para></footnote> I build most of the audio software I am used to work with. You can use any version of gcc >= 3.4<footnote><para>To use another compiler than your system default, just update the following symbolic links: <filename class="symlink">/usr/bin/gcc</filename> and <filename class="symlink">/usr/bin/g++</filename> to point on, respectively (to use gcc 4.x): <filename>/usr/bin/gcc-4.x</filename> and <filename>/usr/bin/g++-4.x</filename>.</para></footnote>. But at this time you will have troubles while compiling the DSSI Hexter plugin with a version >= 4. I mainly use the software described in this chapter, but <ulink url="http://linux-sound.org/">many others</ulink> exist. See <xref linkend="appendix-usefull-audio-links" /> to find useful links.
  </para>

  <note>
    <para>
      Please pay attention to applications' dependencies. First check <filename>README</filename> or <filename>INSTALL</filename> files which are commonly found in tarballs archives. Then carefully check the ouput of the configuration process.
    </para>
  </note>
  
  <sect1 id="build-jack-audio-connection-kit">
    <title>Jack Audio Connection Kit</title>
    <mediaobject>
      <imageobject><imagedata fileref="images/jack-logo.png" format="PNG" /></imageobject>
    </mediaobject>
    <para>
      <application>JACK</application> is a low-latency audio server, written for POSIX conformant operating systems such as GNU/Linux and Apple's OS X. It can connect a number of different applications to an audio device, as well as allowing them to share audio between themselves. Its clients can run in their own processes (ie. as normal applications), or can they can run within the <application>JACK server</application> (ie. as a <emphasis>plugin</emphasis>).
    </para>
    <para>
      I recommand you to always use the <application>SVN</application> version of <application>Jack</application>. Checkout the <application>SVN</application> module as explained <ulink url="http://jackaudio.org/download">here</ulink>.
    </para>
    <para>
      Go to the main <application>Jack</application> directory and do:
    </para>
    <para>
      <screen><userinput>
$ ./autogen.sh --prefix=/usr --enable-mmx --enable-sse --enable-dynsimd --enable-optimize --enable-resize --enable-timestamps --enable-posix-shm --with-gnu-ld
$ make
$ su -c "make install"
      </userinput></screen>
    </para>
    <para>
      The configuring process should detect automatically a lot of things. The output of this step on my machine is:
    </para>
    <para>
      <screen><computeroutput>
jack-audio-connection-kit 0.109.0 :

| Build with ALSA support............................... : true
| Build with old FireWire (FreeBob) support............. : false
| Build with new FireWire (FFADO) support............... : false
| Build with OSS support................................ : true
| Build with CoreAudio support.......................... : false
| Build with PortAudio support.......................... : false
| Compiler optimization flags........................... : -DREENTRANT -O3 -fomit-frame-pointer -ffast-math -funroll-loops -march=k8 -mmmx -msse -mfpmath=sse
| Compiler full flags................................... : -I$(top_srcdir)/config -I$(top_srcdir) -I$(top_srcdir) -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS -Wall -g -DREENTRANT -O3 -fomit-frame-pointer -ffast-math -funroll-loops -march=k8 -mmmx -msse -mfpmath=sse
| Install dir for libjack + backends.................... : ${exec_prefix}/lib64/jack
|
| Default driver backend................................ : "alsa"
| Shared memory interface............................... : "POSIX"
| Install prefix........................................ : /usr
      </computeroutput></screen>
    </para>
  </sect1>

  <sect1 id="build-qjackctl">
    <title>Qjackctl</title>
    <mediaobject>
      <imageobject><imagedata fileref="images/qjackctl-logo.png" format="PNG" /></imageobject>
    </mediaobject>
    <para>
      Provides a simple GUI dialog for setting several <application>JACK</application> daemon parameters, which are properly saved between sessions, and a way control of the status of the audio server daemon. With time, this primordial interface has become richer by including an enhanced patchbay and connection control features.
    </para>
    <para>
      Download it <ulink url="http://qjackctl.sourceforge.net/#Downloads">here</ulink>.
    </para>
    <para>
      <application>Qjackctl</application> needs QT stuff to be built. You should also define the <envar>QTDIR</envar> environment variable.
    </para>
    <para>
      <screen><userinput>
$ ./configure --prefix=/usr
$ make
$ su -c "make install"
      </userinput></screen>
    </para>
  </sect1>
  
  <sect1 id="build-ladspa">
    <title>LADSPA</title>
    <para>
      <acronym>LADSPA</acronym> stands for "Linux Audio Developer's Simple Plugin API".
    </para>
    <para>
      Many audio synthesis and recording packages are in use or in development on Linux. These work in many different ways. <acronym>LADSPA</acronym> provides a standard way for "plugin" audio processors to be used with a wide range of these packages.
    </para>
    <para>
      For instance, this allows a developer to make a reverb program and bundle it into a <acronym>LADSPA</acronym> "plugin library". Ordinary users can then use this reverb within any LADSPA-friendly audio application.
    </para>
    <para>
      If you wonder if VST plugins can be used on GNU/Linux, the answer is "yes"<footnote><para>Using <ulink url="http://www.winehq.com/">WINE</ulink>.</para></footnote>. Some works and others do not. Please, keep in mind that VST plugins are far to be Free as defined by the Free Software Fundation. If you want some information about how to use them with GNU/Linux, please refer to the <ulink url="http://gimpel.gi.funpic.de/Howtos/VST_on_Linux/_pages/1.html">VST on Linux</ulink> Gimpel's Webspace Howto.
    </para>
    <para>
      Most of the applications described in this Howto<footnote><para>Like <application>Rosegarden</application>, <application>Hydrogen</application>, <application>Rezound</application>, <application>Ardour</application>...</para></footnote> are able to handle LADSPA plugins.
    </para>
    
    <sect2 id="ladspa-plugins">
      <title>LADSPA plugins</title>
      <para>
        You will find here informations for some well-known plugins. Feel free to visit the <ulink url="http://www.ladspa.org/">LADSPA homepage</ulink> to find other ones.
      </para>
      <para>
        First off all, to compile LADSPA plugins you will need to install the <ulink url="http://www.ladspa.org/ladspa_sdk/ladspa.h.txt">ladspa.h</ulink> C header file in <filename class="directory">/usr/include/</filename> <footnote><para>Of cource, you will have to rename it from <filename>ladspa.h.txt</filename> to <filename>ladspa.h</filename></para></footnote>.
      </para>
      <para>
        I mainly use the following plugins:
	<itemizedlist>
          <listitem>
	    <formalpara>
	      <title>Steve Harris's LADSPA plugins</title>
              <para>
                Download them <ulink url="http://plugin.org.uk/releases/">here</ulink> <footnote><para>If you have problem on <literal>x86_64</literal> architecture, just try to replace all <option>-march=x86_64</option> by <option>-march=x86-64</option>" after executing <command>configure</command>, it should do the trick.</para></footnote>.
		<screen><computeroutput>
$ ./configure --prefix=/usr
$ make
$ su -c "make install"
		</computeroutput></screen>
	      </para>
	    </formalpara>
	  </listitem>
          <listitem>
	    <formalpara>
	      <title>Tom's Audio Processing LADSPA plugins</title>
              <para>
                Download them <ulink url="http://sourceforge.net/projects/tap-plugins">here</ulink>.
	        After uncompressing the plugins' archive go to the main directory and edit the <filename>Makefile</filename> file to change the following variables like this:
		<screen><computeroutput>
INSTALL_PLUGINS_DIR     =       /usr/lib/ladspa/
INSTALL_LRDF_DIR        =       /usr/share/ladspa/rdf/
		</computeroutput></screen>
		Then just compile it like other software:
		<screen><computeroutput>
$ make
$ su -c "make install"
		</computeroutput></screen>
	      </para>
	    </formalpara>
	  </listitem>
          <listitem>
	    <formalpara>
	      <title>CMT LADSPA plugins</title>
              <para>
                Download them <ulink url="http://www.ladspa.org/download/">here</ulink>.
	        After uncompressing the plugins' archive go to the main directory and edit the <filename>src/makefile</filename> file to change the following variable like this:
		<screen><computeroutput>
INSTALL_PLUGINS_DIR     =       /usr/lib/ladspa/
		</computeroutput></screen>
		Then just compile it like other software <footnote><para>Note that those plugin will not build with a g++ version >= 4. To fix the problem, just edit the <filename>src/analogue.cpp</filename> and add <userinput>a = b = c = 0;</userinput> to the line <literal>264</literal> (just after variables declaration).</para></footnote> <footnote><para>If you experience problem on <literal>x86_64</literal> architecture, just add <literal>-fPIC</literal> in the <filename>Makefile</filename> file, line <literal>48</literal>: <userinput>$(CC) $(CFLAGS) -fPIC -I/usr/local/include -c $&lt;</userinput></para></footnote>:
		<screen><computeroutput>
$ make
$ su -c "make install"
		</computeroutput></screen>
	      </para>
	    </formalpara>
	  </listitem>
          <listitem>
	    <formalpara>
	      <title>CAPS Audio Plugin Suite</title>
              <para>
                Download them <ulink url="http://quitte.de/dsp/caps.html#Download">here</ulink>.
	        After uncompressing the plugins' archive go to the main directory and edit the <filename>Makefile</filename> file to change the following variable like this:
		<screen><computeroutput>
PREFIX = /usr
		</computeroutput></screen>
		Then just compile it like other software<footnote><para>Note that with versions &lt; 0.3.0 this plugin will not build with a g++ version >= 4. To fix the problem, download the following <ulink url="http://quitte.de/dsp/caps-0.2.3+gcc-4.diff">Mario Lang's patch</ulink> and apply it like that:
	      </para>
	      <para>
		<screen><userinput>
$ cd /usr/src/
$ wget http://quitte.de/dsp/caps-0.2.3+gcc-4.diff
$ cd caps-0.2.3/
$ patch -p1 &lt; ../caps-0.2.3+gcc-4.diff
		</userinput></screen>
		</para></footnote>:
		<screen><computeroutput>
$ make
$ su -c "make install"
		</computeroutput></screen>
	      </para>
	    </formalpara>
	  </listitem>
	</itemizedlist>
      </para>
    </sect2>
  </sect1>

  <sect1 id="build-dssi">
    <title>DSSI</title>
    <para>
      DSSI (pronounced <emphasis>dizzy</emphasis>) is an API for audio plugins, with particular application for software synthesis plugins with native user interfaces. 
      DSSI is an open specification developed for use in Linux audio applications, although portable to other platforms. It may be thought of as LADSPA-for-instruments, or something comparable to VSTi.
    </para>
    <para>
      Download all packages (except the <literal>dssi-vst</literal> package<footnote><para>I will not tell you how to work with VST plugins in this tutorial. For details about VST support, see <xref linkend="build-ladspa" /></para></footnote>) from <ulink url="http://sourceforge.net/projects/dssi/">here</ulink>.
    </para>
    <note>
      <para>
        Sometime DSSI is not even packaged in common GNU/Linux distros (like Debian for example), so you do not have other choice than building it yourself.
      </para>
    </note>
    <para>
      Uncompress each package and execute:
    </para>
    <para>
      <screen><userinput>
$ ./configure --prefix=/usr
$ make
$ su -c "make install"
      </userinput></screen>
    </para>
    <para>
      for each one<footnote><para>The Hexter plugin will not compile if your gcc version is >= 4.</para></footnote>. Just build and install the DSSI package first.
    </para>
    <para>
      The output of the configuration step on my machine for the <literal>dssi</literal> package is:
    </para>
    <para>
      <screen><computeroutput>
* ======== DSSI 0.9.1 configured ========
* building jack-dssi-host:            yes
* building DSSI OSC tools:            yes
* building trivial_synth plugin:      yes
* building less_trivial_synth plugin: yes
* building trivial_sampler plugin:    yes
* building less_trivial_synth GUI:    yes
* building trivial_sampler GUI:       yes
      </computeroutput></screen>
    </para>
  </sect1>

  <sect1 id="build-hydrogen">
    <title>Hydrogen</title>
    <mediaobject>
      <imageobject><imagedata fileref="images/hydrogen-logo.png" format="PNG" /></imageobject>
    </mediaobject>
    <para>
      	<application>Hydrogen</application> is an advanced drum machine for GNU/Linux. It's main goal is to bring professional yet simple and intuitive pattern-based drum programming.
    </para>
    <para>
       Download it <ulink url="http://www.hydrogen-music.org/?p=download">here</ulink>.
    </para>
    <para>
      <screen><userinput>
$ ./configure --prefix=/usr
$ make
$ su -c "make install"
      </userinput></screen>
    </para>
    <para>
      The output of the configuration step on my machine is:
    </para>
    <para>
      <screen><computeroutput>
-----------------------------------------------------------------
 Hydrogen 0.9.2 configuration:
-----------------------------------------------------------------

        Source code location:   .
        Prefix                  /usr
        Data path               /usr/share/hydrogen
        LDFLAGS                  -lsndfile   -lFLAC++ -lFLAC -ljack -lasound -llrdf -lraptor -lxml2

        Debug messages:         no
        FLAC:                   yes
        LRDF:                   yes

        Jack:                   yes
        ALSA :                  yes
        OSS:                    yes
        PortAudio               no
        PortMidi:               no

        Features list =  (FLAC) (Jack) (Alsa) (OSS) (LRDF)
      </computeroutput></screen>
    </para>
    <para>
      If you have problems while using <application>Hydrogen</application>, if it starts to react very sluggish on mouse-clicks and updating of the graphics is also very slow, try to apply <ulink url="http://www.esaracco.fr/downloads/SongEditor.cpp-hydrogen-0.9.2.patch">this patch</ulink>. It come from the <ulink url="http://lists.sourceforge.net/lists/listinfo/hydrogen-devel">hydrogen-devel</ulink> mailing-list (you can read the message <ulink url="http://sourceforge.net/mailarchive/message.php?msg_id=12623228">here</ulink>). Apply it like this:
    </para>
    <para>
      <screen><userinput>
$ cd /usr/src/hydrogen-0.9.2/src/gui/SongEditor/
$ patch SongEditor.cpp /usr/src/SongEditor.cpp-hydrogen-0.9.2.patch
      </userinput></screen>
    </para>
    <para>
      For those who use the brand new SVN release, use <application>scons</application> instead of <application>make</application>:
    </para>
    <para>
      <screen><userinput>
$ scons prefix=/usr
$ su -c "scons prefix=/usr install"
      </userinput></screen>
    </para>
    <para>
      And for those, like me, who bought the wonderfull <ulink url="http://www.naturalstudio.co.uk/ns_kit7.html">NS Kit7</ulink> from Natural Studio, I have developed a Perl script that built a Hydrogen's drumkit XML file from scratch, parsing NS Kit7 audio files. You can download it <ulink url="http://www.esaracco.fr/downloads/buildNSKit7.pl">here</ulink>.
    </para>
  </sect1>

  <sect1 id="build-qsynth">
    <title>QSynth</title>
    <mediaobject>
      <imageobject><imagedata fileref="images/qsynth-logo.png" format="PNG" /></imageobject>
    </mediaobject>
    <para>
      <application>QSynth</application> is a <application>Fluidsynth</application> GUI front-end application written in C++ around the Qt3 toolkit using Qt Designer. Eventually it may evolve into a softsynth management application allowing the user to control and manage a variety of command line softsynth but for the moment it wraps the excellent <application>FluidSynth</application>. <application>FluidSynth</application> is a command line software synthesiser based on the Soundfont specification.
    </para>
    <para>
      Download it <ulink url="http://sourceforge.net/projects/qsynth">here</ulink>.
    </para>
    <para>
      It could be useful to use soundfonts if you do not have a Soundblaster card. See <xref linkend="soundfonts-testing-with-qsynth" />.
    </para>
    <para>
      <screen><userinput>
$ ./configure --prefix=/usr
$ make
$ su -c "make install"
      </userinput></screen>
    </para>
  </sect1>

  <sect1 id="build-spiralsynthimodular">
    <title>SpiralSynthModular</title>
    <mediaobject>
      <imageobject><imagedata fileref="images/spiralsynthmodular-logo.png" format="PNG" /></imageobject>
    </mediaobject>
    <para>
     <application>SpiralSynthModular</application> is an object orientated music studio with an emphasis on live use.  You can use it in a fairly straight forward way to make tracks with, or get very experimental. Audio or control data can be freely passed between the plugins. Data can also be fed back on itself for chaotic effects.
    </para>
    <para>
      <application>SpiralSynthModular</application> is not under active development. You can give a try to <application><ulink url="http://www.nongnu.org/om-synth/">Om</ulink></application> if you want.
    </para>
    <para>
      You can dowload <application>SpiralSynthModular</application> <ulink url="http://sourceforge.net/project/showfiles.php?group_id=62620">here</ulink>. However I advise you to work with the last CVS version.
    </para>
    <para>
      <screen><userinput>
$ cvs -d:pserver:anonymous@spiralmodular.cvs.sourceforge.net:/cvsroot/spiralmodular login
$ cvs -z3 -d:pserver:anonymous@spiralmodular.cvs.sourceforge.net:/cvsroot/spiralmodular co -P ssm
      </userinput></screen>
    </para>

    <para>
      Then build it with<footnote><para>Note that if you use a <literal>x86_64</literal> arch you will need to apply a <ulink url="http://www.esaracco.fr/downloads/LADSPAInfo.C.patch">patch</ulink> in order to have LADSPA plugins working.
      </para>
      <para>
        <screen><userinput>
$ cd ssm/SpiralSound/Plugins/LADSPAPlugin/
$ wget http://www.esaracco.fr/downloads/LADSPAInfo.C.patch
$ patch LADSPAInfo.C LADSPAInfo.C.patch
        </userinput></screen></para></footnote>:
    </para>
    <para>
      <screen><userinput>
$ ./autogen.sh --prefix=/usr
$ make
$ su -c "make install"
      </userinput></screen>
    </para>
  </sect1>

  <sect1 id="build-zynaddsubfx">
    <title>ZynAddSubFX</title>
    <mediaobject>
      <imageobject><imagedata fileref="images/zynaddsubfx-logo.png" format="PNG" /></imageobject>
    </mediaobject>
    <warning>
      <para>ZynAddSubFX will not be able to read neither its own configuration file nor instruments patches with 2.3 <ulink url="http://www.minixml.org">MiniXML (mxml) library</ulink> release (but it is ok with >= 2.4). If you can not upgrade to 2.4 you can apply <ulink url="http://www.esaracco.fr/downloads/mxml-file.c.patch">this patch</ulink> on the mxml <filename>mxml-file.c</filename> file to fix the problem.</para>
    </warning>

    <para>
      <application>ZynAddSubFX</application> is a opensource software synthesizer capable of making a countless number of instruments, from some common heared from expensive hardware to interesting sounds that you'll boost to an amazing universe of sounds.
    </para>
    <para>
      You can either download it <ulink url="http://sourceforge.net/projects/zynaddsubfx">here</ulink>, or decide to build it from the <application>CVS</application>: see <ulink url="http://sourceforge.net/cvs/?group_id=62934">here</ulink> for information. To get the current <application>CVS</application> HEAD, do the following:
    </para>
    <para>
      <screen><userinput>
$ cvs -d:pserver:anonymous@zynaddsubfx.cvs.sourceforge.net:/cvsroot/zynaddsubfx login
$ cvs -z3 -d:pserver:anonymous@zynaddsubfx.cvs.sourceforge.net:/cvsroot/zynaddsubfx co -P zynaddsubfx
      </userinput></screen>
    </para>
    <para>
      Then do the following:
    </para>
    <para>
      Then go to the <filename class="directory">src/</filename> subdirectory and edit the <filename>Makefile.inc</filename> file. Then uncomment/comment lines to suit your needs. Significant lines are:
    </para>
    <para>
      <screen><computeroutput>
OS_PORT=LINUX
FFTW_VERSION=3
ASM_F2I=YES
DISABLE_GUI=NO
LINUX_MIDIIN=ALSA
LINUX_AUDIOOUT=OSS_AND_JACK
LINUX_DSSI=NO
      </computeroutput></screen>
    </para>
    <para>
      Then make sure that the following packages are installed on your system: <literal>fluid</literal>, <literal>libfltk</literal> and <literal>libmxml</literal>.
    </para>
    <para>
      To build and install <application>ZynAddSubFX</application>, just do <footnote><para>If you experiment problems with CVS version of ZynAddSubFX and SVN version of Jack (>= 998), try to apply the following <ulink url="http://www.esaracco.fr/downloads/zyn-jack-midi-adjust.patch">patch</ulink>.</para></footnote>:
    </para>
    <para>
      <screen><userinput>
$ make
$ su
# cp zynaddsubfx /usr/bin/
# cd ..
# mkdir -p /usr/share/zynaddsubfx
# /bin/cp -a banks presets /usr/share/zynaddsubfx/
      </userinput></screen>
    </para>
    <para>
      You will find up-to-date instruments banks <ulink url="http://zynaddsubfx.sourceforge.net/doc/instruments/">here</ulink>.
    </para>
  </sect1>

  <sect1 id="build-rosegarden">
    <title>Rosegarden</title>
    <mediaobject>
      <imageobject><imagedata fileref="images/rosegarden-logo.png" format="PNG" /></imageobject>
    </mediaobject>
    <para>
      <application>Rosegarden</application> is a professional audio and <acronym>MIDI</acronym> sequencer, score editor, and general-purpose music composition and editing environment.
    </para>
    <para>
      If you want to use it efficiently, D. Michael McIntyre (aka. Silvan) wrote a <ulink url="http://rosegarden.sourceforge.net/tutorial/"><citetitle>The Rosegarden Companion</citetitle></ulink>, a great little book about <application>Rosegarden</application>, and also a lot of very interesting and good written other supplemental tutorials from Silvan.
    </para>
    <note>
      <para>
        Most of the time <application>Rosegarden</application> which is distributed with common GNU/Linux distros was not built with DSSI support. Manually rebuilding it is the only way to have DSSI plugins working with it.
      </para>
    </note>
    <para>
      You can either download the stable archive, or decide to build it from the <application>SVN</application>: see <ulink url="http://www.rosegardenmusic.com/getting/">here</ulink> for information. To get the current <application>SVN</application> trunk, do the following:
    </para>
    <para>
      <screen><userinput>
svn co https://svn.sourceforge.net/svnroot/rosegarden/trunk/rosegarden rosegarden
      </userinput></screen>
    </para>
    <para>
      I use the <application>SVN</application> trunk of <application>Rosegarden</application>. And when things go wrong I edit <application>Rosegarden</application> files (<filename>.rg</filename>) manually to repair them. <application>Rosegarden</application>'s files are XML files compressed with <application>gzip</application><footnote><para>You will find tools like <command>rgedit</command> and <command>rgview</command> (to manipulate <filename>.rg</filename> files) in the <filename class="directory">scripts/</filename> subdirectory of the <application>CVS</application> tree.</para></footnote>.
    </para>
    <para>
      <screen><userinput>
$ cmake . -DCMAKE_INSTALL_PREFIX=`kde-config --prefix`
      </userinput></screen>
    </para>
    <para>
        With my configuration this step produces:
    </para>
    <para>
      <screen><computeroutput>
-- Found Qt3 (version 3.3.7)
-- Found KDE3 include dir: /usr/include/kde
-- Found KDE3 library dir: /usr/lib
-- Found KDE3 dcopidl preprocessor: /usr/bin/dcopidl
-- Found KDE3 dcopidl2cpp preprocessor: /usr/bin/dcopidl2cpp
-- Found KDE3 kconfig_compiler preprocessor: /usr/bin/kconfig_compiler
-- Program pkg-config found (/usr/bin/pkg-config)
-- Found LADSPA (/usr/include)
-- Program msgfmt found (/usr/bin/msgfmt)
-- KDE3HTMLDIR : share/doc/kde/HTML
-- KDE3DATADIR : share/apps
-- KDE3ICONDIR : share/icons
-- KDE3MIMEDIR : share/mimelnk
-- KDE3MENUDIR : share/applications/kde
-- KDE3L18NDIR : share/locale
-- KDE3EXECDIR : bin
-- Program kde-config found (/usr/bin/kde-config)
-- Program meinproc found (/usr/bin/meinproc)
-- Rosegarden 1.7.0-svn will be built for install into /usr
-- Configured to compile for release without debug information

Installation Summary
--------------------

Install Directory             : /usr
Build type                    : Release
Use Qt/KDE precompiled headers: FALSE

Xft notation font support     : TRUE
No LIRC support configured.

ALSA MIDI support             : TRUE
JACK audio support            : TRUE
LADSPA plugin support         : TRUE
DSSI synth plugin support     : TRUE
Custom OSC plugin GUI support : TRUE
Audio timestretching          : TRUE
LRDF plugin metadata support  : TRUE

-- Configuring done
-- Generating done
-- Build files have been written to: /usr/src/audio/rosegarden
      </computeroutput></screen>
    </para>
    <para>
      Then build and install it. The process can take some time, so be patient :-)
    </para>
    <para>
      <screen><userinput>
$ make
$ su -c "make install"
      </userinput></screen>
    </para>
  </sect1>

  <sect1 id="build-lmms">
    <title>LMMS - Linux Multimedia Studio</title>
    <mediaobject>
      <imageobject><imagedata fileref="images/lmms-logo.png" format="PNG" /></imageobject>
    </mediaobject>
    <para>
      <application>LMMS</application> aims to be a free alternative to popular (but commercial and closed-source) programs like FruityLoops, Cubase and Logic giving you the ability of producing music with your computer by creating cool loops, synthesizing and mixing sounds, arranging samples, having more fun with your MIDI-keyboard and much more....
    </para>
    <para>
      You can either download the stable archive <ulink url="http://sourceforge.net/project/showfiles.php?group_id=105168&amp;package_id=113209">here</ulink>, or decide to build it from the <application>SVN</application>: see <ulink url="http://lmms.sourceforge.net/download.php">here</ulink> for information. To get the current <application>SVN</application> trunk, do the following:
    </para>
    <para>
      <screen><userinput>
svn co https://svn.sf.net/svnroot/lmms/trunk/lmms
      </userinput></screen>
    </para>
    <para>
      Then do a <userinput>autoreconf -is</userinput> followed by a <userinput>./configure --prefix=/usr</userinput> and take a look to the output. If you see something like that:
    </para>
     <para>
      <screen><userinput>
[...]
========================
 ===  LMMS - WARNING  =======================================================
 ========================
 =
 = You don't seem to have SDL_sound-library installed and/or SDL_sound-
 = development-package is missing. This means that you can only load samples
 = within LMMS if you have libsndfile and libvorbis installed!
 = Consider installing the missing packages for using the full power of LMMS.
 =
[...]
      </userinput></screen>
    </para>
    <para>
      Install the <literal>libsdl-sound1.2</literal> and <literal>libsdl-sound1.2-dev</literal> packages.
    </para>
    <para>
      Then do the following:
    </para>
    <para>
      <screen><userinput>
$ make
$ su -c "make install"
      </userinput></screen>
    </para>
  </sect1>

  <sect1 id="build-ardour">
    <title>Ardour</title>
    <mediaobject>
      <imageobject><imagedata fileref="images/ardour-logo.png" format="PNG" /></imageobject>
    </mediaobject>
    <para>
<application>Ardour</application> is a digital audio workstation (<acronym>DAW</acronym>). You can use it to record, edit and mix multi-track audio. You can produce your own CDs, mix video soundtracks, or just experiment with new ideas about music and sound.
    </para>
    <para>
      You can either download the stable archive, or decide to build it from the <application>SVN</application> : see <ulink url="http://www.ardour.org/download_full">here</ulink> for information.
    </para>
    <para>
      Download it from <ulink url="http://www.ardour.org/download_full">here</ulink>, then :
    </para>
    <para>
      <screen><userinput>
$ scons PREFIX=/usr
$ su -c "scons install"
      </userinput></screen>
    </para>
  </sect1>

  <sect1 id="build-jamin">
    <title>JAMin</title>
    <mediaobject>
      <imageobject><imagedata fileref="images/jamin-logo.png" format="PNG" /></imageobject>
    </mediaobject>
    <para>
      <application>JAMin</application> is the <application>JACK Audio Connection Kit (JACK)</application> Audio Mastering interface. <application>JAMin</application> is an open source application designed to perform professional audio mastering of stereo input streams. It uses <acronym>LADSPA</acronym> for digital signal processing (<acronym>DSP</acronym>). <application>JAMin</application> is licensed under the <acronym>GPL</acronym>.
    </para>
    <para>
      You can either download the stable archive <ulink url="http://sourceforge.net/project/showfiles.php?group_id=78441">here</ulink>, or decide to build it from the <application>CVS</application>: see <ulink url="http://sourceforge.net/cvs/?group_id=78441">here</ulink> for information. To get the current <application>CVS</application> HEAD, do the following:
    </para>
    <para>
      <screen><userinput>
$ cvs -d:pserver:anonymous@jamin.cvs.sourceforge.net:/cvsroot/jamin login
$  cvs -z3 -d:pserver:anonymous@jamin.cvs.sourceforge.net:/cvsroot/jamin co -P jamin
      </userinput></screen>
    </para>
    <para>
      Then do the following:
    </para>
    <para>
      <screen><userinput>
$ ./autogen.sh --prefix=/usr
$ make
$ su -c "make install"
      </userinput></screen>
    </para>
  </sect1>

  <sect1 id="build-timemachine">
    <title>Jack Timemachine</title>
    <mediaobject>
      <imageobject><imagedata fileref="images/timemachine-logo.png" format="PNG" /></imageobject>
    </mediaobject>
    <para>
      <application>JACK</application> audio recorder for spontaneous and conservatory use.
    </para>
    <para>
      Download it <ulink url="http://plugin.org.uk/timemachine/">here</ulink>.
    </para>
    <para>
      I use it very often to capture <application>Rosegarden</application> output and to convert in WAV format, before encoding it with <application>Oggenc</application> or <application>Lame</application>. It writes WAV files with a sample format of 32bit float, which is not appropriate to my configuration. So I must use <application>Rezound</application> to transform it to a <userinput>signed</userinput> sample format with a sample width of <userinput>24</userinput>.
    </para>
    <para>
      You can capture all that <application>Jack</application> can manage. It is especially great when you just want to grabe what actually sounds on your soundcard (audio CD, sounds of video DVD...).
    </para>
    <para>
      <screen><userinput>
$ ./configure --prefix=/usr
$ make
$ su -c "make install"
      </userinput></screen>
    </para>
  </sect1>

  <sect1 id="build-rezound">
    <title>Rezound</title>
    <mediaobject>
      <imageobject><imagedata fileref="images/rezound-logo.png" format="PNG" /></imageobject>
    </mediaobject>
    <para>
      ReZound aims to be a stable, open source, and graphical audio file editor primarily for but not limited to the Linux operating system.
    </para>
    <para>
      Download it <ulink url="http://sourceforge.net/project/showfiles.php?group_id=5056">here</ulink>.
    </para>
    <para>
      I use it as often as I use <application>Timemachine</application> to adapt audio files in a suitable format and to add some final effects <footnote><para><application>Rezound</application> will failed to build on 64-bit arch. To build it with success, apply <ulink url="http://www.esaracco.fr/downloads/rezound-0.12.2beta-64-bit.patch">this patch</ulink> (taken from <ulink url="http://sourceforge.net/mailarchive/forum.php?thread_id=8925105&amp;forum_id=18767">this thread</ulink>) like that:
    </para>
    <para>
      <screen><userinput>
$ cd /usr/src/
$ wget http://www.esaracco.fr/downloads/rezound-0.12.2beta-64-bit.patch
$ cd rezound-0.12.2beta/
$ patch -p0 &lt; ../rezound-0.12.2beta-64-bit.patch
      </userinput></screen></para></footnote>.
    </para>
    <para>
      <screen><userinput>
$ ./configure --prefix=/usr --enable-largefile
$ make
$ su -c "make install"
      </userinput></screen>
    </para>
  </sect1>

   <sect1 id="build-lame">
    <title>Lame</title>
    <para>
      <application>LAME</application> is an LGPL MP3 encoder. The Open source development model allowed to improve its quality and speed since 1999. It is now an highly evolved MP3 encoder, with quality and speed able to rival state of the art commercial encoders.
    </para>
    <para>
      Download it <ulink url="http://lame.sourceforge.net/download/download.html">here</ulink>.
    </para>
    <para>
      <screen><userinput>
$ ./configure --prefix=/usr
$ make
$ su -c "make install"
      </userinput></screen>
    </para>
  </sect1>
</chapter>

<chapter id="soundfonts">
  <title>Soundfonts</title>
  <para>
    Just look at the <ulink url="http://en.wikipedia.org/wiki/Soundfont">Wikipedia soundfont definition</ulink> before reading this chapter.
  </para>
  <para>
    Once you have software to make some noise, you must use some soundfont that contains those great noises you want :-) If you have a Soundblaster card you can even directly load those soundfonts on the card. Others will use a soft synthetizer and work with soundfonts this way.
  </para>

  <sect1 id="getting-soundfonts">
    <title>Getting soundfonts</title>
    <para>
      See <xref linkend="appendix-soundfonts" /> for non-commercial soundfonts web sites links.
    </para>
    <para>
      I mainly use 2 of them. You will find them here:
      <itemizedlist>
        <listitem>
          <para>
            <ulink url="ftp://ftp.personalcopy.net/pub/PC51f.sf2.gz">PC51f</ulink> (compressed - 51M)- The one I use mainly. Good, except for violins.
          </para>
        </listitem>
        <listitem>
          <para>
            <ulink url="http://www.hammersound.net/cgi-bin/soundlink.pl?action=view_download_page;ID=699">Fuild (release 3)</ulink> (compressed - 68M) - Good for orchestral strings (especially violins and violas).
          </para>
        </listitem>
      </itemizedlist>
    </para>
    <para>
       You will find a lot of soundfonts archives compressed with the <ulink url="http://melodymachine.com/sfark.htm">sfArk</ulink> tool. You can download it from <ulink url="http://melodymachine.com/files/sfarkxtc_lx86.tar.gz">here</ulink>.
    </para>
    <para>
      To uncompress a file with it, just uncompress it with <userinput>tar zxvf -C /usr/local/bin/</userinput> and execute: <userinput>sfarkxtc FluidR3\ GS.sfArk /tmp/fluidr3.sf2</userinput>.
    </para>
  </sect1>

  <sect1 id="using-soundfonts">
    <title>Using soundfonts</title>
    <para>
      Soundfonts can be loaded on soundcard, or used with a soft synthetizer.
    </para>
    
    <sect2 id="soundfonts-with-soundblaster-soundcard">
      <title>With Soundblaster soundcard</title>
      <para>
        If you have a Soundblaster soundcard, install a package named <literal>awesfx</literal>. This package should contain the <application>asfxload</application> application. This little tool will help us to load the soundfonts in the soundcard.
      </para>
      <para>
        Once you have downloaded and uncompressed your soundfont, just execute something like <userinput>asfxload /tmp/fluidr3.sf2</userinput>, and wait for a while.
      </para>
      <para>
        A software like <application>Rosegarden</application> is able to load sounfount for you at startup (see <xref linkend="playing-with-rosegarden"/>).
      </para>
    </sect2>

    <sect2 id="soundfonts-with-other-soundcards">
      <title>With other soundcards</title>
      <para>
        It exists a lot of pretty good synthetizers. Some of them have more features than others, but most of them allow you to load your own soundfonts. In those examples we will use one of the DSSI plugins we have built: <filename class="libraryfile">fluidsynth-dssi.so</filename> (see <xref linkend="build-dssi" />), and QSynth (see <xref linkend="build-qsynth" />).
      </para>
      
      <sect3 id="soundfonts-testing-with-dssi-plugins">
        <title>Testing with DSSI plugins</title>
        <para>
          To use directly DSSI plugins you must at first launch <application>Jack server</application>. To do that, just execute <application>Qjackctl</application> as normal user (see <xref linkend="execute-jack-at-first" />). Then we use the <application>Jack DSSI host</application> program to load and execute the <application>Fluidsynth</application> DSSI plugin with <userinput>jack-dssi-host fluidsynth-dssi.so</userinput>. You will see a little graphic interface.
        </para>
        <figure><title>Fluidsynth DSSI plugin graphic interface</title>
          <graphic fileref="images/fluidsynth-dssi-plugin.png" format="PNG" />
        </figure>
        <para>
          Click on the <guibutton>Load Soundfont...</guibutton> button to load a soundfont, choose any instrument and click on <guibutton>Send test note</guibutton> to hear its sound.
        </para>
      </sect3>

      <sect3 id="soundfonts-testing-with-qsynth">
        <title>Testing with QSynth</title>
	<para>
          First, execute <application>Qjackctl</application> as normal user (see <xref linkend="execute-jack-at-first" />) to launch <application>Jack server</application>. Then execute <application>QSynth</application>. In fact, <application>QSynth</application>, like other audio software, can run with or without <application>Jack</application>, directly using OSS, ALSA etc.
	</para>
	<figure><title>QSynth graphic interface</title>
          <graphic fileref="images/qsynth.png" format="PNG" />
        </figure>
        <para>
          Click on the <guibutton>Setup</guibutton> button, go to the <guibutton>Soundfonts</guibutton> notebook and load at least one soundfont. Now QSynth is ready for giving us sound when we will need it (see <xref linkend="rosegarden-using-soft-synthetizers" />).
        </para>
      </sect3>
    </sect2>
  </sect1>
</chapter>
 
<chapter id="create-music">
  <title>Create music</title>
  <para>
    Now that we have built most needed software, we can begin to discover the GNU/Linux sound creation world. First I must say that I systematically use <application>Jack</application> to interconnect sotwares between them, even if most of them can run without <application>Jack</application>. It is a useful application that permits to play with almost everything that claim to be a <application>Jack</application> client (and all software here are <application>Jack</application>-compliant).
  </para>

  <sect1 id="execute-jack-at-first">
    <title>Execute Jack at first</title>
    <note>
      <para>
        To know how to build <application>Jack server</application>, see <xref linkend="build-jack-audio-connection-kit" />.
      </para>
      <para>
        To know how to build <application>Qjackctl</application>, see <xref linkend="build-qjackctl" />.
      </para>
    </note>
    <para>
      Setting <application>Jack</application> can be a nightmare, but sometimes it works more or less as you expected it to work (that is to say without too much <literal>xruns</literal>). We will not explain here what <literal>xruns</literal> are, it is enough to notice that they are bad. They must not appear while applications are running. But they can sometimes appear when you shutdown them. Not really bad in this case.
    </para>
    <para>
      You can either execute <application>Jack server</application> as command line or use <application>Qjackctl</application>. I recommand using <application>Qjackctl</application>, for it makes connection/disconnection between <application>Jack</application> clients more simple. It you have chosen to use <application>set_rlimits</application> instead of <application>Realtime LSM</application> or <application>PAM</application> to manage realtime privileges access (see <xref linkend="obtaining-realtime-privileges" />), do not forget to execute those applications prefixing them with <userinput>set_rlimits -r</userinput>.
    </para>
    <figure><title>Jack server main setup window</title>
      <graphic fileref="images/jack-main-setup.png" format="PNG" />
    </figure>
    <para>
      Things like <computeroutput>/usr/bin/jackd -R -dalsa -dhw:0 -r48000 -p128 -n2</computeroutput> should be reasonable. Adapt values to your hardware's configuration.
    </para>
    <para>
      Read carefully the <command>jackd</command> manpage and do not hesitate to try different values, especially for the "Frame/Period" parameter (<option>-p</option> command line argument):
    </para>
    <para>
      <screen><computeroutput>
-p, --period int
              Specify the number of frames between JACK process() calls.   The
              default  is 1024.  If you need low latency, set -p as low as you
              can go without seeing xruns.  A larger period size yields higher
              latency,  but makes xruns less likely.  The JACK capture latency
              in seconds is --period divided by --rate.
      </computeroutput></screen>
    </para>
    <para>
      Now <application>Jack</application> is up and running.
    </para>
    <figure><title>Jack server main window</title>
      <graphic fileref="images/jack-main.png" format="PNG" />
    </figure>
  </sect1>

  <sect1 id="playing-with-zynaddsubfx">
    <title>Playing with ZynAddSubFX</title>
    <note>
      <para>
        To know how to build <application>ZynAddSubFX</application>, see <xref linkend="build-zynaddsubfx" />.
      </para>
    </note>
    <para>
      You can use <application>ZynAddSubFX</application> alone to understand what it is and how it works before using it with an audio sequencer like <application>Rosegarden</application>. We will only see here the basics of this powerful software. For more information, see its <ulink url="http://zynaddsubfx.sourceforge.net/">Homepage</ulink>.
    </para>
    <note>
      <para>
        If the internal samplerate of your Soundward is different than <literal>44100</literal> (it is to say <literal>48000</literal> for example), launch it like that: <userinput>zynaddsubfx --sample-rate=48000</userinput>.
      </para>
    </note>
    <figure><title>ZynAddSubFX main window</title>
      <graphic fileref="images/zynaddsubfx-main.png" format="PNG" />
    </figure>
    <para>
      Graphic interface is nice, but fonts are always a little bit to big for widgets. I do not know how to reduce them <footnote><para>Note from Ismael Cortes: <quote>The only way I have found to get rid of that is to recompile FLTK (and maybe ZynAddSubFX, if it was compiled with FLTK statically) without the xft option configured (i.e. <option>--disable-xft</option> or just omitting <option>--enable-xft</option>, since it defaults to off). That seems to get the fonts were they should.</quote></para></footnote>.
    </para>
    <para>
      Anyway, once you are here you should see <guilabel>ZynAddSubFX</guilabel> line in the <guilabel>Readable Clients/output Ports</guilabel> part of the connexion manager screen.
    </para>
    <figure id="jack-connection-manager-zynaddsubfx"><title>Jack connection manager/ZynAddSubFX client</title>
      <graphic fileref="images/jack-connection-manager-zynaddsubfx.png" format="PNG" />
    </figure>
    <para>
      Do appropriate connections between <application>ZynAddSubFX</application> outputs and your soundcard inputs, as seen in screenshot <xref linkend="jack-connection-manager-zynaddsubfx" /> <footnote><para>If you are lazy like me and do not want to manually connect it every time you launch it, just uncomment the 2 following lines in <filename>src/Output/JACKaudiooutput.C</filename>:
    </para>
    <para>
      <screen><computeroutput>
/*
  jack_connect(jackclient,jack_port_name(outport_left),"alsa_pcm:out_1");    
  jack_connect(jackclient,jack_port_name(outport_right),"alsa_pcm:out_2");
*/
      </computeroutput></screen>
    </para>
    <para>
      and replace <literal>out_1</literal> by <literal>playback_1</literal> and <literal>out_2</literal> by <literal>playback_2</literal>. Then rebuild <application>ZynAddSybFX</application> as explained in <xref linkend="build-zynaddsubfx" />.
      </para></footnote>.
    </para>
    <para>
      Now go to the main <application>ZynAddSubFX</application> screen, open the 
      <menuchoice>
        <guimenu>Instrument</guimenu>
      	<guimenuitem>Virtual keyboard...</guimenuitem>
      </menuchoice> 
      menu.
    </para>
    <figure><title>ZynAddSubFX virtual keyboard</title>
      <graphic fileref="images/zynaddsubfx-keyboard.png" format="PNG" />
    </figure>
    <para>
      If you either click on the virtual synthetizer keys or press your computer keyboard keys you should hear some sound. You are hearing the default song of the <application>ZynAddSubFX</application> bank. To change instrument, open the 
      <menuchoice>
        <guimenu>Instrument</guimenu>
	<guimenuitem>Show instrument bank</guimenuitem>
      </menuchoice>
      menu. Then choose a bank and click on a patch. You should see the patch name displayed in the main window. But for now you are just working with 1 track.
    </para>
    <para>
      To add other tracks and control their volume in an easy way, just click on the <guibutton>panel Window</guibutton> button in the main window. You will see a mixer like this:
    </para>
    <figure><title>ZynAddSubFX multitracks mixer</title>
      <graphic fileref="images/zynaddsubfx-mixer.png" format="PNG" />
    </figure>
    <para>
      You can do a lot of things with <application>ZynAddSubFX</application>. Play with it a while.
    </para>
  </sect1>

  <sect1 id="playing-with-hydrogen">
    <title>Playing with Hydrogen</title>
    <note>
      <para>
        To know how to build <application>Hydrogen</application>, see <xref linkend="build-hydrogen" />.
      </para>
    </note>
    <para>
      Hydrogen is a good alternative to GM drum kits. It is really specialized in percussions pattern creation.
    </para>
    <figure><title>Hydrogen main window</title>
      <graphic fileref="images/hydrogen-main.png" format="PNG" />
    </figure>
    <para>
      This application is simple to use. Just create patterns in the "Pattern editor" and chain them in the "Song editor".
    </para>
  </sect1>

  <sect1 id="playing-with-rosegarden">
    <title>Playing with Rosegarden</title>
    <note>
      <para>
        To know how to build <application>Rosegarden</application>, see <xref linkend="build-rosegarden" />.
      </para>
    </note>
    <para>
      I really appreciate <application>Rosegarden</application>. It is a really amazing software, and it evolves in a good way. Its developers are kind and do a great job. Thanks to them.
    </para>
    <para>
      I will neither show you here all features, nor explain you in details how to use it. I will just try to show you the way to begin. For more informations, take a look at <ulink url="http://rosegarden.sourceforge.net/tutorial/">this page</ulink>.
    </para>
    <para>
      I mainly use <application>Rosegarden</application> to do <acronym>MIDI</acronym> compositions, and use its great notation editor. But you can do a lot of things with it: 
      <itemizedlist>
        <listitem><para>
          Connect external <acronym>MIDI</acronym> instruments, record them and see the corresponding notation.
        </para></listitem>
        <listitem><para>
          Connect accoustic instruments, record them and apply effects.
        </para></listitem>
        <listitem><para>
          ... 
        </para></listitem>	
      </itemizedlist>
    </para>

    <sect2 id="rosegarden-settings">
      <title>Rosegarden settings</title>
      <para>
        We will just see here the main settings of <application>Rosegarden</application>, that is to say <emphasis>Sequencer</emphasis> settings.
      </para>
      <figure><title>Rosegarden General settings</title>
        <graphic fileref="images/rosegarden-settings-general.png" format="PNG" />
      </figure>
      <para>
        Click on the
	<menuchoice>
          <guimenu>Settings</guimenu>
	  <guimenuitem>Configure Rosegarden...</guimenuitem>
	</menuchoice>
	menu to raise the windows settings. Then click on the <guibutton>Sequencer</guibutton> button.
      </para>
      <para>
        To load a specific Soundfont at <application>Rosegarden</application> startup, just click to the <guibutton>Load SoundFont to SoundBlaster card at startup</guibutton> radio button, enter the path to the <command>asfxload</command> command and select a Soundfont to load. See <xref linkend="soundfonts" /> for Soundfonts informations. Save your choices.
      </para>
      <para>
        Next go to the
	<menuchoice>
          <guimenu>Composition</guimenu>
	  <guimenuitem>Edit Document Properties...</guimenuitem>
	</menuchoice>
	menu. Then click on the <guibutton>Audio</guibutton> button and choose the directory where <application>Rosegarden</application> will save your audio tracks. Audio tracks are tracks on which you have recorded external instruments. For the moment, just choose a base directory on a well dimensioned partition (audio files can be pretty large). Later we will adapt subdirectories for each of our songs. Save your choices.
      </para>
      <para>
        Now that we have customized settings we can tell <application>Rosegarden</application> to save them as the default for all futur new projects by clicking on the
	<menuchoice>
          <guimenu>Composition</guimenu>
	  <guisubmenu>Studio</guisubmenu>
	  <guimenuitem>Save Current Document as Default Studio</guimenuitem>
	</menuchoice>
	menu.
      </para>
      <para>
        To check that all DSSI plugins we have compiled have been loaded by <application>Rosegarden</application>, click on the <guiicon><inlinegraphic fileref="images/rosegarden-synth-plugins-icon.png"/></guiicon> icon on the main menu. You should see some lines and have the choice to select plugins in combo boxes. If not, go to <xref linkend="build-dssi" /> and check what is wrong in you configuration.
      </para>
      <figure id="rosegarden-synth-plugins"><title>Rosegarden synth plugins manager</title>
        <graphic fileref="images/rosegarden-synth-plugins.png" format="PNG" />
      </figure>
    </sect2>
    
    <sect2 id="rosegarden-using-soft-synthetizers">
      <title>Using soft synthetizers</title>
      <para>
        Using <application>Rosegarden</application> with a soft synthetizer is as easy as executing both your soft synthetizer and <application>Rosegarden</application> at the same time. As a example we will use the <application>fuidsynth</application> graphic frontend: <application>QSynth</application>.
      </para>
    </sect2>

    <sect2 id="rosegarden-recording-audio-tracks">
      <title>Recording audio tracks</title>
      <para>
        
      </para>
    </sect2>
  </sect1>

  <sect1 id="playing-with-ardour">
    <title>Playing with Ardour</title>
    <note>
      <para>
        To know how to build <application>Ardour</application>, see <xref linkend="build-ardour" />.
      </para>
    </note>
    <para>
      <application>Ardour</application> is a rather complex application, so I advise you to refer to <ulink url="http://ardour.org/files/manual/index.html">its documentation</ulink>.
    </para>
    <figure><title>Ardour main window</title>
      <graphic fileref="images/ardour-main.png" format="PNG" />
    </figure>
  </sect1>

  <sect1 id="playing-with-jamin">
    <title>Playing with JAMin</title>
    <note>
      <para>
        To know how to build <application>JAMin</application>, see <xref linkend="build-jamin" />.
      </para>
    </note>
    <para>
      Masterisation is a complex step and it exists a lot of books and tutorial.
    </para>
    <figure><title>JAMin main window</title>
      <graphic fileref="images/jamin-main.png" format="PNG" />
    </figure>
    <para>
      Here is the advices of one of the Ardour's developers on using JAMin with Ardour:

      <orderedlist>
        <listitem><para>
          Open up either the editor mixer for the master bus or use the mixer window
        </para></listitem>
        <listitem><para>
          Right click on the black box above the master fader to open the context menu
        </para></listitem>
        <listitem><para>
          Select <menuchoice><guimenu>New Insert</guimenu></menuchoice> (it will automatically be a stereo insert)
        </para></listitem>
        <listitem><para>
          "Edit" the insert either via right clicking on the insert and selecting <menuchoice><guimenuitem>Edit</guimenuitem></menuchoice>, or "edit click" (<keycombo><keycap>CTRL</keycap><keycap>Right</keycap></keycombo> click) the insert
        </para></listitem>
        <listitem><para>
          Connect <application>JAMin</application> inputs and outputs to the send outputs and inputs 
        </para></listitem>
        <listitem><para>
          "Activate" the insert by either right clicking on the insert and selectiong <menuchoice><guimenuitem>Activate</guimenuitem></menuchoice> or middle-click on the insert
        </para></listitem>
      </orderedlist>
    </para>
  </sect1>

</chapter>

<chapter id="capturing-and-encoding">
  <title>Capturing and encoding</title>
  <para>
    Once we have created something and that we want to share it with others, we must capture and encode it. The capture can be easily done in WAV format with <application>Timemachine</application> or in a more complex way with <application>Ardour</application>. Then we will encode it in other formats to share it.
  </para>
  <sect1 id="playing-with-timemachine">
    <title>Playing with Timemachine</title>
    <note>
      <para>
        To know how to build <application>Timemachine</application>, see <xref linkend="build-timemachine" />.
      </para>
    </note>
    <para>
      <application>Timemachine</application> allows you to capture everything that can be understood by <application>Jack server</application>.
    </para>
    <para>
      The first step is to launch <application>Timemachine</application> with some arguments to tell it to capture in WAV format and to manage its files in our Desktop directory:
    </para>
    <para>
      <screen><userinput>
timemachine -f wav -p /home/youruser/Desktop/
      </userinput></screen>
    </para>
    <para>
      Just replace the <userinput>youruser</userinput> string by your current Unix user.
    </para>
    <para>
      Once <application>Timemachine</application> is started it is necessary to manually connect the required <application>Jack</application>'s clients outputs to <application>Timemachine</application>'s inputs. Saying you want to record a <application>Rosegarden</application> composition, just connect <application>Rosegarden</application>'s output 1 <guilabel>record monitor out L</guilabel> to <application>Timemachine</application>'s input <guilabel>in_1</guilabel> and <application>Rosegarden</application>'s output 2 <guilabel>record monitor out R</guilabel> to <application>Timemachine</application>'s input <guilabel>in_2</guilabel>, as seen in <xref linkend="jackconnectionmanagertimemachine" />.
    </para>
    <figure id="jackconnectionmanagertimemachine"><title>Jack connection manager/Timemachine client</title>
      <graphic fileref="images/jack-connection-manager-timemachine.png" format="PNG" />
    </figure>
    <para>
      Now you can click on the main <application>Timemachine</application> green button, and play your <application>Rosegarden</application> song.
    </para>
    <figure><title>Timemachine</title>
      <graphic fileref="images/timemachine-main.png" format="PNG" />
    </figure>
  </sect1>

  <sect1 id="playing-with-rezound">
    <title>Playing with Rezound</title>
    <note>
      <para>
        To know how to build <application>Rezound</application>, see <xref linkend="build-rezound" />.
      </para>
    </note>
    <para>
      The WAV file produced by <application>Timemachine</application> must be edited with <application>Rezound</application> to remove extra parts, control volume level or apply effects.
    </para>
    <para>
      To launch <application>Rezound</application> as a <application>Jack</application> client do:
    </para>
    <para>
      <screen><userinput>
rezound --audio-method=jack
      </userinput></screen>
    </para>
    <para>
      Once your file is loaded, cut the beginning and the ending to fit your needs.
    </para>
    <figure><title>Rezound main window</title>
      <graphic fileref="images/rezound-main.png" format="PNG" />
    </figure>
    <para>
      I am used to raise the volume level. To do that, select the entire song with 
      <keycombo>
        <keycap>CTRL</keycap>
	<keycap>A</keycap>
      </keycombo> 
      and click on the main menu to 
      <menuchoice>
        <guimenu>Effects</guimenu>
	<guimenuitem>Gain</guimenuitem>
      </menuchoice>. 
      Then enter a scalar value of <userinput>3</userinput> or <userinput>4</userinput>, raise the <guibutton>Gain</guibutton> level and click on the <guibutton>Okay</guibutton> button to apply changes on the current file.
    </para>
    <figure><title>Rezound Gain Control window</title>
      <graphic fileref="images/rezound-gain.png" format="PNG" />
    </figure>
    <para>
      You can also apply a fade out at the end. Select the region you want to apply a fade out, then click on the main menu to 
      <menuchoice>
        <guimenu>Effects</guimenu>
	<guimenuitem>Curved gain</guimenuitem>
      </menuchoice>. 
      Choose <guibutton>Linear Fade Out</guibutton> or anything else by double-clicking on it and click on the <guibutton>Okay</guibutton> button.
    </para>
     <figure><title>Rezound Curved Gain window</title>
      <graphic fileref="images/rezound-fade-out.png" format="PNG" />
    </figure>
    <para>
      Then save your file. When saving the file, <application>Rezound</application> will popup a dialog that will allow you to change properties of the WAV encoding. With my configuration I must save WAV with a <userinput>signed</userinput> sample format and a width format of <userinput>24</userinput>. If I do not do that, <application>Oggenc</application> OGG encoding will turn in nothing else than a noisy file <footnote><para>However <application>Lame</application> MP3 encoding can be done on WAV in <literal>signed 32</literal> format without any problem.</para></footnote>.
    </para>
    <figure><title>Rezound save window</title>
      <graphic fileref="images/rezound-save.png" format="PNG" />
    </figure>
  </sect1>

  <sect1 id="share-your-work">
    <title>Share your work</title>
    <note>
      <para>
        To know how to build <application>Lame</application>, see <xref linkend="build-lame" />.
      </para>
    </note>
    <para>
      Now that we have our song in WAV format, we will convert it in OGG and MP3 format to share it more easily. 
    </para>
    <para>
      <command>oggenc</command> and <command>lame</command> allow us to specify some extra attributs for our songs, like its title or its genre (see manpages). Usually I only specify title and genre.
    </para>
    <para>
      To obtain a list of genres, pass the <userinput>--genre-list</userinput> argument to Lame. It will output the following:
    </para>
    <example>
      <title>Music genre's list for OGG and MP3 encoding</title>   
      <screen><computeroutput>
123 A Cappella
 34 Acid
 74 Acid Jazz
 73 Acid Punk
 99 Acoustic
 20 Alternative
 40 Alt. Rock
 26 Ambient
145 Anime
 90 Avantgarde
116 Ballad
 41 Bass
135 Beat
 85 Bebob
 96 Big Band
138 Black Metal
 89 Bluegrass
  0 Blues
107 Booty Bass
132 BritPop
 65 Cabaret
 88 Celtic
104 Chamber Music
102 Chanson
 97 Chorus
136 Christian Gangsta Rap
 61 Christian Rap
141 Christian Rock
 32 Classical
  1 Classic Rock
112 Club
128 Club-House
 57 Comedy
140 Contemporary Christian
  2 Country
139 Crossover
 58 Cult
  3 Dance
125 Dance Hall
 50 Darkwave
 22 Death Metal
  4 Disco
 55 Dream
127 Drum &amp; Bass
122 Drum Solo
120 Duet
 98 Easy Listening
 52 Electronic
 48 Ethnic
 54 Eurodance
124 Euro-House
 25 Euro-Techno
 84 Fast-Fusion
 80 Folk
115 Folklore
 81 Folk/Rock
119 Freestyle
  5 Funk
 30 Fusion
 36 Game
 59 Gangsta Rap
126 Goa
 38 Gospel
 49 Gothic
 91 Gothic Rock
  6 Grunge
129 Hardcore
 79 Hard Rock
137 Heavy Metal
  7 Hip-Hop
 35 House
100 Humour
131 Indie
 19 Industrial
 33 Instrumental
 46 Instrumental Pop
 47 Instrumental Rock
  8 Jazz
 29 Jazz+Funk
146 JPop
 63 Jungle
 86 Latin
 71 Lo-Fi
 45 Meditative
142 Merengue
  9 Metal
 77 Musical
 82 National Folk
 64 Native American
133 Negerpunk
 10 New Age
 66 New Wave
 39 Noise
 11 Oldies
103 Opera
 12 Other
 75 Polka
134 Polsk Punk
 13 Pop
 53 Pop-Folk
 62 Pop/Funk
109 Porn Groove
117 Power Ballad
 23 Pranks
108 Primus
 92 Progressive Rock
 67 Psychedelic
 93 Psychedelic Rock
 43 Punk
121 Punk Rock
 15 Rap
 68 Rave
 14 R&amp;B
 16 Reggae
 76 Retro
 87 Revival
118 Rhythmic Soul
 17 Rock
 78 Rock &amp; Roll
143 Salsa
114 Samba
110 Satire
 69 Showtunes
 21 Ska
111 Slow Jam
 95 Slow Rock
105 Sonata
 42 Soul
 37 Sound Clip
 24 Soundtrack
 56 Southern Rock
 44 Space
101 Speech
 83 Swing
 94 Symphonic Rock
106 Symphony
147 Synthpop
113 Tango
 18 Techno
 51 Techno-Industrial
130 Terror
144 Thrash Metal
 60 Top 40
 70 Trailer
 31 Trance
 72 Tribal
 27 Trip-Hop
 28 Vocal
      </computeroutput></screen>
    </example>
    <para>
      A basic OGG encoding could be done with:
    </para>
    <para>
      <screen><userinput>
$ oggenc -a"Emmanuel Saracco" -t"Blackbird" -G"Fusion" -d2005-08-23 blackbird.wav
      </userinput></screen>
    </para>
    <para>
      Where <option>-a</option> is for author name, <option>-t</option> for title, <option>-G</option> for genre, and <option>-d</option> for entire date.
    </para>
    <para>
      A basic MP3 encoding could be done with:
    </para>
    <para>
      <screen><userinput>
$ lame -s 48 --ta "Emmanuel Saracco" --tt "Blackbird" --tg"Fusion" --ty "2005" blackbird.wav blackbird.mp3
      </userinput></screen>
    </para>
    <para>
      Where <option>--ta</option> is for author name, <option>--tt</option> for title, <option>--tg</option> for genre, and <option>--ty</option> for year.
    </para>
    <note>
      <para>
        If you need to convert a old MP3 file to OGG, you can use <command>ecasound</command> like the following:
      </para>
      <para>
        <screen><userinput>
$ ecasound -i blackbird.mp3 -o blackbird.ogg
        </userinput></screen>
      </para>
    </note>
  </sect1>
</chapter>

<appendix id="appendix-usefull-audio-links">
  <title>Useful Audio Links</title>
  <sect1 id="appendix-mailing-lists">
    <title>Mailing-lists</title>
    <para><ulink url="http://music.columbia.edu/mailman/listinfo/linux-audio-user">Linux Audio Users list</ulink></para>
    <para><ulink url="http://lists.sourceforge.net/lists/listinfo/rosegarden-user"><application>Rosegarden</application> users list</ulink></para>
    <para><ulink url="http://lists.ardour.org/listinfo.cgi/ardour-users-ardour.org/"><application>Ardour</application> users list</ulink></para>
    <para><ulink url="http://lists.sourceforge.net/lists/listinfo/hydrogen-users/"><application>Hydrogen</application> users list</ulink></para>
  </sect1>

  <sect1 id="appendix-web-sites">
    <title>Web sites</title>
    <para><ulink url="http://www.dogmazic.net/">Dogmazic.net, Free music</ulink></para>
    <para><ulink url="http://www.grame.fr/Elody/">Elody, a music composition environment</ulink></para>
    <para><ulink url="http://ubuntustudio.com/">Ubuntu Studio</ulink></para>
<!-- <para><ulink url="http://lam.fugal.net/">Music Made with Linux</ulink></para> -->
<!--    <para><ulink url="http://musicians.opensrc.org/">Musicians Opensrc Org</ulink></para> -->
    <para><ulink url="http://www.linuxmao.org/">MAO Libre [fr]</ulink></para>
    <para><ulink url="http://linux-sound.org/">Sound &amp; <acronym>MIDI</acronym> Software For Linux</ulink></para>
    <para><ulink url="http://freesound.iua.upf.edu/">The Freesound Project</ulink></para>
    <para><ulink url="http://www.cadenza.org/glossary/">A multi-lingual dictionary of musical terms</ulink></para>
    <para><ulink url="http://logiciels-libres-cndp.ac-versailles.fr/rubrique.php3?id_rubrique=16">Musique et audio [fr]</ulink></para>
<!-- <para><ulink url="http://www.demudi.org/">The AGNULA home page</ulink></para> -->
    <para><ulink url="http://creativecommons.org/audio/">Creative Commons License for Audio work</ulink></para>
    <para><ulink url="http://www.rosegardenmusic.com/">Rosegarden</ulink></para>
    <para><ulink url="http://jackaudio.org/">Jack Audio Connection Kit</ulink></para>
    <para><ulink url="http://qjackctl.sourceforge.net/">QJackctl</ulink></para>
    <para><ulink url="http://dssi.sourceforge.net/">DSSI</ulink></para>
    <para><ulink url="http://www.ladspa.org/">LADSPA</ulink></para>
    <para><ulink url="http://plugin.org.uk/">Steve Harris's plugins</ulink></para>
    <para><ulink url="http://tap-plugins.sourceforge.net/">Tom's Audio Processing plugins</ulink></para>
    <para><ulink url="http://www.hydrogen-music.org/">Hydrogen</ulink></para>
    <para><ulink url="http://qsynth.sourceforge.net/qsynth-index.html">QSynth</ulink></para>
    <para><ulink url="http://zynaddsubfx.sourceforge.net/">ZynAddSubFX</ulink></para>
    <para><ulink url="http://ardour.org/">Ardour</ulink></para>
    <para><ulink url="http://plugin.org.uk/timemachine/">Jack Timemachine</ulink></para>
    <para><ulink url="http://rezound.sourceforge.net/">Rezound</ulink></para>
    <para><ulink url="http://audacity.sourceforge.net/">Audacity</ulink></para>
    <para><ulink url="http://easytag.sourceforge.net/">EasyTAG</ulink></para>
    <para><ulink url="http://gentoo-wiki.com/HOWTO_Create_an_Audio_CD">How to create a Audio CD</ulink></para>
  </sect1>

  <sect1 id="appendix-soundfonts">
    <title>Soundfonts</title>
    <para><ulink url="ftp://ftp.personalcopy.net/pub/PC51f.sf2.gz">PC51f soundfont</ulink></para>
    <para><ulink url="ftp://sf2midi.com/sgm128/SGM180v1.5.zip">SGM180 soundfont</ulink></para>
    <para><ulink url="http://freepats.opensrc.org/">The Freepats project</ulink></para>
    <para><ulink url="http://www.sf2midi.com/index.php?searchword=&amp;filetype=sf2&amp;typesearch=files&amp;page=search">sf2 MIDI</ulink></para>
    <para><ulink url="http://www.hammersound.net/">Hammersound</ulink></para>
    <para><ulink url="http://www.homemusician.net/soundfonts.php">HomeMusician</ulink></para>
    <para><ulink url="http://www.soundfonts.it/?a=soundfonts">SoundFonts.it</ulink></para>
  </sect1>

  <sect1 id="appendix-soundeffects">
    <title>Sound effects</title>
    <para><ulink url="http://www.sound-fishing.net/bruitages.htm">Sound-fishing (bruitages gratuits) [fr]</ulink></para>
  </sect1>

</appendix>

<appendix id="my-compositions">
  <title>My work</title>
  <para>
    This is the <emphasis>real</emphasis> thing, the one that made you working hard to set up you GNU/Linux box: Creating Music.
  </para>
  <para>
    My own audio work is available <ulink url="http://www.esaracco.fr/musique/">on my Website</ulink>, <ulink url="http://www.dogmazic.net/Emmanuel_Saracco">Dogmazic</ulink>, <ulink url="http://www.lastfm.fr/music/Emmanuel+Saracco">Last.fm</ulink> or <ulink url="http://www.jamendo.com/artist/Emmanuel_Saracco">Jamendo</ulink>.
  </para>
  <note>
    <para>
      Most of this material is intended to be executed by <emphasis>real</emphasis> instruments, so <acronym>MIDI</acronym> should sound a bit strange. In this case, better listening with headphones...
    </para>
  </note>
</appendix>

<colophon id="colophon">
  <para>
    This book is written in <ulink url="http://www.docbook.org/">DocBook</ulink> XML on <ulink url="http://www.gnu.org/">GNU</ulink>/<ulink url="http://www.kernel.org/">Linux</ulink> <ulink url="http://www.debian.org/">Debian</ulink> <emphasis>sid</emphasis> (amd64) system.
  </para>
  <para>
    Outputs were produced with <command>db2html</command> and <command>db2pdf</command>.
  </para>
  <para>
  Stylesheet for HTML output have been stolen and adapted from <ulink url="http://www.karakas-online.de/myLinuxTips/css-for-docbook.html">here</ulink>.
  </para>
</colophon>

</book>
