Tag Archive for: dither

Dither is used when you need to reduce the number of bits. The best example, and one that is commonly used, is when dithering down from 24 bits to 16 bits or 16 bits down to 8 etc…Most commonly, dithering from a higher bit depth to a lower one takes place when a project you are working on needs to be bounced down from 24 bits to 16 bits using dithering algorithms.

So, what is the process; in mortal language of course?

A very basic explanation is we add random noise to the waveform when we dither, to remove noise. When we truncate the bits, ie, in this case, we cut down the least significant bits, and the fact that we are always left with the stepped like waveforms in the digital process, by adding noise we create a more evenly flowing waveform instead of the stepped like waveform. It sounds crazy, but the noise we add results in the dithered waveform having a lower noise floor. This waveform, with the noise, is then filtered at the output stage. I could go into this in a much deeper context using graphs and diagrams and talking about probability density functions (PDF) and resultant square waves and bias of quantisation towards one bit over another. But if I did that you’d probably hate me. All that matters is that dither is used when lowering the bit depth and that this is an algorithmic process, ie using a predetermined set of mathematical formulas.

If we take the 24 bit project scenario and select to bounce the resultant audio without dithering then the last eight bits (also know as Least Significant Bits) of every 24-bit sample are discarded. In terms of audio integrity, you will not only lose resolution but also introduce  Quantisation Noise. Because dithering adds random noise to the lower eight bits of the 24 bit signal whilst maintaining stereo separation the quantisation noise is dramatically reduced. It then makes sense to dither from 24 bits to 16 bits rather than bounce without it.

How well the process is executed is down to how good the dithering algorithms are. But to be honest these algorithms are so good nowadays that even standard audio sequencing suites (Cubase, Logic etc) will perform dithering tasks without much problem.

My recommendation is to always work in 24 bit and dither down to 16 bit for the resultant file, as CD format is still 16 bits.

Relevant content:

Jitter in Digital Systems

AN INTRODUCTION TO DIGITAL AUDIO

In the old days, sampling consisted of recoding the audio onto magnetic tape. The audio, (analogue), was represented by the movement of the magnetic particles on the tape. In fact, a good example is cutting vinyl. This is actually sampling because you are recording the audio onto the actual acetate or disc by forming the grooves. So, the audio is a continuous waveform.

Whether we are using a hardware sampler, like the Akais, Rolands, Yamahas, Emus etc…, or software samplers on our computers, like Kontakt, EXS24, NN-19 etc…, there is a process that takes place between you recording the analogue waveform (audio) into the sampler and the way the sampler interprets the audio and stores it.. This process is the conversion of the analogue signal (the audio you are recording) into a digital signal. For this to happen, we need what we call an analogue to digital converter (ADC) and for the sampler to play back what you have recorded and for you to hear it, the process is reversed but with a slightly different structure and process, and for that to happen we need a digital to analogue converter (DAC). That is simple and makes complete sense. Between all of that, there a few other things happening and with this diagram (fig1) you will at least see what I am talking about.

Fig1

The sampler records and stores the audio as a stream of numbers, binary, 0s and 1s, on and off. As the audio (sound wave) is moving along the ADC records ‘snapshots’ (samples) of the sound wave, much like the frames of a movie.. These snapshots (samples) are then converted into numbers. Each one of these samples (snapshots) is expressed as a number of bits. This process is called quantising and must not be confused with the quantising we have on sequencers although the process is similar. The number of times a sample is taken or measured per second is called the sampling rate. The sampling rate is measured as a frequency and is termed as kHz, k=1000 and Hz= cycles per second. These samples are measured at discrete intervals of time. The length of these intervals is governed by the Nyquist Theory. The theory states that the sampling frequency must be greater than twice the highest frequency of the input signal in order to be able to reconstruct the original perfectly from the sampled version. Another way of explaining this theory is that the maximum frequency that can be recorded with a set sample rate must be half the sample rate. A good example at this point would be the industry standard cd. 44.1 kHz means that the number of times a sample (snapshot) per second is taken equates to 44,100/second.

