Audio production Part 2 - Synthesis

From LXF Wiki

Table of contents

Audio and Music Production - part 2

(Original version written by Graham Morrison for Linux Format magazine issue 64.)


Modular synthesis is a great way of getting into audio design. We start plugging in the cables...


In the last tutorial we started this series of tutorials with an overview of Jack and how several music applications interact with it. We plugged two sound generation devices into the Jack server, and covered some of the details you need to consider when putting an audio system together. This month we're going to cover some more sound generation, using another synthesizer called the Alsa Modular Synth (AMS) and attempt to record the output into an audio sequencer called Rosegarden.

The synth we used in the last tutorial, ZynAddSubFX, is a complicated piece of software, especially for users with little prior exposure to synthesis. It features several different methods of synthesis and an awful lot of parameters. Despite all of this, when you get used to it, it is still relatively easy to use as all the complicated parameters are hidden from view unless you feel the need to get into the details. AMS is one of the other more significant synths for Linux and is the brainchild of Matthias Nagorni, and features with a completely different approach to sound synthesis.

One of the best ways to cover the basics of synthesis is to create a simple sound from scratch. There are many ways of achieving this, you could use ZynAddSubFX for example, but perhaps the best way is to use a modular synthesizer. Modular synths represent the earliest stages of synthesizer design, they were often situated in their own room and featured teak enclosures and a thousand different cables stretched from one side to another. Basically, a modular synthesizer is so called because it's made of many discrete and totally separate modules. There are usually only two kinds of connections that tie the whole thing together, one is obviously for audio, and the other is for what is called a control voltage, which is the precursor to MIDI, and is usually a voltage signal output from one device to control another.


Modular Synthesis

AMS is a software version of one of those old systems and it's a good way of learning the basics of synth design. As you need to add and wire each module separately, you immediately get a sense of what's changing to the sound. When you first start AMS (you need to specify -jack on the command line for Jack integration) you're presented with a blank canvas in a terrible shade of brown. The first thing you need to do (after changing the background colour that is) is add an MCV module. Modules are added by selecting the Module menu item, followed by New and the module you require. The MCV module converts MIDI input into the required virtual control voltage (CV) for controlling the other modules.

Unlike ZynAddSubFX, AMS doesn't have its own embedded keyboard for playing sounds with, so the next step is to get some note information into AMS to be able to play it. In the absence of an external MIDI keyboard, there's a virtual keyboard for Linux called 'vkeybd' that plugs into ALSA by providing its own MIDI outputs. Whether it's with an external keyboard or vkeybd, the MIDI data needs to be routed to AMS and the easiest way to accomplish this is with qjackctl's Connect window. The MIDI tab in this window works in exactly the same way as the audio one we used last month, and when selected should present you with a list of readable clients on the left (equivalent to MIDI Out ports) and writeable clients on the right (equivalent to MIDI In). For fear of stating the obvious, the vkeybd can be connected to AMS by selecting Virtual Keyboard's output port and AMS's input port and clicking 'Connect'.

Now that the MIDI input is catered for, we can go back to generating our synthesizer. To generate a sound, the next module needs to be the VCO (Module>New>VCO). This is connected to the MCV via the frequency control voltage which has been converted from the MIDI note value arriving at the MCV. To make connections in AMS, click on the small box to the right of 'Freq' in the MCV box, hopefully highlighting it in red, then click on the small box to the left of 'Freq' on the VCO. This should create a cable that illustrates the connection. Outputs are always on the right of a module, while inputs are on the left.


Synthesizer Modules

The logic-circuits of synthesis

The Voltage Controlled Oscillator (VCO) is always one of the more important parts of any synthesizer, being the main component responsible for introducing sound to the audio signal path. This rather cryptically named component refers to the fact that a repeating voltage waveform can be oscillated using control voltages and if the frequency of this oscillation is within the audible range, sound is generated. Changing the control voltage changes the pitch. Strictly speaking, with digital synthesis, this component has become the DCO, but usage of VCO is commonly used to denote an attempt to re-create some of the analogue imperfections of the older machines.

The Voltage Controlled Filter (VCF) is responsible for adding more interest to a sound's timbre by filtering out some frequencies while leaving the other frequencies to pass through unhindered. Actually, that isn't exactly true, the filter output is the complex result of a phase cancellation and harmonic interaction, but it does have the effect of taking broad swathes of a frequency-range out of the audio signal. The design of the filter module (and in the digital age, its corresponding algorithm) is often judged as the linchpin of a synthesiser's character. The distinctive sound of some of the more famous classics, such as a Minimoog or the squelchy Roland TB-303, comes primarily from the filter action. While there are almost as many ways to filter a signal as there are synthesizers, there are three configurations that are nearly universal. These are low-pass (LPF), band-pass (BPF) and high-pass (HPF). As their names suggest, they let either the low, middle or high frequencies through, with the cut off threshold (frequency) usually being under the user's control. There's one other parameter that has a great deal of influence on a filter's sound, and that is usually called resonance (but depending on manufacturer, can be have strange names like 'emphasis', 'brightness' or even just 'Q'). Resonance simply boosts the frequencies at the cut off point and is responsible for the nasal quality that can sometimes scream at high levels. It's best heard when the filter is swept up through the frequency range.

