Tuesday, August 21, 2012

Femto Photography.


Honestly, there isn't much more than I can say about this; it should speak for itself.


Sunday, August 12, 2012


When I'm teaching people about networks, the one thing that tends to cause confusion is the concept of Subnets.

If you've ever manually entered an IP address, you'll be familiar with the following:

I've added the red box to point out the "subnet mask"; a bunch of 255's and 0's that magically appear whenever you type in an IP address.

But what does it mean?

Splitting Networks

I briefly touched on the subject of packet switching in my "Layers of the Internet" article. Basically, an Internet Protocol (IP) network is a collection of devices connected via some form of network.

But what if we wanted to have some computers on the same network, but we didn't want them to interact? For example, we had the computers that controlled a company's payroll on the same network as the company's email servers.

Obviously that's not a wise thing; anyone with a bit of networking knowledge and access to Google would be able to give themselves an unexpected pay rise.

Thankfully, internet engineers foresaw this problem and came up with "subnets". A Subnet is a simple way of splitting one physical network in to two "virtual" networks.
Just like devices that are on separate physical networks, devices on different Subnets can't communicate with each other.

In other words, you can have the finance guys  on one subnet and the rest of the company on the other subnet, and you'll never have to worry about people editing their own pay grade.

One Number; two addresses

The great thing about Subnets is that they are contained within the devices' IP addresses by default.

The IP address is made up of two parts; the "Subnet" address and the "Device" address.

In fact, an IP address is a lot like a Street address. If you look at an address like "31 George St" you can instantly find that building. "31" by itself means nothing, and "George St" is too vague to be of any use.

In our IP addresses the "Subnet" address is the street, and the "Device" address is the number.

But let's look at one of the IP addresses above.
That doesn't look much like "31 George St". Which part is the Street, and which is the number?

Subnet Masks

Now we are finally coming to the mystery behind the Subnet Mask.
A Subnet mask tells us which part of the address is the street and which is the number.

The network in the diagram above has a subnet mask of:
Quite quickly we can see something special here. Everywhere that there is a "255" is part of the Street Name, and every where that there is a "0" is the number.

Let's look at that address again:
If use use the above rule, the "Street" (Subnet) becomes 192.168.100 and the Device number is 5.

Looking at our network again, we can see that the Finance machines on subnet 192.168.100 are effectively on a separate network from the workstations on the 192.168.101 subnet.

But what if...
Okay, for an exercise, let's take the same network as above, but let's change the subnet mask to:
As you'd imagine, all of the devices are now on the same subnet:
is on the same subnet as

So we have to be careful when designing our networks to include the correct subnet masks in all of our addresses.

But what does mean?
I have never been asked this question, so I am going to pre-empt you all and give you the answer.

Remember that all computers work in binary, that is, 0's and 1's.
An IP address is made up of four groups of eight bits, that is, eight 0's or 1's.

So, if we were to look at in binary, it would look more like:
Now, that doesn't look like much to a normal person, but now let's have a look at the subnet mask
It should be immediately obvious that the 1's show the subnet, and the 0's show the device number.

And so we come to a more general rule:
The Subnet Mask denotes the "Subnet" part of an IP address with a 1, and the "Device" part with a 0.

If we look at other subnet masks we can see this quite clearly: = 11111111.11111111.00000000.00000000
We can also get into more exotic subnet masks: = 11111111.11111000.00000000.00000000

It's very rare to find a subnet mask that isn't a combination of 255's and 0's for the simple reason that it is practically impossible to work out the subnet/device number of a "split" subnet mask.

Slash Fiction

Since writing constantly is a bit of a pain, IT people have come up with a quicker way of notating the subnet mask of an IP address.

Normally, for our Finance Server in the example above, we'd have to write:
Subnet Mask:
But let's look at the subnet mask of in binary again:
We can see that this is simply twenty-four 1's in a row. So, we can write the full IP address of the server as:
The "/" at the end of the address denotes the subnet mask; in this case, twenty-four 1's (or, in decimal,

If we had the subnet of, the Full IP address could be written:
as only has sixteen 1's in a row to denote the subnet address.

I hope that this has explained the concept of the subnet mask. As always, please let me know if you think that this could be a better explanation!