Ok, now let’s look at Bits. We have talked about the samples (snapshots) and the numbers. We know that these numbers are expressed as a number of bits. The number of bits in that number is crucial. This determines the dynamic range ( the difference between the lowest value of the signal to the highest value of the signal) and most importantly, the signal to noise ratio (S/N). For this, you need to understand how we measure ‘loudness’. The level or loudness of a sound is measured in decibels (dB), this is the unit of measure of the replay strength ( loudness) of an audio signal. Named after this dude Bell. The other measurement you might come across is dBu or dBv, that is the relationship between decibels and voltage. This means that decibels referenced to .775 volt. You don’t even need to think about this but you do need to know that we measure loudness (level) or volume of a sound in decibels, dB. 

Back to bits. The most important aspect of bits is its resolution. Let me explain this in simpler terms. You often come across samplers that are 8 bit, Fairlight CMI or Emulator 11, or 12 bit, Akai S950 or Emu SP1200, or 16 bit, Akai S1000 or Emulator 111 etc..You also come across sound cards that have 16 bit or 24 bit etc…Each bit refers to how accurately a sound can be recorded and presented. The more bits you have (Resolution), the better the representation of the sound. I could go into the’ electrical pressure measurement at an instant’ definition but that won’t help you at this early stage of this tutorial. So, I will give a little simple info about bit resolution.

There is a measurement that you can use, albeit not clear cut but at least it works for our purposes. For every bit, you get 6dBs of accurate representation. So, an 8 bit sampler will give you 48dB of dynamic range. Bearing in mind that we can, on average, hear up to 120dB, that figure of 48dB looks a bit poor. So, we invented 16 bit cd quality which gives us a 96dB dynamic range. Now we have 24 or even 32 bit sound card and samplers (24 bit) which gives us an even higher dynamic range. Even though we will never use that range, as our ears would implode, it is good to have a bit. Why? Well, use the Ferrari analogy. You have 160mph car there and even though you know you are not going to stretch it to that limit (I would), you do know that to get to 60mph it takes very little time and does not stress the car. The same analogy can be applied to monitors (speakers), the more dynamic range you have the better the sound representation at lower levels.

To take this resolution issue a step further: 8 bits allows for 256 different levels of loudness to a sample, 16 bit allows for 65,536. So, now you can see that 16 bits gives a much better representation. The other way of looking at it is: if I gave you 10 colours to paint a painting (copy a Picasso) and then gave you a 1000 colours to paint the same painting, which one would be better in terms of definition, colour, depth etc.? We have the same situation on computer screens and scanners and printers. The higher the resolution the clearer and better defined the images on your computer, or the better the quality of the scanned picture, or better the resolution of the print. Fig2. As you can see from the figure below. The lowest bit resolution is 1 and the highest is 4. The shape of the highest bit resolution is the closest in terms of representing the shape of the audio signal above. So the higher the bit resolution the better the representation. However, remember that because we are dealing with digital processing and not a continuous signal, there will always be steps in our signal in the digital domain.

Fig2

Now let’s look at the signal to noise ratio (S/N). This is the level difference between the signal level and noise floor. The best way to describe this is by using an example that always works for me. Imagine you are singing with just a drummer. You are the signal and the drummer is the noise (ha.ha). The louder you sing or the quieter the drummer plays the greater the signal to noise ratio. This is actually very important in all areas of sound technology and music. It is also very relevant when we talk about bit resolution and dynamic range. Imagine using 24 bits. That would allow a dynamic range of 144 dB. Bearing in mind we have a limit of 120 dB hearing range (theoretical) then the audio signal would be so much greater than the noise floor that it would be almost noiseless.

A good little example is when people re-sample their drums, that were at 16 bit, at 8 bit. The drums become dirty and grungy. This is why the Emu SP1200 is still so highly prized. The drum sampler beatbox that gave us fat and dirty drum sounds. Lovely.

Now, let’s go back to sample rates. I dropped in a nice little theorem by Nyquist to cheer you up. I know, I know, I was a bit cold there but it is a tad relevant.

If the sampling rate is lower or higher than the frequency we are trying to record and does not conform to the Nyquist rule, then we lose some of the cycles due to the quantisation process we mentioned earlier. Whereas this quantisation is related to the input voltage or the analogue waveform, for the sake of simplicity, it is important to bear in mind it’s relationship with bits and bit resolution. Remember that the ADC needs to quantise 256 levels for an 8 bit system. These quantisations are shown as steps, the jagged shape you get on the waveform. This creates noise or alias. The process or cock-up is called aliasing. Check Fig3.