A Contour Generator can output a control signal that varies over time according to a pre-defined envelope. The two typical destinations for the control signal output from a contour generator are either the Voltage Controlled Amplifier (VCA) for controlling the audio volume, or the VCF for frequency changes over time. With some synthesizers, the envelope can be as simple as three or even two stages, but the majority use four, known as an ADSR envelope. The 'A' is for Attack, the initial ramp in volume from silence. Usually, this would be extremely fast for a percussive instrument and much slower with something like an accordion. The Decay (D) that follows usually drops the sound down to the Sustain (S) level of the instrument after which the Release (R) is the time it takes for the sound to fade-away after being played.

The Low Frequency Oscillator is another implementation of a VCO, but rather than oscillating at an audible frequency (typically 20Hz-20kHz), it can be set to oscillate at a much lower rate. This is particularly useful for modulating other signals, adding some dynamic changes to a signal. Using an LFO to modulate an audio signal adds vibrato, whereas modulating a VCO's frequency (changing it's pitch) would introduce tremolo. Other useful effects can be achieved from modulating the VCF.


At this stage, it is perfectly possible to generate a sound, though it wouldn't be terribly useful. To do this, we need to add another module that represents the physical output and this is called PCM Out (Module->New->PCM Out). Make sure your output volume is turned all the way down, then to hear a sound, firstly connect one of the waveform outputs from the VCO, such as Saw, to the outputs on the PCM module. This should produce a burst of audio activity in the form of a droning, uniform tone. Because the MCV frequency is connected to the VCO's, the only control that is possible is that of changing the pitch from either vkeybd or an external MIDI device. As this isn't much use, you can stop the sound by right-clicking on the PCM Out and selecting 'Disconnect'.


Taming the contour

The next stage is to build some control into the sound, making it more useable, and the main way to accomplish this is through applying a volume envelope to the sound signal. This is achieved in two stages, the first of which is generating an envelope for the sound volume, followed by sending the volume control signal to a VCA to attenuate the audio. In AMS, we need to add both an ENV module (Module>New>ENV) and a VCA (Module>New>VCA lin). To wire this into our current setup, the Gate output from the MCV needs to be connected to the Gate input of the ENV modules. This basically starts an envelope when a MIDI key is pressed (the equivalent of opening a gate in control voltage terms). Then the ENV Out is connected to the Gain 0 Input on the Lin VCA Module, which provides the module with the control signal for changing the volume. The final step is to take the audio signal from the VCO, connecting the Saw output to the In 0 on the VCA, and connecting the VCA Out to the PCM In.

The first difference is that unless anything is pressed on the keyboard, no sound is generated. Pressing a key triggers the envelope and contours the audio volume appropriately. To change the envelope's characteristics, or any other module's parameter for that matter, just right-hand click on the module and the user is be presented with a separate window with all the editable parameters. With the ENV module you can experiment with the effects of lengthening the attack or reducing the release, to get a feel for how it all works.

While the synth sound produced with this configuration is certainly starting to resemble something you may expect from a piece of hardware, it is still rather bland. What's needed is a filter to tame the Saw-tooth waveform a little and impart a little character into the sound. For this, add a VCF module and wire it in-between the VCO and the VCA. This can be done easily by first disconnecting the Saw to In 0 wire, and taking the Saw output to the VCF's In, followed by the VCF's Out to In 0 on the VCA. The sound is now more nasal and less defined because the filter is taking out most of the high-frequency information from the audio signal. Right-click on the VCF module and change both the frequency and resonance sliders for maximum timbre-changing mayhem.

The last stage for this very basic synthesizer is to add a little modulation to change the sound, making a sustained note a little more interesting. An LFO is the most common way of doing this and can be done by simply adding the LFO module and connecting its Sinusoidal oscillator output to the Freq control input on the VCF, and the Gate on the MCV module to the Reset input on the LFO. This should now have a moderately rapid modulated filter cut off frequency and the oscillation rate can been changed from the LFO's parameter display.

Instead of always opening a module's parameter view, AMS also has the ability to take certain important parameters, such as a filter's cut off frequency, and add them to a separate window. This is the software synth's equivalent to the hardware front panel, and can be configured with the AMS control centre (View>Control Center) by selecting the module's parameter from the right and choosing 'Add to Parameter View'. This is also a good opportunity to assign the parameter to an external MIDI controller. This 'hardware' panel can then be accessed from the same view menu.

