User:Crantila/FSC/Synthesizers/FluidSynth

From FedoraProject

Jump to: navigation, search
Note.png
This Is out of Date
The most recent revisions of the Musicians' Guide are now available from the git repository.

Contents

About FluidSynth

FluidSynth is a software-based MIDI synthesizer. FluidSynth accepts MIDI input from programs like Qtractor and Rosegarden, and uses SoundFont technology to create audio signals. This makes FluidSynth a very flexible tool; it can be used even on low-power computers, doesn't require specialized hardware, and can take advantage of a wide selection of high-quality MIDI instruments. When used with the Qsynth graphical interface, FluidSynth becomes even more powerful: users can easily control basic effects like chorus and reverb, and they can start multiple FluidSynth synthesizers, each with their own settings and MIDI instrument assignments. Finally, because Qsynth was created and is maintained by the same developers as Qtractor and QjackCtl, it provides a familiar interface, and integrates well with these other applications.

SoundFont Technology

SoundFont technology was developed in the early 1990s, and comprises a file format and certain hardware technologies designed to allow the creation of MIDI instruments that sound like acoustic instruments. It would be virtually impossible to make an electronically-synthesized instrument sound identical to an acoustic counterpart, but SoundFont technology enables the gap to narrow considerably. Heard in the right context, most people would not notice that music was recorded by a SoundFont-capable MIDI synthesizer, but results can vary widely.

What FluidSynth enables users to do is eliminate the hardware component of using SoundFonts, so that any computer becomes capable of synthesizing from SoundFont files, which are often simply referred to as "a SoundFont." As fonts change the look of text characters, SoundFonts change the sound of MIDI notes - the overall meaning is the same when conveyed by any font (or SoundFont), but the particular nuance is changed.

Fedora offers a few SoundFonts in the default repositories. By default, FluidSynth installs the FluidR3 General MIDI ("GM") SoundFont, which contains a wide array of conventional (and some non-conventional) "patches." To see the other options that are available, use PackageKit, KPackageKit, or yum to search for "soundfont".

How to Get a SoundFont

There is a large selection of SoundFonts available for free on the internet, and some are also available for purchase, including a few very high quality SoundFonts. The following three websites have links to SoundFont resources, and some SoundFonts available for paid or free download. No guarantee is made of the quality of the material provided, or of the quality and security of the websites.

See the "Optional Installation: SoundFont ..." below for installation instructions.

MIDI Instruments, Banks, Programs, and Patches

A "MIDI instrument" is the synthesizer itself. If the synthesizer uses SoundFonts, then the SoundFont also constitutes part of the instrument. Each instrument can be thought of as a library, which stores books.

Each instrument offers at least one, but possibly several "banks," which store programs. If a MIDI instrument is a library, then a bank is like a particular shelf. You must first select a shelf before choosing a book.

Each bank offers between one and one hundred and twenty seven "programs," (also called "patches") which are the sounds themselves. If a MIDI instrument is a library and a bank is a shelf, then a program is a book. Programs need not necessarily be related, but banks with a large number of programs (like the "General MIDI" bank) usually follow some sort of order. It is the program alone which determines the sound of the synthesized audio; the bank and instrument simply limit the possible choices of program.

MIDI Channels

A MIDI synthesizer will accept input on multiple channels. Although each "instance" of the synthesizer can only have one MIDI instrument assigned to it, each channel can be assigned a program independently. This allows the synthesis of a virtual instrumental ensemble.

The General MIDI ("GM") standard, used partially by the default FluidR3 SoundFont and by FluidSynth itself, further specifies that there will be 16 channels, and that channel 10 will be used for (mostly unpitched) percussion instruments. Any program change message sent to channel 10 will be ignored, and although FluidSynth can be configured to use a non-percussion program on channel 10, this use is discouraged.

For cases where FluidSynth does not adhere to the General MIDI standard, it is adding functionality, rather than removing it.

Requirements and Installation

Software Requirements

FluidSynth requires the JACK Audio Connection Kit. If you have not already installed the JACK packages from the Planet CCRMA at Home repository, then it is recommended that you do so before installing FluidSynth. Follow the instructions here.

Choosing an Installation Method

There are two ways to install FluidSynth. The first, to install FluidSynth with Qsynth, allows FluidSynth to be used with the Qsynth graphical interface. It also installs a default SoundFont, which can be used by any SoundFont-aware application (like timidity++). This installation method does not - by default - allow FluidSynth to be used from a terminal, although this ability can be easily added later. This is the installation method recommended for most users.

The second way to install FluidSynth is without the Qsynth graphical interface. This method allows FluidSynth to be run from a terminal, and does not install a default SoundFont. This installation is recommended only for advanced users.

Installation with Qsynth