Fig3

To be honest, that is a very scant figure but what it shows is that the analogue to digital conversion, when not following the Nyquist rule, leaves us with added noise or distortion because cycles will be omitted from conversion and the result is a waveform that doesn’t look too much like our original waveform that is being recorded.

To be even more honest, even at high sampling the signal processed will still be in steps as we discussed earlier about quantisation and the way the digital process processes analogue to digital.

So how do we get past this problem of aliasing? Easy. We use anti-aliasing filters. On Fig1, you see that there are 2 filters, one before the ADC and one after the DAC. Without going back into the Nyquist dude’s issues, just accept the fact that we get a great deal of high-frequency content in the way of harmonics or aliasing with the sample rate processing, so we run a low pass filter that only lets in the lower frequencies and gets rid of the higher frequencies (above our hearing range) that came in on the signal. The filter is also anti-aliasing so it smoothes out the signal.

What is obvious is that if we are using lower sampling rates then we will need a filter that is a steeply sloped frequency band (aggressive). So, it makes sense to use higher sampling rates to reduce the steepness of the filter. Most manufacturers put an even higher sample rate at the output stage so the filter does not need to be so aggressive (please refer to upsampling further on in this tutorial). The other process that takes place is a process is called interpolation. This is an error correction circuit that guesses the value of a missing bit by using the data that came before and after the missing bit. A bit crude. The output stage has now been improved with better DACs that are oversampling, and additionally a low order analogue filter just after the DAC at the output stage. The DAC incorporates the use of a low pass filter (anti imaging filter) at the output stage.

Now let’s have a look at an aggressive form of alias called foldover. Using Nyquist again: A sampling rate of 44.1 kHz can reproduce frequencies up to 22.05kHz (half). If lower sampling rates are used that do not conform to the Nyquist rule, then we get more extreme forms of alias. Let us put that in simple terms and let us take a lower sampling rate and for the sake of this argument, let us halve the usual 44.1 kHz. So, we have a sampling rate of 22.05 kHz. We know, using Nyquist, that your sampler or sound card cannot sample frequencies above half of that, 11.025 kHz. Without the use of the filter, that we have already discussed, the sampler or sound card would still try to record those higher frequencies (above 11.025 kHz) and the result would be terrible as the frequencies would now be re-markedly different to the frequencies you were trying to record.

So, to solve this extreme form of alias, manufacturers decided to use a brick wall filter. This is a very severe form of the low pass filter and, as the name suggests, only allows frequencies at a set point through, the rest it completely omits. However, it tries to compensate this aggressive filtering by boosting the tail-end of the frequencies, set by the manufacturer, to allow it to completely remove the higher frequencies.

However, we have now come to a new improved form of DAC called upsampling.

An upsampling digital filter is simply a poor over oversampled digital reconstruction filter having a slow roll-off rate. Nowadays, DAC manufacturers claim that these DACs improve the quality of sound and when used, instead of the brick wall filters, the claim is genuine. Basically, at the DAC stage, the output is oversampled, usually 8 times, this creates higher frequencies than we had at the AC stage, so to compensate and remove these very high frequencies, a low order analogue filter is added after the DAC and just before the output. So we could have an anti-aliasing filter at the input stage and an upsampling DAC with a low order analogue filter at the output stage. This technology is predominantly used in cd players and, of course, sound cards, and any device that incorporates DACs. I really don’t want to get into this topic too much as it really will ruin your day. At any rate, we will come back to this and the above at a later date when we examine digital audio in more detail. All I am trying to achieve in this introduction is to show you the process that takes place to convert an analogue signal into digital information, back to analogue at the output (so we can hear it: Playback) and the components and processes used.

The clock. Digital audio devices have clocks that set the timing of the signals and are a series of pulses that run at the sampling rate. Right now you don’t need to worry too much about this as we will come to this later. Clocks can have a definite impact in the digital domain but are more to do with syncing than the actual digital processes that we are talking about in terms of sampling. They will influence certain aspects of the process but are not relevant in the context of this introduction. So we will tackle the debate on clocks later as it will become more apparent how important the role of a good quality clock is in the digital domain.

Dither