This is only the beginning in terms of synth design with AMS. For a start, it's relatively easy to add greater modulation possibilities and more envelopes. Relatively few synthesizers feature a single oscillator, so the next step should be to add several more, as can be seen with the demo synths included within the AMS package. Also, this is the simplest of synths, using the simplest of synthesis techniques, namely subtractive synthesis. For real complexity, there's always additive, FM (Frequency Modulation) or even physical modelling.

The next stage after sound generation is sequencing and recording. While there are several heavy-weight packages available for Linux, including Muse and Ardour, one of the smartest is Rosegarden, especially for the user with some familiarity with similar packages for other platforms. Plugged into the ALSA/Jack system, Rosegarden can not only handle the audio aspect of composition, including effects and routing, but also the MIDI sequencing that's required to send the notes to the various synthesizers.

When first started, Rosegarden presents an imposing initial window absolutely filled with a combination of 64 audio and MIDI tracks. Most projects, especially early on, would never need this many but deleting them can cause problems. Rosegarden adds all of its internal audio channels to Jack and this can be seen in the connection window of qjackctl. Looking at qjackctl's MIDI tab, Rosegarden's MIDI capabilities are conspicuous by the absence of any MIDI channels. This is because, for MIDI functionality, the application uses its own routing table rather than the more usual ALSA connections.


Sums and roses

There are two channel types in Rosegarden, audio and MIDI. They don't have any particular distinction apart from the internal object channel that they point to. In an attempt to make the MIDI connections easier to understand, Rosegarden provides a window for renaming the MIDI ports to something that more resembles the software or hardware connected at the other end. This is accomplished through the 'Manage Midi Devices' window, opened through its button on the tool bar. To rename the MIDI connection to the AMS, double-click on 'General MIDI Device' in the play devices list and change it to something more meaningful like AMS. The next stage is to assign the first MIDI track's output to the AMS input, using the renamed MIDI connection. To enable MIDI output to AMS, right-click on the first channel at the point where is says <untitled> and from the internal routing list select 'AMS'. This is the equivalent of sending the MIDI output of the track to the AMS synth. It's also worth renaming this track to ams to make it clearer (double click on <untitled>).

Next, create a two-bar block by selecting the Pen tool (F3) and drawing onto the AMS channel between the '1' and the '3'. The box snaps to each bar, representing an area that can now have MIDI data entered into it. To enter some data, while the block is still selected, press 'm'. This opens the matrix editor, which is basically a grid where notes and other data can be added. Rosegarden also features a comprehensive notation editor which is an excellent option for those that understand it. By default, the size if the grid is defined by a single beat, but it's often easier to use a smaller grid size for smaller notes and this is achieved by using the drop down at list at the top right of the window next to the word 'Grid'. A good choice for this is '1/8', after which, notes can be added to the grid with the pen tool and physically drawn onto the matrix (note pitch is on the vertical axis while time is on the horizontal. The note itself can be previewed by clicking on the piano keyboard on the left. The current AMS synthesizer is only monophonic, meaning it can only play one note at a time, but this is perfectly acceptable for bass lines and synth leads.

Once a series of notes have been entered into the block, they are played from simply pressing the 'Play' icon available from any window. The block will then be played through once, with the current position being marked by a moving vertical bar. To make composition easier, it's better to have the current block of data repeated-over while notes are edited in real-time. In Rosegarden this is accomplished by shift-clicking on the grey bar just underneath the horizontal bar strip in the main window, after which the selected bars become highlighted in white. Pressing play will now loop through the highlighted bars, allowing the notes in the matrix editor to be fine-tuned to perfection. To disable the looping behaviour, just shift-click at any point on the same grey area underneath the bar.

Often, when working with several virtual synthesizers on the same system, it becomes necessary to render the output from a synth back to an audio file to save processing cycles. Playing a simple audio file always has significantly less computational overhead than running a software synth. The downside is that after the audio file has been recorded, it's lost a lot of the versatility it had as an easily editable MIDI file. Rosegarden's metronome gets in the way a little when recording audio, to turn it off, open the metronome management window (Composition>Studio->Manage Metronome) and ensure that the bar and beat velocity fields are both set to zero. To record the AMS output into Rosegarden, first select an audio channel in the main window and click on the red 'LED' icon to enable recording on the track. Then, route the audio from AMS to Rosegarden in Jack, using the qjackctl connection window, after which it's just a simple matter of pressing record in Rosegarden.

After pressing stop to finish the recording, if all has gone well, Rosegarden should then calculate the resulting audio waveform from the recording and display it on the corresponding audio track. To listen to the recording, first mute the MIDI channel by disabling the blue 'LED' icon on the MIDI track and press play. The output should be just the same as before, only this time it's from an audio file, and that's all there is too it. Next month we'll try and bring all this together into something that should start to feel more like a composition.


Links

Software used this month