(PS: I do know that there is also the whole subject of VLANs that offer a better explanation for how to separate networks, but I'll leave that for another time!)

Wednesday, July 18, 2012

Why Square Waves Matter

A while ago I wrote a post about what Square waves are, how they are formed, and how they are really just made up of a bunch of increasingly higher-pitched sign waves.

I'm sure that was more than enough graphs and lines to scare anyone into submission. That's not such a bad thing.

But one thing that I didn't get into is why square waves are important to the modern sound engineer.

Distortion - nothing's perfect
Whether you want it or not, Distortion is at the heart of every piece of reproduced music. It doesn't matter if that reproduction is "live" (as in a microphone running through a mixing console at a rock concert) or if it was recorded 15 years ago and played back on a CD player.

There are a number of different reasons for this, some of which (like the reaction of various electronic components like capacitors) will be left for later; there's just simply too much to cover.

What I'd like to cover is the linking between Square Waves and distortion, specifically in two areas: Gain and Quantisation.

Gain Management
If you've ever used a mixing console (or pretty much anything that shows you the audio levels in the standard green-orange-red format) you've probably kept on turning up the volume until you've got some pretty red lights blinking all over the place. If you ask any experienced engineer they'll tell you that this means that they are "saturating" the console's amplifiers, leading to "some nice compression" and/or distortion.

But what's actually happening here?

At the heart of every bit of audio equipment is a humble little circuit; the Operational Amplifier (Op-Amp). This simple circuit has a never-ending number of variations and uses, but essentially all we need to know is that it takes an input signal and some power, and outputs the same signal but with more volts.
Your stock-standard op-amp drawings. 
Okay, once again I can feel that this picture means nothing to you.  Never fear; let me explain.
 The top picture is how most of us think of amplifiers: you put a signal (+ and -)  into a circuit and you get some kind of output (shown here as the line out the right hand side of the Amp).

In fact, it's perfectly acceptable to only show the +ve side of the input.
Essentially what this image shows is what we mentioned above; you put a small signal into the amp, and you get a bigger signal out. What actually goes on inside the triangle is inconsequential.

However, the bottom picture gives us a little more information. Here we still see our inputs and outputs (U+, U- and U0). There's no difference there. But we now also see two new variables; Ucc and Uee. These represent the "power" that we are supplying to the amplifier.

In normal operation, the input signal is small enough so that the output (U0) is less than the total power that you are feeding to the op-amp (Ucc and Uee).

But if your input is too big, you can get to a situation where U0 needs to be bigger than Ucc. Since the op-amp has run out of power it stops amplifying and simply outputs the maximum power; i.e. Ucc.

Two examples of clipping; we're interested in the lower example

If you look at the image above, you'll see what I mean. The dashed "threshold" lines indicate Ucc and Uee; in other words, the maximum and minimum possible voltages of the output, U0. For the moment, we're only going to look at the lower example.

You'll notice that as soon as the output reaches the maximum (Ucc) or minimum (Uee), the waveform flattens out, no matter what the input signal looks like.

You'll also notice that this looks exactly like a square wave.

If you have a look at the previous article on Wave Theory, you'll note that a Square Wave contains the original frequency as well as a number of  harmonic frequencies. If we were to look at the above waveform on a spectrum analyser you would initially see a single peak (the input frequency). As the input increases beyond the Ucc threshold, you would start to see the single peak get shorter and more harmonic peaks growing up, as if out of nowhere.

As the clipped wave starts to look more like a square wave, you get more harmonics

These harmonics are the "distortion" that we are hearing. 

Since no amplifier circuit is perfect, you'll always have a bit of this Harmonic Distortion cropping up along the way. It's one of the measurements of amplifier power; Total Harmonic Distortion (or THD), and is expressed as a percentage. The percentage refers to the amount of power that is "lost" in the harmonic peaks. In short, a lower number is better - the number is telling you how much "false" information you're hearing due to the amplifier circuit.

Essentially, you can "fake" an amplifier's power rating by increasing the THD tolerance. An amplifier than can deliver 100W at 0.1% THD might be able to deliver 300W at 5% THD. That's because you're increasing the output of the amplifier, and also increasing the harmonics that are creeping into your original signal.

Is that a bad thing?
Distortion isn't necessarily a bad thing. Rock 'n' Rollers have been using fuzz pedals and distortion generators for decades. As with all sound-related things, everyone has their own opinion. But you also need to make sure that you're getting the right gear for the job. A 300W 10% THD amplifier might be perfect for your car stereo, but you might want a 300W 0.1% THD amplifier for your Hi-Fi speakers in your living room.

Quantisation Noise
The other, very similar form of distortion that I'd like to discuss here is Quantisation Noise.

As we saw in my PCM post, digital audio effectively segments up an analogue signal into a bunch of "stepped" signals.
A 4-bit quantisation (grey) of a sine wave (red)

Hopefully, it won't take you much imagination to realise that the grey, "digital" signal will have a number of harmonic frequencies tied up within its square-wave-like structure.
If not, then scroll back up and have a look at the last image showing the build-up of harmonics in the Square Wave example again!

Of course, just as we explained in the PCM article, the above representation is a gross simplification of a digital signal; even a 16-bit signal has millions of steps, making the harsh corners a little more manageable.

That being said, a digital recording will always have a certain amount of distortion, or "Quantisation Noise," inherent in the system. In low bit-rate recordings or transmissions (e.g. bad digital radio), this comes through as a watery-garbling of the audio signal.

Here is an example of an 8-bit recording, and then the noise generated as this is reduced in bit-depth to:
4 Bits (like the above image)

But does it matter?
I've just had a look at a couple of Analogue-to-digital converters in 16 bit terms. These list the THD of the entire converter (including the op-amps and the rest of the circuitry) at about -100dB. That equates to a THD of about 0.0009%. 

Whilst there is a lot of complaints about the "sound" of digital recordings (and yes, I do admit that there are differences between the two), the chances are that the THD of the amplifier is many, many times greater than the harmonic distortion that is caused by the "digital-ness" of the recording.