Slackware Packages for Music Production and Audio Processing
============================================================

Introduction
------------

This is my repository of Slackware packages for music production and
audio processing. This packages are tested against Slackware-current.

This repository is basically an extension to the collection of music
production packages created by Eric Hameleers (aka Alien BOB), and
some of his packages are required to install and run mine.

Please have a look here for an introduction:
https://alien.slackbook.org/blog/explorations-into-the-world-of-electronic-music-production/

At the present time here you will find the Non-DAW collection (a
pattern based MIDI sequencer, a timeline for recording and
synchronizing audio tracks, a session manager and a mixer) and some
accompanying tools needed for Ambisonics mixing.

The Non-DAW collection is a feature-full Digital Audio Workstation
system with a modular, unix-like design. I believe it should fit
perfectly on a Slackware system.

The Non-Mixer is, in my opinion, the gem of this collection: it is an
amazing piece of software that makes Ambisonics mixing extremely easy
and intuitive thanks to a powerful Spazializer module. Using the
Ambisonics sound format in combination with a convolution reverb makes
it possible to achieve quite astonishing results, at least for a
newcomer like me. Moreover, the Ambisonics sound format can be decoded
into many different formats, suitable for many different speaker
configurations (Quad, 5.1, 7.1, etc.)

In order to appreciate what you can achieve with this mixing technique
you can watch this non-mixer spazializer demo:

  http://youtu.be/GVm5Jd1WDWw

The music starts at minute 3.

In this repository you will find the minimum requirement for getting
started with this technology. Below you will also find a brief quick
start guide for using some of the applications you can download here.

The Repository
--------------