Dither is used when you need to reduce the number of bits. The best example, and one that is commonly used, is when dithering down from 24 bits to 16 bits or 16 bits down to 8 etc… A very basic explanation is we add random noise to the waveform when we dither, to remove noise. We talked about quantisation earlier in this tutorial and when we truncate the bits (lowering the bit resolution), ie, in this case, we cut down the least significant bits, and the fact that we are always left with the stepped like waveforms in the digital process, by adding noise we create a more evenly flowing waveform instead of the stepped like waveform. It sounds crazy, but the noise we add results in the dithered waveform having a lower noise floor. This waveform, with the noise, is then filtered at the output stage, as outlined earlier. I could go into this in a much deeper context using graphs and diagrams and talking about probability density functions(PDF) and resultant square waves and bias of quantisation towards one bit over another. But you don’t need to know that now. What you do need to know is that dither is used when lowering the bit resolution and that this is an algorithmic process, ie using a predetermined set of mathematical formulas.

Jitter

Jitter is the timing variation in the sample rate clock of the digital process. It would be wonderful to believe that a sample rate of 44.1 kHz is an exact science, whereby the process samples at exactly 44,100 cycles per second. Unfortunately, this isn’t always the case. The speed at which this process takes place usually falters and varies and we get the ‘wobbling’ of the clock trying to keep up with the speeds of this process at these frequencies. This is called jitter. Jitter can cause all sorts of problems and it is best explained, for you, as the lower the jitter the better the audio representation. This is sometimes why we use better clocks and slave our sound cards to these clocks, to eradicate or diminish ‘jitter’ and the effects caused by it. I will not go into a deep explanation of this as, again, we will come to it later in these tutorials.

So, to conclude:

For us to sample we need to take an analogue signal (the audio being sampled), filter and convert it into digital information, process it then convert it back into analogue, then filter it and output it.

Relevant content:

Jitter in Digital Systems

Dither – What is it and how does it work?

This month’s tutorial is going to concentrate on the basic and general tools available for the sampling process and will not focus on the more detailed or esoteric tools that are adopted to further hone the sample.

So, let’s start right at the input stage of the sampler or sound card.

We have already covered the topic of attaining a clean and hot signal. Now, we need to cover the tools available to actually sample a sound, and how to use the tools available after you have sampled a sound.

Most samplers will allow you to sample in a number of ways. But first, it is important, and sensible, to create a location for the samples. On computers, it is always good practice to create a section on your hard drive for audio. You can then create folders for your samples and have them in categories, for example, if you are sampling bass sounds, have a folder named ‘Basses’, for drums have a category named ‘Drums’ and then assign subcategories and name them relative to what you are sampling. So, for Drums, you c could have subcategories for kicks, snares, and hi-hats etc. This makes filing (archiving) of the samples, and even more importantly, the searching for a sample, much easier.

On hardware samplers, it is pretty much the same. You create a bank and name that and within that bank you create presets, which house the samples. On Emu samplers, the sampler creates a default preset on startup. This makes life easier. Most samplers have this facility.

Now let us look at the different ways of sampling that certain samplers provide.

I am going to concentrate on Emu Ultra samplers for this tutorial.