This installation method is recommended for most users, and will install everything you need to start using FluidSynth.

  1. Use "PackageKit" or "KPackageKit" to install the "qsynth" package.
  2. Review and approve the proposed installation:
    • If the "jack-audio-connection-kit" package is listed, it is recommended that you follow these instructions to install the JACK Audio Connection Kit before installing Qsynth.
    • The installation may include the "fluid-soundfont-gm" package, which is quite large.

If you wish to use FluidSynth from a terminal, without the Qsynth graphical interface, you can enable this capability by installing the "fluidsynth" package. This package is not needed if you only intend to run FluidSynth with Qsynth, because Qsynth only uses files in the "fluidsynth-libs" package, which is automatically installed with Qsynth. If you are unsure of whether you should install the "fluidsynth" package, you can safely install it, even if you never use it. It only uses a small amount of hard drive space.

Installation without Qsynth

This installation method is recommended only for advanced users. You will have to use FluidSynth from a terminal. You will also have to install a SoundFont file before using FluidSynth.

  1. Use PackageKit or KPackageKit to install the fluidsynth package, or use a terminal to run su -c 'yum install fluidsynth'

Installation of SoundFont Files

Qsynth automatically installs a SoundFont for use with FluidSynth, but if you did not install Qsynth, or if you want to add additional SoundFont files with additional programs, you will need to install them separately. The Fedora package repositories offer a small selection of SoundFont files, which you can find by searching for "soundfont" with PackageKit, KPackageKit, or yum. These files will automatically be installed correctly. If you wish to install additional SoundFont files, it is recommended that you install them in the same location - and with the same security settings - as the ones available from the Fedora repositories. If you do this, then you enable all users of the computer system to access the files, you will not "lose" them if you forget where they are stored, and you help to minimize the potential security risk of using software downloaded from the internet.

The following steps will move a SoundFont file called "myFont.sf2" to the default folder (/usr/share/soundfonts), and correctly set the security settings. Note that you will need the system administrator's password (belonging to the "root" account) to complete this operation. If you do not have this password, it is best to ask the system administrator to install the files for you. Alternately, you may simply use the SoundFont file from your a sub-folder in your home folder.

  1. Start a shell or terminal and navigate to the folder where the SoundFont file is currently stored.
  2. Run su -c 'cp myFont.sf2 /usr/share/soundfonts'
    • Modify the command as necessary to copy your SoundFont file, rather than "myFont.sf2".
    • You will be asked for the "root" password.
  3. Run cd /usr/share/soundfonts to change to the directory of the SoundFont
  4. Run su -c 'chmod 644 myFont.sf2'
    • Modify the command as necessary to refer to your SoundFont file, rather than "myFont.sf2".
    • This will set the file-system permissions to "read-write" for the owner (the "root" user, in this case), and "read-only" for all other users. This way, only the system administrator should be able to change the file, but all users will be able to use it.
  5. Run ll myFont.sf2 to verify that the permissions were set correctly.
    • Modify the command as necessary to refer to your SoundFont file, rather than "myFont.sf2".
    • The output should resemble this: -rw-r--r--. 1 root root 9 2010-06-23 02:28 myFont.sf2, but with a different date, time, and filename.
  6. Highly-observant users may notice that the SELinux context of the new file is different from that of any Fedora-installed SoundFont file. As long as the type is "usr_t", which it should be by default, then there is no practical difference (no difference in enforcement) between this and a Fedora-installed SoundFont file. If you don't know what this means, or if you hadn't noticed it, then it means that this additional SoundFont file should not create a new potential security problem.

Using FluidSynth in a Terminal

This is not the recommended way to use FluidSynth, because the Qsynth graphical interface is much easier to use. Qsynth automatically configures most of FluidSynth's settings by default, allowing you to avoid focus on how you want to use FluidSynth, rather than on how to use FluidSynth.

If you want to use FluidSynth in a terminal, you can use the fluidsynth command. The default sample-rate is 44.1 kHz, so if you want to use JACK at a different sample rate, you need to use the -r flag, like this: fluidsynth -r 48000

When you start FluidSynth from a terminal, it will normally start a shell of its own. How to use this shell is beyond the scope of the Musicians' Guide, but you can get basic help by running the "help" command from the FluidSynth command line.

Configuring Qsynth

When you quit Qsynth, all settings are preserved, and re-used when Qsynth is re-started. This includes settings for additional instances of Qsynth (described below), which are also re-created when Qsynth is re-started.

Starting FluidSynth

  1. Start Qsynth from the Applications menu, or the K Menu
  2. The FluidSynth engine will be started automatically.
  3. The row of buttons at the right of the Qsynth window control Qsynth. The other settings control FluidSynth.
  4. You can use the "Messages" button to display a window containing FluidSynth's output. If FluidSynth doesn't work as expected, you can use this window to view any error message that might have been produced.

SoundFont Configuration