This repository should work with slackpkg+ and, possibily, slap-get (I
used Alien BOB's gen_repos_files.sh to generate it). In each package
directory there is a "build" directory where the source code and the
build scripts can be found.

Real-time Scheduling
--------------------

My daughters and I use our laptops to play a virtual instrument with a
MIDI keyboard (we use LinuxSampler and the Salamander Grand Piano).
That requires a low latency system, which requires every JACK client
to be able to set the real time priority assigned to it by JACK. To
achieve this goal I need to either use set_rlimits or setcap. In this
repository I use setcap to set real time capabilites of the binaries
of JACK clients. If you do not like it you can rebuild the packages,
editing the SlackBuild scripts accordingly, or use "setcap -r
/path/to/progname" to remove these capabilities.


A Quick Start Guide to Ambisonics Mixing
----------------------------------------

This is from Wikipedia:

  "Ambisonics is a full-sphere surround sound format: in addition to
  the horizontal plane, it covers sound sources above and below the
  listener."

  "Unlike other multichannel surround formats, its transmission
  channels do not carry speaker signals. Instead, they contain a
  speaker-independent representation of a sound field called B-format,
  which is then decoded to the listener's speaker setup."

  https://en.wikipedia.org/wiki/Ambisonics

And this is how Wikipedia describes convolution reverb:

  In audio signal processing, convolution reverb is a process used for
  digitally simulating the reverberation of a physical or virtual
  space through the use of software profiles; a piece of software (or
  algorithm) that creates a simulation of an audio environment. It is
  based on the mathematical convolution operation, and uses a
  pre-recorded audio sample of the impulse response of the space being
  modeled. To apply the reverberation effect, the impulse-response
  recording is first stored in a digital signal-processing system.
  This is then convolved with the incoming audio signal to be
  processed. The process of convolution multiplies each sample of the
  audio to be processed (reverberated) with the samples in the impulse
  response file.

  https://en.wikipedia.org/wiki/Convolution_reverb

I'm far from being an expert in this kind of stuff, so I'm not going
into any technical detail. In this guide I will just show you how to
pan a stereo signal into a B-format Ambisonics signal, route it to a
convolution reverb and mix the final result. First we will decode the
Ambisonic result into a format suitable for a stereo 2 speaker setup,
and then into a format suitable for a simple 4 speaker setup.

This technique can be used with Ardour through the AMB-plugins. But in
this guide I will use a simpler setup with non-mixer.

I will be using a single stereo sound source, LinuxSampler, which is
receiving MIDI signals generated by the non-sequencer (this is what
you will see in the graphs linked below).

1. Setting up a non-mixer strip for the stereo signal

First we need to setup a non-mixer strip, which is visualized in JACK
as a single client. Please refer to the non-mixer manual for
instructions on creating a project and adding strips to it:

  http://non.tuxfamily.org/mixer/doc/MANUAL.html

The strip must have 2 channels (for stereo input): in the fader view,
below the "Mute" botton, there is the setting for the number of
channels. You can assign a name to the strip (click on "Unnamed" a
enter the name: "Sound source" in my case).

Switch to the signal view and add the Spatializer module (below the
Gain module).

Now the strip should show up in the JACK graph with the name
"Non-Mixer/Sound source", 2 input channels and 9 output channels:
"late reverb/out-1", 4 channels marked as "early reverb/out-[1-4]",
and 4 channels marked "out-[1-4]".

2. Setting up a convolution reverb

The convolution reverb, which is run by the jconvolver engine,
requires a response-impulse signal and an appropriate configuration
file.

The impulse response files we are going to use can be downloaded here:

  http://kokkinizita.linuxaudio.org/linuxaudio/downloads/jconvolver-reverbs.tar.bz2

A set of jconvolver reverb configuration files, specifically tweaked
for the Ambisonics format by the non-mixer author Jonathan Moore
Liles, can be downloaded from here:

  http://non.tuxfamily.org/ambiverb.tar.bz2

In our example I will use the reverb of the Sala dei Concerti, Casa
della Musica, Parma, Italy (as far as I understand Fons Adriaensen,
the author of jconvolver, ambdec, and other amazing pieces of software
related to audio signal processing, used to work -- maybe he's still
working -- for the University of Parma).

The configuration file we are going to use is
"sala-concerti-cdm.conf", and the impulse response files are
"bform-B-tail-ML.wav" and "bform-B-refl-MR.wav".

You need to edit the configuration file to set the path to the impulse
response files. In my case I changed the appropriate line in
sala-concerti-cdm.conf to point to the correct location:

   /cd /home/andrea/Music/non/reverbs/sala-concerti-cdm

where "bform-B-tail-ML.wav" and "bform-B-refl-MR.wav" are located.

Now launch jconvolver with:

  jconvolver -s default -N "sala concerti parma" /path/to/sala-concerti-cdm.conf &

In the JACK graph you will see a new client, named "sala concerti
parma", with 5 input channels (In.Tail, In.W, In.X, In.Y, In.Z) and 4
output channels (Out.W, Out.X, Out.Y, Out.Z).

Keep in mind that the impulse response sample should be recorder with
a frequency that matches the frequency you are running JACK at. In my
case I'm running JACK at 48KHz and the files I'm using match that
configuration. If are running JACK at 44.1 KHz you could check the
r1-nuclear-reactor.conf (coming with the Liles' ambiverb package) and
the accompanying samples at 44.1 KHz, which may be downloaded from
here:

  http://www.openairlib.net/auralizationdb/content/r1-nuclear-reactor-hall

You obviously need to change the configuration file to use those
samples.

3. Setting up a non-mixer strip for controlling the reverb volume

A convolution reverb will produce (only) the reverberations of the
input (Ambisonics) signals. The reverberations will then be mixed
together with the original sound. To control the volume of the
reverberations to be added to the original sound we will use another
non-mixer strip (let's call it "Reverber") with 4 input and output
channels. So we need to create it.

4. Setting up an Ambisonics decoder/encoder

In our example we will first output our processed signal to a simple
stereo setup, suitable for my/your headphones.

To do so we will encode the Ambisonics B-format signals into the
Ambisonics UHJ format, ready for a normal stereo output. For some info
about UHJ see:

  https://en.wikipedia.org/wiki/Ambisonic_UHJ_format

Jconvolver comes with an appropriate configuration file (in my package
the file is stored in /usr/doc/jconvolver-{$VERSION}/config-files).

So let's launch the needed command:

   jconvolver -s default -N "uhj encoder" /usr/doc/jconvolver-1.0.3/config-files/ambisonic/uhjenc.conf

A new JACK client, named "uhj encoder", will appear in the graph, with
4 input (In.W, In.X, In.Y, In.Z) and 2 output (Out.L and Out.R)
channels.

5. Connecting everything together

We will now use JACK to create all the needed connections:

 a. connect the 2 output channels of LinuxSampler to the 2 input
    channels of my "Sound source" non-mixer strip;

 b. connect the 5 reverb output of the "Sound source" strip to the
    "sala concerti parma" 5 input channels ("late-reverb/out-1 goes to
    "In.Tail");

 c. connect the 4 output channels of the "sala concerti parma" client
    to the 4 input channels of the "Non-Mixer/Reverb" client;

 d. connect the 4 output channels of the "Non-Mixer/Reverb" client to
    the 4 input channels of the "uhj encoder" client;

 e. connect the 2 output channels of the "uhj encoder" client to the
    "system" playback;

 f. finally, connect the 4 output channels of the "Sound source"
    client to the 4 input channels of the "uhj encoder" client (both
    the original sound and the reverberations are mixed together!).

You should now have a connection graph like this:

  http://www.istitutocolli.org/img/2_speaker_connections.png

Now you can use the non-mixer Spazializer module as described in the
video I mentioned above.

Keep in mind that the reverberations added to the original sound will
(sort of) interfere with the perception of the spatial location of the
sound source. Lower the gain of the "Reverb" strip to have a stronger
perception of the spatial location of the sound source.

6. Other possible configurations

In our example we have only one sound source and we are controlling
only the amount of reverberation to be added to the original sound. If
you are mixing many instruments you may want to control the amount of
reverberation generated for each instrument. To do that you can simply
add a 5 channel strip between the "Sound source" strip and the "sala
concerti parma" reverb. As far as I can understand all the instruments
may be connected to the same convolution reverb client: "In fact you
can do this because a convolution reverb is a linear process: reverb
(a) + reverb (b) = reverb (a + b)."[*]

[*] See Fons Adriaensen-2 first replay in this thread:
http://linux-audio.4202.n7.nabble.com/ambisonics-UHJ-encoder-td75856.html

7. Using a 4 speaker setup

I have a behringer UMC204HD audio interface, which gives me 4
independent playback channels I can connect to 4 independent speakers.
With this setup I can fully appreciate the surrounding capabilities of
Ambisonics.

To use 4 speakers we need to make a small adjustment to the previous
configuration: instead of using a UHJ encoder, we will now use ambdec
(an Ambisoninc decoder) configured for a 4 speaker square setup.
Ambdec comes with a set of presets (included in the doc direcotry): we
will use "square.ambdec" for our purpose.

So we launch ambdec:

   ambdec -c /usr/doc/ambdec-0.7.1/presets/square.ambdec

The ambdec GUI will be displayed (you can use it to set the output
volume of the decoder) together with a new JACK client with 16 input
and 4 output channels (Ambisonics can work with up to 16 channels,
indeed). We will use the first 4 input channels to connect the output
of the "Reverb" strip and the output of the 4 "Sound source" strip. We
will then connect the 4 output channels of the ambdec client to the 4
playback channels of "system" (the audio interface used by JACK).

You should now have a connection graph like this:

  http://www.istitutocolli.org/img/4_speaker_connections.png

Notice that in this case I'm routing the "Sound source" output to a
"Non-mixer/pre reverb" 5 channel strip to control the amount of
reverberation to be generated for the source (see above, #6).

Now, playing with the Spazializer module should give you a better idea
of what you can do with this kind of stuff!

8. Other configuration

In this example I used Ambisonics and convolution reverb for mixing
recorded (or played) instruments, but you could use this approce for
other purposes, such as routing a simple stereo signal to a 5.1 or 7.1
system.

Take a look at this graph:

   https://i.stack.imgur.com/1tSCF.png

This is the related non-mixer configuration:

  https://i.stack.imgur.com/A3i5W.png

This guy is routing a simple audacious stereo signal to a 7.1 system!

9. Further readings:

https://non.tuxfamily.org/wiki/Ambisonics
https://non.tuxfamily.org/wiki/AmbisonicsReverb


I hope you found this quick start guide useful. Feedback is really
appreciated.

Andrea Rossato
<andrea.rossato (at) unitn.it>

Last revision: 2020-02-08