For the sampler to begin sampling, it needs to know a few things.

  • Source analog or digital, 44.1 kHz or more. Pretty self-explanatory as it is asking you to choose the source and the sample rate. Some samplers will have the option that will allow for digital recording as well as analog. There are advantages to using digital recording modes but there are also disadvantages. The sample rate, however, is important. If you own a Sound Blaster card and it only operates at 48 kHz, then sampling at 44.1 kHz is not helpful at all. The other advantage of sampling at a higher rate is for precision and clarity in the representation of the sound you are sampling. The disadvantage of higher sample rates is that they will eat up memory. In the virtual world (computer), it is now more common to sample at 24 Bits and 96 kHz (24/96) or 44.1 kHz (24/44.1). However, these parameters are dependent on the sound card you are using. If 24/96 is not supported then you cannot sample at those values.
  • Input This is for selecting mono or stereo for the sampling process.
  • Length You can predetermine the length of the sample you want to record. Maybe you only need to sample 3 seconds of a sound. Setting 3 seconds as the length automatically stops the sampler recording after 3 seconds of sampling.
  • Dither Used when recording digitally.
  • Monitor Gives you the option of having it on or off. Setting it to on allows you to listen to the sound being sampled while it is being sampled.
  • Gain Here you can adjust the input gain (volume/level) of the sound (signal) being sampled. If the signal is too loud and is distorting or clipping, you can adjust the level by using this function.
  • Trigger Key This is one of the methods of sampling that I mentioned earlier. You can set the trigger key to any key on the keyboard, say C4, and when you hit C4 on your keyboard the sampler activates (gets triggered) and starts to sample.
  • Arm This puts the sampler into standby mode and when it hears a signal, it starts to sample. This is usually used in conjunction with the threshold. The threshold sets the level at which you want the sampler to be triggered when in arm mode. The real advantage of this is to eliminate noise. If you set the threshold above the noise level and then play the sound, the sampler will only start to record at the threshold level setting, in this case, above the noise, as the noise is below the threshold level. The threshold/arm combination is also useful when you want to sample a sound that is above the general level of the piece of audio being sampled, an example of this would be to sample a loud snare that is above the rest of the audio piece. If you set the threshold to just below the level of the snare, the sampler ignores everything below that level and automatically records the snare.
  • Force or Manual This simply means that you press a button to start the sampler recording.

Those are the general functions available on most samplers, to do the actual sampling/recording. Now we need to look at the tools available when you press stop or complete the recording of the sound.

When you press stop, a new page appears and you are given a bunch of options. Here are the general options that are offered to you.

  • Dispose or Keep This just means you can either dump the sample, if it was no good, or keep it.
  • Place This allows you to place the sample anywhere on the keyboard you want and within this option, you will have a range you can set. The range is displayed as Low and High. Let’s say I sample a C3 bass note off a synthesizer, I can then place it at C3 on my keyboard and set the low to A2 and the high to D#3. I have not placed the note and set it a range on my keyboard. This saves me loads of time and effort in having to do it later. This placing and range setting are stored in the preset, so, in effect, I am creating and building my preset as I am sampling, instead of having to sample all the notes then go back into the preset and start placing and setting ranges. Much easier. With a drum loop, you can do the same thing and by setting the range, it gives you different pitch choices of the drum loop as the sample pitches down when setting the low range value, and pitches up when setting the high range value. For single drum shots, I would place and set the ranges at the placed note. So, a kick would be placed on C1 and the low range value would be set to C1 and the same for the high range value. I now have a kick on C1.
  • Truncate Some samplers have auto-truncate and manual truncate. Truncate, also called trim or crop, is a function used to cut data before and after the sampled data. This can cut/delete space or sound before or after the sample or can be used to cut/delete any portion of the sample. Auto-truncate simply removes everything before and after the sample.
  • NormalizeorNormalise This is a topic that has ensured some fiery debates and I doubt it will ever get resolved. Basically normalising a sample means that you raise the volume of the sample to the peak of the headroom. If, for example, you were normalising a sample to 0dB, then that means the process takes the highest peak/s in the sample data and raises them to 0dB, in this way, the loudest peak hits 0dB. This is called Peak (or absolute) normalising. By raising the highest peak you also raise the entire sample data, this has the disadvantage of raising the noise floor as well, as all data is raised till the peak hits 0dB. To normalise an audio file to ensure a certain level of perceived loudness, you need to normalise to an RMS (or relative) value of dB, rather than peak. RMS is, roughly, the average volume over a given time, rather than just the highest peak/s. It calculates the average peaks and raises those to 0dB. The disadvantage of RMS normalising is that by raising the average data peaks, you incur clipping, not always, but usually. So, in this instance, a good normalising plugin will compress or limit at the same time as normalising, so the levels do not exceed 0dB and thus, prevent clipping. I have always maintained that if you have a strong signal, with good dynamic movement, that does not clip and stays just under 0dB, then you are far better off than normalising to 0dB. Of course, there are instances where normalisation can be your friend, but in most cases, it can cause additional side effects that are not needed. These include killing any headroom that was there, raising the noise floor so noise is also now more pronounced and evident, and to top it all off, you can get roundness in the shape of the peaks and even slight distortion or phasing. So, use this function sensibly.

Now you have your sample recorded, placed, truncated, normalised etc, you need to look at the tools available to edit and process the sample.

