# Get a band in a box with Linux Sampler Synthesizers have been attempting to emulate real world musical instruments for decades. Famous synthesist Wendy Carlos worked hard to understand (and document, in her **Secrets of Synthesis** album) how synthesizers could capture the intent of music initially written for physical instruments. Musicians came to understand, though, that if you wanted to capture the exact sound and feel of an instrument, you had to record it, and the Mellotron famously pioneered this idea with tape loops connected to a keyboard. When synthesizer technology transitioned from analogue to digital, sampling became a standard practice. Sampling, in the context of musical synthesis, is the process of recording a real instrument, and then using that recording to make new music. It's an important idea in music because few people have access to every instrument they happen to want to compose music for. And if you want to write a score featuring a full symphonic orchestra for a video game, it's likely out of your budget to hire an orchestra, a studio, and engineers. With open source, however, you can certainly afford to hook your MIDI keyboard up to [Linux Sampler](http://linuxsampler.org/). ## Install Linux Sampler is a specialized multimedia tool aimed at musicians, so not all distributions package it in their repositories. On Fedora, CentOS, Mageia, and similar, you can add On Linux, your distribution may have Linux Sampler available from its package manager. If you can't find Linux Sampler in your repository and you're using an RPM-based distribution such as Fedora, CentOS, or Mageia, you can use the builds found at the klaatu/linuxsampler COPR repository: ```bash $ sudo dnf copr enable klaatu/linuxsampler $ sudo dnf install linuxsampler ``` On Debian and similar, download the DEB installer from [linuxsampler.org](https://download.linuxsampler.org/packages/debian/) and install: ```bash $ sudo dpkg -i linuxsampler*deb ``` For macOS and Windows, download installers from [linuxsampler.org](https://download.linuxsampler.org/packages/debian/) and launch the installer. Linux Sampler is actually just the *engine* to play sample files. You also need a front-end application so you can interact with it. There are two user interfaces provided on the Linux Sampler website: Qsampler and Fantasia. Fantasia is a Java desktop application, so it works regardless of your operating system. You can [download the Fantasia](http://downloads.sourceforge.net/jsampler/Fantasia-0.9.jar) from the Linux Sampler website. ## Getting samples Linux Sampler plays three different kinds of sample files: * `.gig` (also known as Gigastudio or Gigasample files). * `.sf2` (also known as Soundfont) * `.sfz` (an open standard with no relation to the `.sf2` Soundfont format) There are several sources for free and open source sound banks in all of these formats, including the [http://virtualplaying.com/virtual-playing-orchestra/](Virtual Playing Orchestra) project, the [Versil Studio](https://vis.versilstudios.com/vsco-community.html) collection, [Flame Studios](https://www.flamestudios.org/free/GigaSamples) guitar samples, and many more. You can also purchase bundles of Gigasamples from a number of sample bank companies. As long as you have Linux Sampler, you have a way to play Gigasamples, Soundfonts, and SFZ files. ## Making music with Linux Sampler The Fantasia interface for Linux Sampler has a three-column configuration. ![Linux Sampler (Fantasia) layout](linuxsampler-ui.jpg) On the right is the main configuration panel. This is where you select audio and MIDI devices. In the middle is the rack. This is where you add virtual synths, each with a unique sample bank loaded. On the left is the Orchestra and Instrument panel. This is largely an optional panel where you can build a collection of instruments you use often, for quick access. ## Audio configuration To set your audio output, click the **Power** button on the left of the **Audio Devices** entry in the right column. For Linux, you can use ALSA or JACK. The JACK system allows you to route sound from different applications as if they were all coming from the same application. JACK is a powerful system, but it does take time to learn. If you want to use ALSA instead, you must suspend Pulse Audio so Linux Sampler can lay claim to your audio output device. To set Linux Sampler to use ALSA: ```bash $ cat << EOF >> fantasia.sh > #!/bin/sh > java -jar $HOME/Downloads/Fantasia-0.9.jar > EOF $ chmod +x ./fastasia.sh ``` Each time you launch Fantasia, use this command: ```bash $ pasuspender ./fastasia.sh ``` ## MIDI configuration Linux Sampler responds to MIDI signals. To create a new MIDI device, click the **Power** button on the left of the **MIDI Devices** entry in the right column. On Linux, you can use ALSA or JACK to manage MIDI. Personally, I use ALSA for MIDI even when I'm using JACK. ## Adding instruments To play your samples, you need a synthesizer (a **sampler channel**, in Fantasia's terminology) in your rack with a sample bank loaded. To add a sampler channel, click the **Power** button on the left of the **MIDI Devices** entry in the middle column. Linux Sampler defaults to GIG, but you can click the **GIG** button on the rack unit to choose a different format. Click the **Load instrument** button to choose the file you want to load. ## Playing sound To play your samples, you can use the virtual keyboard at the bottom of the window. Click on an instrument in the middle column to make it active, and then click on the keyboard at the bottom of the window. Alternately, if you're using a USB MIDI keyboard, you can use it to trigger sounds. ## Advanced MIDI setup The virtual piano keyboard at the bottom of the screen uses MIDI channel 1 by default, and that's what all of your instruments in the middle rack are set to when you create them. If you want to trigger sounds over a specific MIDI channel, either because you're using a MIDI keyboard that sends signals over that channel, or because you're triggering sounds from a separate application, then you can change the MIDI channel of each instrument. To see an instrument's MIDI settings, click the **Options** button on the right of the rack unit. In the drop-down panel that appears, you can set you MIDI input, port, channel, and more. ![Advanced MIDI settings](linuxsampler-midi.jpg) ## Open source orchestration When it comes to movies and video games, I love a good cinematic score, with a full orchestra, swelling crescendos, and plucky arpeggios. I also really enjoy old music, and it's amazing how many MIDI files are out there that provide a sort of "digital sheet music" for old classics. I don't have access to a full chamber orchestra myself, but I do have access to a lot of great open source technology and open culture work that, when combined, allows me to compose and play a digital orchestra. Linux Sampler doesn't have a sequencer built into it. It's just a player. Combine it with a digital audio workstation such as [Ardour](https://opensource.com/article/21/12/making-music-ardour-advent-2021-18), [Qtractor](https://opensource.com/article/17/6/qtractor-audio), or [Rosegarden](https://opensource.com/article/18/3/make-sweet-music-digital-audio-workstation-rosegarden) to create your own scores, songs, or just use it as a sound source for MIDI files. If you close your eyes, you might just convince yourself you're being serenaded by a real live band.