Monday, July 26, 2021

Expand your Horizons

This time, I want to have a look at what is possible using only open source software
and using only Linux.

I don't mean replacing your current OS or DAW, but rather adding to it, with things
like realtime processing, audio manipulation and extra features that are not available
in the more main stream software and plugins.

Many of you will use a DAW like PT or Logic in Mac or Windows.
Nothing wrong with that, but there are things that those apps are not designed to
do at all, or you have to use "kludges" and you have no way of changing the default
behaviour as it's all closed source.

The idea then, is to interface a modest Linux PC to your current DAW/mixer workflow.
Certain tasks can then be offloaded to this PC, but are available in near realtime
on your existing system, or can be accessed via a shared folder on a network.

Linux supports as many sound cards/interfaces as you need, and is limited only
by the resources available on your PC.
How you interface them, is entirely up to you, it can be via XLR/RCA (analog),
Firewire, USB, TCP/IP or Samba shares.

Furthermore, no hardware patch-bay is required, once multiple feeds are coming
in and out of a Linux PC, many software patch-bays are available and can be changed
in realtime.

Below, two scenarios I have created and patches can be saved and recalled at any time.




As can be seen then, the possibilities are almost endless.
There are also separate MIDI patches, but I don't use them.

Below, some actual applications that are available, been coded or modified and
recompiled by me.
In all cases, I used the same computer, which is an entry level Celeron with a 1.8GHz
CPU, 2 GB RAM and good old fashioned 500GB spinning drive.
The Linux I'm using is Debian 9,  64 bits.

For sound cards I'm using the internal one, an extra one on PCI and two on USB-2.
Hence I have in total, 4 stereo outputs (or 8 mono) and 4 stereo inputs plus 4 monos.

Inputs 1&2 connect to the AUX outputs of my Mackie mixer, 3 to the output of my Mac,
and input 4 is a general purpose stereo inputs to connect to the output of my FM tuner,
mobile phone or CD player.
These are selected by means of a hardware patch panel.

As for the outputs, 2 connect to the line inputs of my mixer, 2 to the FX returns and the
rest via a passive mixer to a pair of studio monitors.
These I use as "dry" monitoring channels.
Since no amplification or EQ is required on the monitoring channels, the passive mixer
is a simple lash-up of log sliders feeding a summing matrix.

So here we go, some real world (and realtime) applications.

1) Monitoring loudness and dynamic range of FM radio and CD's.

Have always been interested in how much FM stations compress and "manipulate"
the audio before broadcast.
Connected the audio outputs of my Pioneer FM tuner to a pair of inputs and analyzed
the output of two popular stations.
The first, plays predominantly modern music, note the LRA and frequency response.
(Note, I used a level of around -28 LUFS, to allow for plenty of headroom and range).



Each of the apps that you see, can be used together or individually, and all in realtime.
Further explanation as follows:

The top trace, is the audio waveform, this then allows visual inspection in case
there is any clipping.
The bottom waveforms (green is the left audio & purple is the right).
The one just above it (brownish/orange), is the average frequency response (last 3 secs).
Note the characteristic low cut at 15 KHZ.
All FM stations do this, so as to preserve the stereo pilot tone at 19 KHz & the suppressed 
carrier at 38 KHz.

Then we also have a readout of the time spent analyzing, the RMS value and the LUFS
plus overall LRA.

The bottom app, is just the patch settings.


As can be seen, to do all this in realtime, placed only a few percent CPU load and a
total latency of around 18 milliseconds.
Not bad at all for a Celeron computer with 2 GB RAM.

Let's then look at a FM talk only station:


Very Interesting results.

Let's analyze two different CD's.


A bit compressed, but expected of most of today's music.
At least it's not limited to 15 KHz like FM broadcasts or many streaming platforms.
The second one though, is just crazy, yes it's more dynamic, but just look at the clipping.
So much for standards.


Of course, the same setup could be used to monitor and analyze the audio from TV broadcasts.
You may have also noticed that on the last three tests, I used yet another app, a level histogram.
this is very useful is showing the "spread" or loudness range.

Keep in mind that is was all done in realtime.

2) Getting perceptional loudness and song EQ's:

Those that make and record music or do final mix on music, will know that each genre
of music, has some "established" EQ's or what they sound like.