The default "FluidR3" SoundFont, installed with Qsynth, is automatically configured.

To configure an additional Soundfount:

  1. Click the 'Open' button, and navigate to the path of the SoundFont you wish to add. This should be /usr/share/soundfonts, if installed to the standard location specified !!above.!!
  2. Select the additional SoundFont, then click the 'Open' button.
  3. To change the SoundFont ID (SFID), use the 'Up' and 'Down' buttons to change the position of the SoundFonts, as desired. This does not directly change the function of FluidSynth - any SoundFont should work with any SoundFont ID number.

JACK Output Configuration

It is possible to configure FluidSynth to output synthesized audio either to JACK or to ALSA. The default, and recommended, method is to output synthesized audio to JACK. This allows the greatest control over audio quality, and the greatest flexibility in terms of routing and multiplexing (see definition here), which allows you to simultaneously record the synthesized audio signal and listen to it.

If you are having problems, you may wish to confirm that Qsynth is configured correctly to use JACK.

  1. Open Qsynth's "Setup" window.
  2. Select the 'Audio' tab, and ensure that "Audio Driver" is set to "jack".
  3. You should also ensure that the other settings are correct - especially that the "sample rate" is set to the same sample rate as JACK (through QjackCtl).
  4. The default settings for most things should work. If you changed a default setting, they are these:
    • Buffer Size: 1024
    • Buffer Count: 2
    • Audio Channels: 1
    • Audio Groups: 1
    • Polyphony: 256

If you are having problems with audio cut-outs, you may wish to increase the buffer settings. The size should be increased in multiples of 1024, and the buffer count should not be increased much. The default setting or one "Audio Channel" provides stereo output, and each additional channel produces another set of stereo outputs. Increasing the "polyphony" setting will allow a higher number of simultaneous notes ("MIDI events," really), which will be useful in exteremely complex situations.

MIDI Input Configuration

FluidSynth will only produce sound as instructed by a connected (software- or hardware-based) MIDI device. If you are having problems configuring FluidSynth to accept MIDI input, verify the following options.

  1. Open Qsynth's "Setup" window.
  2. The "Enable MIDI Input" setting must be enabled.
  3. There are two settings for "MIDI Driver" that you would likely want.
    • When set to "alsa_seq", the input will appear on QjackCtl's "ALSA" tab in the "Connect" window. This is useful if the MIDI generator device that you are using, such as a MIDI-enabled keyboard, is connected directly to ALSA.
    • When set to "jack", the input will appear on QjackCtl's "MIDI" tab in the "Connect" window. This is useful if the MIDI generator device that you are using, such as Rosegarden, is connected directly to JACK.
  4. You can set the number of MIDI input channels provided by FluidSynth. Refer to the information below, in !!"Changing the Number of MIDI Input Channels"!!

Viewing all FluidSynth Settings

  1. Open the "Setup" window
  2. Select the "Settings" tab
  3. Scroll through the list to the setting you wish to see.
  4. The settings in this tab are not editable in this tab.

Assigning Programs to Channels with Qsynth

The best way to do this is through your MIDI sequencer, like Qtractor or Rosegarden. If you are using an application which doesn't allow you to send program-change messages, or if you need to configure programs for another reason, you can follow these instructions.

  1. In the main Qsynth window, click "Channels" to open the "Channels" window.
  2. In the Channels window, each channel will, by default, look like 1 - - -
  3. To assign a program to a channel, click on the row of the channel that you want to assign.
  4. Select the bank and program number that you want, using the name, SFID, and Soundfont columns to guide you.
  5. Repeat this process for all of the channels that you wish to assign.
  6. If you are not going to use a channel, there is no harm in assigning it a program anyway. However, assigning a program to a channel that you will not use can lead to confusion, especially if you later forget that you intended to not use that channel.
  7. Remember that channel 10 is reserved for percussion instruments, and should not be changed from a General MIDI percussion program.

Changing the Number of MIDI Input Channels

You can increase the number of MIDI input channels offered by FluidSynth. Although QSynth will let you set any number between 1 and 256, channels will be added and removed only in sets of 16. Qsynth will automatically create the lowest number of channels that will allow as many channels as you need. Each set of 16 channels will be indicated in JACK with an additional MIDI input device. The name of the device indicates which channels are listening: channels 1 through 16 listen to the device ending in 0; channels 17 through 32 listen to the device ending in 1; channels 33 through 58 listen to the device ending in 2; and so on.

To change the number of MIDI input channels, follow these instructions.

  1. Open Qsynth's "Setup" window.
  2. The "Enable MIDI Input" setting must be enabled.
  3. Input the number of channels that you wish to use, between 1 and 256.

Saving and Reusing Channel Assignments

QSynth allows you to save multiple sets of program assignments, which you can restore later. This means that you will not have to re-configure all of the channels every time you want to change them.