By selecting ‘edit sample’ you are presented with the sample and a host of tools you can use to edit and process the sample. Let us look at these briefly and then, when we come to the bigger topics, we will get a little more in-depth.

  • Zoom +- This is like a magnifying tool that allows you to zoom in, or magnify, a portion of a sample.
  • Start End Size Here, you have the start and end of the sample represented in cycles and, in some samplers, in time. The size tells you the size of the sample. This might not seem important now but the size of the sample is important when working out and retuning the sample or changing the sample rate. Don’t worry, we will tackle that later.
  • Loop This is a crucial function and is the essence of what a sampler really does. The whole concept of looping is actually a simple one, whether it’s for memory saving or for creating sustained instrument sounds, the process is invaluable. What is difficult is how to find good loop points, and there are a number of reasons why this can seem complex. Firstly, unless the shape of the sample at the beginning, during and end of the loop matches up in level, shape, and phase, you will have problems in finding a clean loop point. The most common enemy here is click. The best way to avoid clicks is to find what we call the ‘zero-crossing’ point. This is where the sample’s shape crosses over from the positive axis to the negative axis. At the point where the shape crosses the axis, we have a zero point. Looping at zero points eradicates the problem of clicks. But, if the shape and level don’t match up well, you will still get a click. So we are still left with a problem. What does this tell us? It tells us that the sample length being looped must be consistent, both in terms of shape and level, but also in terms of length. Too long a sample loop length and you encounter modulation. Why? Because the sample has an attack and decay. If you start your loop point too close to the attack and your endpoint too near the decay, you are then left with a shape that starts high and drops to a lower level, this causes the loop to modulate or wobble up and down. The opposite is also true. All sounds have a harmonic structure and if your loop length is too small then the harmonics of the sound are compromised since you are looping a very small instance of the sample, you are, in effect, cutting the harmonics up. This will give you an unnatural loop in that it will sound very synthesized. That’s ok if you are sampling synthetic sounds but not if you are trying to loop a natural instrument sound. The final problem you are faced with is pitch. If you loop the wrong are of the sample, then it might not be in the right pitch of the original signal that was being sampled. A C3 string note will not stay at exactly C3 but move through the harmonics, so if you looped the wrong harmonic, the sample might show up as C3 +3 or worse, ie it is 3 cents off the right pitch. You need to select the most consistent part of the sample to attain the right loop points and loop length. This, unfortunately, takes practice and experience. This leads me subtly to the next function.
  • Auto Correlation Some samplers provide this function when you are looping. Basically what this function does is, after you have set your loop points, it searches for the next best loop point that it thinks will give you the best loop. Not always accurate but useful to use if you are completely off target. However, we do have another weapon at our disposal if the loop still throws up a click.
  • Crossfade Looping This technique involves fading out the end of the loop and overlapping it with a fade-in of the start of the loop, and it’s a facility provided by virtually all samplers. By fading in these points, you get a smoother transition on the loop points, start and end. I only recommend using this when you have got really close to finding the right loop point and length, as it is a nice little tool and is just a polisher and not a tool to remedy bad loop points and lengths. If you had a very bad loop and it was glitching heavily, then using this tool would only make the sound unnaturally modulated, without any consistent shape. So, it’s not for error correction but for polishing off the tiny click that might be barely audible.
  • DC offset Any waveform that isn’t symmetrical around the zero axis has a DC offset. DC offset is when there is too large a DC (direct current) component in the signal, sometimes visible as the signal not being visually ‘centered’ around the ‘zero level axis’. DC offsets do not affect what you actually hear, but they affect zero-crossing detection and certain processing, and it is recommended that you remove them. That’s the technical, but short, definition. Basically, always remove the DC offset on a sample. This will help you find zero-point crossings. This is a whole debate in itself and there are arguments raging on both sides of the fence and arguments based around the algorithms used in DC offsetting tasks. You don’t need to even think about getting involved in this debate. What you do need to know and do is to remove the DC offset on a sample and you are usually given a tool in the menu option to do this. The DC offset removal is actually called the DC filter, for those who want to know. Try experimenting, as always.

Relevant content:

RIAA Amps and Standards

Preparing to Sample – Using hardware samplers!

Preparing and Optimising Audio for Mixing

Normalisation – What it is and how to use it

Topping and Tailing Ripped Beats – Truncating and Normalising