Once it's time to final mix your song, you may want to make it sound more like a similar
commercial song.
No problem, simply play the commercial song you want to "emulate" through the apps above,
take some screenshots during the intro, chorus, etc and you will have a much better picture.

Some of you will also know that, humans do not perceive all sounds (pitch) at the same level
or intensity.
There has been many studies done on this, and the LUFS system also takes this into account.
There are algorithms available so we can easily make an app to see what a specific mix
will sound like.

Below is the response of some music, with relation to this.
It's a 3 second average of how it will be perceived, it's not a frequency response in the 
traditional sense, but intensity of frequencies as they will be perceived by the average person.

I have also added a LUFS meter, plus another very handy app, an instant recorder.
By clicking on the big green icon, it will record the audio and time stamp it for later reference.



These apps alone are worth having to monitor your mix from your DAW on a daily basis.

3) Auto Normalizing audio files in a watch folder.

Another use could be to get the computer to auto normalize (to -23 or any other level)
all files that are placed in a special watch folder.
For each file, a screenshot of the finished product can also be automatically generated.



4) Some effects

Yet another use, is to create effects for TV or radio shows.
One effect that is quite difficult to achieve, is the realistic simulation of a cellphone or
other digital call that is breaking up.
Normally it involves reducing the sample rate and some EQ.
However, this is not that realistic, to get that mangled sound, one should ideally feed
the audio through a real digital channel and create the break up or decimation there.

Again, open source to the rescue, there are uLAW, GSM and other codecs available
that can be manipulated to adjust the "break-down".

To that, just add some EQ and some compression to replicate those conversations.

The settings I used for GSM "mangling":


I have full control of level, phase and simulated bit error rate.
On top of this, some compression and more "envelope mangling":


The results?

Before and after:




5) Silence detection & reporting.

In situations like broadcasting, streaming and others, realtime monitoring
of silence (or drop-outs) is extremely important.

Since we can analyze audio in realtime, it then becomes a simple matter
to set up a circular buffer sampling an audio input or inputs.
The buffer size determines the sample rate and period we must sample
for the resulting silence (or another level) that is then treated as an 
alarm condition and acted upon.

The action that is automatically taken can be programmed in a script.
It can range from a simple audible alarm, to an email or even activating
a pin on a hardware port, which in turn can activate another piece of kit.

Over and above, a log in an excel compatible spreadsheet can also be
automatically created.

The opposite is also possible, automatic recording only when there is
audio above a certain level available.
This is very handy for situations where the audio may be periodic or
even sporadic.
No reason to fill up a hard drive with hours and hours of silence.

I have created an app that can record (with no silences) to one long
audio file, or separate audio files each with their time & date as file names.

As can be seen, loads of possibilities which are only limited by your
needs and imagination.
Each of the above examples can of course be tailored to many other
applications and uses.
Since I have all the source code, any changes can be quickly applied with
no need for an update from a company.

In conclusion, I hope that this blog has given you some ideas to try out new things,
ideas and concepts.

Will leave you with one final idea:
Get some audio transformers from old, un-used equipment and wire them inline
with you inputs and outputs of you new Linux computer.
It will help get some of that old, analog sound to your mixes.




Don't be scared to experiment, it will help you expand your horizons and possibilities.




Thursday, July 1, 2021

What lurks beneath

 No, it's not a horror movie, but it may well turn into a horror story if you're not careful.

I'm of course talking about audio interference, not the type you can hear, not immediately anyway.
We hear audio as longitudinal waves, i.e. the compression of air molecules,
but.....much more exists as electromagnetic (RF) waves.

So we can't hear them as they are electromagnetic, but they can, and do at times, wreak havoc
with our audio recordings.

So how do these electromagnetic waves get into our audio paths?

There are two main ways, both via capacitive or inductive coupling.
(Basically, as a result of poor shielding and isolation of circuits and cables).

1) Waves that are higher than the audio spectrum, but are picked up, rectified and the 
modulation of the main carrier, which is in the audio spectrum, is then heard.
We have all heard cellphone interference on audio equipment.
The actual carrier can be anywhere from 900 - 2200 MHz, definitely not audible,
however, the digital modulation will be heard after rectification.