To save the settings for later:

  1. Ensure that Qsynth is correctly configured, and working with the program assignments as desired.
  2. In Qsynth's "Channels" window, erase the contents of the "Preset Name" text field, and replace it with whatever name you would like.
  3. Click "Save" to preserve the settings under that name.

To restore settings from earlier:

  1. Open Qsynth's "Channels" window.
  2. Search through the "Preset Name" drop-down box to find the name of the preset that you wish to restore.
  3. Select it, and verify that the correct channel assignments were restored.

Using Reverb and Chorus with Qsynth

While "reverb" (meaning "reverberation") and "chorus" effects are not part of the General MIDI standard, they are offered by most MIDI synthesizers. FluidSynth is no exception, and the Qsynth interface provides a convenient and easy way to adjust settings of the reverb and chorus effect-generators. Experimentation is the only way to know whether you have chosen the right settings, and they will probably change depending on the music you are working on, and even during a piece. Most MIDI sequencers and players (including Qtractor and Rosegarden) allow you to send MIDI messages changing the reverb and chorus settings while a session is playing.

The reverb and chorus effects can be turned off temporarily if you do not plan to use them. To do this in Qsynth, uncheck the "Active" check-box underneath the respective effect generator's settings dials.

The reverb effect generator creates artificial reverberation (like an "echo," but more complex), which occurs naturally in almost all performing environments. The effect generator works by creating a virtual room, and pretending that the user is listening within it. These are the settings offered by Qsynth:

  • Room: Adjusts the size of the virtual room. Settings higher than 100 can cause a situation that escalates in volume to dangerously high levels, even with the lowest possible "level" settings. This is an interesting effect, but caution is advised so that listener do not incur accidental hearing damage. Remember also that the reverb effect can accumulate as time goes on, so it may even take many minutes for the volume level to build to a dangerously high level, depending on the settings.
  • Damp: Adjusts the amount of "sound damping" in the virtual room, affecting not only the time it takes for the sound to die, but the frequencies which are most affected. The greater the damping, the shorter the higher frequencies last.
  • Width: Adjusts the perceived "width" of the stereo image of the virtual room, and also has a large effect on the volume level.
  • Level: Adjusts the volume level of the reverberation.

All of the settings interact in ways that make it difficult to describe any sort of recommended settings. Users are strongly encouraged to experiment with the various settings to find ones that suit their needs. A wide variety of listening environments can be simulated, and the settings required do not always reflect the most logical choice - it is possible to emulate a concert hall with a relatively small "room" setting, for example. Effective use of the reverb effect can greatly enhance the MIDI listening experience.

The chorus effect generator creates the impression that more than one real-world instrument is playing each MIDI line. The effect generator works by slightly responding to each MIDI note several times, with slightly inaccuracies in pitch and time in each response. Although it may seem overly negative to say so, humans intuitively recognize that this inaccuracy is part of real-world, acoustic music, so the chorus effect helps to add a realistic sound to some performances. These are the settings offered by Qsynth:

  • N: Adjusts the number of effect "stages," which allows you to control the approximate number of discrete instruments perceived.
  • Level: Adjusts the volume level of the effect. (??!!)
  • Speed: Adjusts the speed of the chorus, and so the range of time over which the notes are spread. (??!!)
  • Depth: Adjusts the perceived "depth" of the stereo image. (??!!)

Multiple FluidSynth Instances with Qsynth

Rarely will you need more than one instance of FluidSynth, because QSynth/FluidSynth together offer up to 256 independent input channels, and the ability to control the reverb and chorus effects independently by channel. The most common use of multiple FluidSynth instances is if you want to use multiple MIDI instruments. In other words, if you want to use multiple SoundFonts at the same time, you will need to use one instance of FluidSynth for each SoundFont.

Thankfully, Qsynth allows us to do this almost effortlessly! Each "instance" of FluidSynth is created and controlled by, in effect, running the FluidSynth synthesis application multiple times. The reality is that, since Qsynth controls the FluidSynth engine directly, it simply starts the synthesis engine directly, creating multiple instance of that engine. This is much more efficient than actually running Qsynth multiple time, or even than running FluidSynth directly from a terminal. Each such instance is represented in Qsynth by a "tab," displayed at the bottom of the Qsynth window.

To create an additional instance of FluidSynth:

  1. Press the green "+" button in the bottom-left corner of Qsynth's main window
  2. Adjust the settings as desired, by using the Setup window that pops up.
  3. Press "OK" to start the additional instance.
  4. To close an additional instance, use the red "X" near the lower-right corner.

Each instance of the FluidSynth engine has its own settings in the "Setup" window. Qsynth supports a theoretically unlimited number of FluidSynth instances, but your computer's memory will probably not allow many more than ten, depending on the SoundFonts used.