Keep in mind that ANY semiconductor junction in electronic devices,
can act as a rectifier.
To make it worse, modern audio equipment has a combination of analog and digital
gain circuits, which makes equipment much more prone to interference if not
adequately shielded or fed with inferior cables.

2) The other type of potential interference, is from electromagnetic waves which are
in the audible range but are not heard as they are RF and not longitudinal waves.
Unheard of course, until our equipment picks it up, amplifies it and ruins our recording.
Rectification is not even required as they are already in the 20 Hz - 20 KHz range.

An example of this, is 50 Hz (mains) pickup.

To illustrate this, I built a RF adapter for my cellphone.
So it does not record using a microphone, but rather by picking up electromagnetic
waves that are in the range of 20 Hz and 20 KHz, actually up to 22 KHz.

First up, mains interference.
This was recorded 2 meters away from any wall plug and the antenna was a short piece
of wire.
Again, no microphone was used, this is purely an electromagnetic (RF) recording.




The fundamental at 50 Hz is clearly visible (and audible when recorded), plus
harmonics going all the way up to around 1 KHz.

So what else is lurking, just waiting to ruin your recordings?

A quick scan around the house, quickly revealed some candidates.
First off, the spark igniters on the gas stove.



The aerial is just a short screwdriver, this is what was picked up:



Those peaks are the sparks being created.
Zooming in, we see that they last for around 6 samples (@44.1 KHz sample freq.)
which puts them at 7.439 KHz.
The repetition rate is 3 sparks/second.


Since I'm sampling at 44.1 KHz, can "see" signals up to half of that (Nyquist rule),
so let's look at what harmonics it produces.
We can see the 2nd harmonic (at 14.698 KHz), the 3rd will be of no consequence as it's
pretty much on the edge of what someone with good ears will hear.



Nasty, and it manifests itself as short, sharp clicks.

Let's take another example, the garden.
Surely, other than the audible (with our ears), there is not much else.
Let's find out.
First, let's record with the built-in cellphone's mic.

Other than some birds and wind noise, not much else.
Aha, that is what you think, let's switch to RF mode:



What the ??
Let's look at what it is, it's frequency and spectrum plot.







So, it's clicking pulses with most of the energy concentrated at around 10 KHz
and just look at the level.
Yep, it's my electric fence.

This was recorded in the middle of my garden, with the "antenna" being a 50 cm 
piece of wire and about 4 meters away from the fence.
This then, simulates a crappy audio cable quite well.

I was lucky that it's not on my microphone recording as it was done all with the cellphone.
No cables, no external mixers, etc.
Had I being doing an outside broadcast or other recording with lots of external cables
and equipment, almost sure some of that fence energy would be on that audio recording.

I hope that by now, you are more aware of things that can catch you out,
and there are plenty more.
Electric motors (without suppression), geysers and other high current appliances switching
on and off.

Let's not forget about lights, light dimmers, ...........

The list is a long one, but by always using good quality shielded cables, as short as possible
and properly shielded equipment, you decrease your chances of being affected 
by what lurks beneath, unseen and unheard until it's too late.

This RF adapter is actually a rather handy thing, maybe I'll start making a few and selling them.

Wednesday, June 23, 2021

Audio Dropouts

Nothing in my opinion, is more irritating than audio dropouts.
Be it in music, speech or the sound track of a video, they are
extremely jarring and detract from the enjoyment.

Audio dropouts can be caused by many things, but usually
as a result of inferior/faulty equipment, buffer under-runs
or just plain sloppiness from who ever is recording the media.




They can occur on only one channel, both channels of a stereo recording, or even
all channels in a 5.1 or 7.1 surround sound recording.
The duration and "intensity" can also vary, making them not the easiest of things to remove.

This is especially true if the audio is part of a video's soundtrack, you can't just lop them off
otherwise the whole audio will become out of synch with the video.

If the dropout is only on one channel, copying the other (good) channel and pasting it in place
sometimes works, depending of course on the content, phasing and stereo field.

The other way of course is re-synthesizing it, from bits and pieces.
Slow going, but no real alternative.
That then, probably explains the clip below, from a well known broadcaster
who shall remain nameless. ;-)

Before, 5 dropouts in just 20 seconds, and it's not even the whole clip.



With a bit of effort and time, the result is much better and well worth it.




Monday, June 7, 2021

The Call of the Ibis

 The call of the ibis, summed up in a single picture:





Love them or hate them, the ibis must be responsible for countless ruined recordings.

According to Wikipedia:





What they don't mention is, these note have a glissando effect and are very loud, which in
turn creates loads of harmonics and can even overload recording equipment, causing clipping.

The ibis sound is then a perfect candidate to try some DSP on.
Let's make it even more difficult by having some music too.
The music has very simple notes, which makes for a good test and simple to hear
 if we change the "sound" or timbre of the notes in any way.

The "raw" recording:


I'm pretty pleased on how it turned out.
The dreaded call of the ibis is 99% gone and the timbre is unchanged.


Add some extra ambience and they are pretty much gone.


It wasn't easy, took a bit of time but the result is worth it.
Can the call of the ibis be removed every time?
Probably not, or at least not 100%, but at least it's worth a try.
Better than scrapping the whole recording.

Wednesday, June 2, 2021

Enhancing old recordings

Let's start off with a recording from 1919.
The original was recorded by the Edison Company and is a short comedy skit.

As expected, lots of noise, limited frequency response and it's monophonic. 



When restoring and cleaning up old material, there is always an important question to be asked..
How much to clean up.
For these examples, I will restore to different levels, so as to better demonstrate what is possible.
Below, is the same clip, cleaned and a stereo field is re-created.
The judge is on one side, the bailiff on the other and general sound effects centered slightly wide. 



Here is another, a 1953 Elvis recording.



Usual sort of thing, noise and limited frequency response.
The recording was not badly made, it was the norm for the 50's.

Technology has moved on, and so has music and how it sounds.
There have been many studies on how music (frequency wise), has evolved over the decades.
Here is a graph showing the average results from thousands of songs across many genres.


Today's music has more low end, less mid-range and more high end by several dB's, when
compared to the 1950's.
So let's apply it to the 1953 recording.
Listening on good speakers or headphones is recommended.
Note how the guitar is richer, brighter and wider.

It's a tad too "bright" for my liking, but I intentionally left it like that to show what can be achieved.
The trick here, was to re-create the high frequencies that were non existent in the original.
Simply using EQ is not going to do that, as it will just amplify more noise.





One more example, a LM radio special broadcast for New Year's eve, 1969-1970.
Since it was recorded off a shortwave radio, there is plenty of noise, crackles, whistles and heterodynes.
The original is barely listenable due to a constant whine and carrier heterodyning with other stations.




After much processing as there where plenty of interfering sounds and carriers, we have something
much more pleasant whilst keeping the characteristic shortwave "sound".


Friday, May 21, 2021

Cleaning Audio For Ambience - Not so quiet suburbia.


As an exercise, decided to see if some ambience recorded in a public park could be used for say
a scene of a character walking in the woods or a forrest.

I planned my ambience and SFX tracks, background birds, footsteps, perhaps a bubbling brook, etc.

The first few were easy, a 30 second recording of me walking on gravel and an indoor water feature.
Time for a walk in the park to record some birds, as it turns out, not exactly a "walk in the park".

Guaranteed that no matter the time of day you go to a public place like a park, you will not be alone.
Other people means, other noises, very unwanted noises.

I did my 30 second recording and as predicted, lots of unwanted noises.
Below, the raw recording, quietest one of five:


Not exactly great, especially towards the end.
People talking in the distance, cars, and other general crud.

After about 10 minutes of cleaning and layering the other SFX over it,
the result is not too bad.



All recordings were done with a modest Hisense H20 Smartphone, format was
wav @ 44.1 KHz


Thursday, May 20, 2021

Repairing Damaged Audio Pt4 - Old McDonald has (no more) farm....


I recently discovered a funny video on Youtube.
An old man decides to interrupt a TV interview in a very unique way.
I't in Greek but that ain't important, watch....



I don't think the broadcaster was too impressed.
Can the interview be saved, assuming it wasn't live ?

You bet it can.



The animal farm has gone, but now it looks very odd with the old man opening his mouth
and no sounds coming out.

Easily fixed with a bit of zooming.


Expand your Horizons

This time, I want to have a look at what is possible using only open source software and using only Linux. I don't mean replacing your c...