<?xml version="1.0" encoding="ISO-8859-15"?>
<!-- DOCTYPE presentation SYSTEM "DTD/presentation.dtd"-->
<!DOCTYPE presentation [
	<!ENTITY % HTMLsymbol SYSTEM "DTD/xhtml-symbol.ent">
	%HTMLsymbol;
]>
<?xml-stylesheet href="presentation.css" type="text/css"?>


<presentation xmlns:html="http://www.w3.org/1999/xhtml">
	<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
        	xmlns:dc="http://purl.org/dc/elements/1.1/">

        <rdf:Description about="">

                <dc:title>Audio Engineering in a Nutshell</dc:title>
                <dc:creator>Steve Harris &lt;S.W.Harris@ecs.soton.ac.uk&gt;, Jörn Nettingsmeier &lt;nettings@folkwang-hochschule.de&gt;</dc:creator>
                <dc:contributor></dc:contributor>
                <dc:publisher></dc:publisher>
                <dc:subject></dc:subject>
                <dc:description></dc:description>
                <dc:date></dc:date>
                <dc:type></dc:type>
                <dc:format>text/xml</dc:format>
								<dc:identifier></dc:identifier>
                <dc:language>en</dc:language>
                <dc:relation></dc:relation>
                <dc:coverage></dc:coverage>
                <dc:rights></dc:rights>

        </rdf:Description>

	</rdf:RDF>

<!--
in-depth introductory audio engineering and digital signal processing
=====================================================================


2 x 1 hr with one hour lunch break in between.


(aimed at people new to home recording and/or digital audio with little theoretical background but some practical experience)


presented by steve harris (the dsp side of things) and
jörn nettingsmeier (the analog domain :)


each of the sections introduces their basic concepts by looking at and explaining the working of analog gear.
we then proceed to its digital counterpart.
at the end of each section, we offer some usage tricks for practical work.
-->
<section>
	<note>Use 'b' to switch to/from presentation mode, PgUp and PgDown to switch slides</note>
	<section>
	<h>Audio Engineering in a Nutshell</h>
	<slide>
		<h>Audio Engineering in a Nutshell - Or: The next two hours of your life</h>
		<ol>
			<li>Basics: the nature of Sound and its representation
				<ul>
					<li>Sound and hearing</li>
					<li>Analog signals</li>
					<li>Digital signals</li>
				</ul>
			</li>
			<li>Basic digital operations</li>
			<li>Controlling timing: delays</li>
			<li>Controlling spectrum: equalization</li>
			<li>Controlling dynamics: compressors/expanders</li>
			<li>Space and spatialization</li>
		</ol>
		<line>Steve Harris &lt;S.W.Harris@ecs.soton.ac.uk&gt;</line>
		<line>Jörn Nettingsmeier &lt;nettings@folkwang-hochschule.de&gt;</line>

	</slide>
	<slide>
		<h>A word of warning</h>
		<line>This talk is absolutely packed. We will flood you with information.</line>
		<line>For two hours straight.</line>
		<line>Except there's the lunch break. :-D</line>
		<line>And there will even be Maths.</line>
		<line>Three things will help you survive:</line>
		<ol>
			<li>We'll start at the very beginning.</li>
			<li>You will be able to ask questions after each section, and possibly get answers.</li>
			<li>We'll explain everything twice, first from the analog point of view (Jörn), then from the digital (Steve).</li>
		</ol>
		<line>Note: Another general-purpose q &amp; a session is planned at the end, so if your question does not relate to the current topic, please hold it until later.</line>
	</slide>
  </section>

  <section>
	<h>Basics: The nature of sound and its representation</h>
  </section>

	<section>
		<h>Sound and hearing</h>

			<slide>
			<h>Sound waves</h>
			<line>Sound is <keyword>pressure waves</keyword> travelling through a <keyword>medium</keyword>.</line>
			<html:object data="graphics/sound-pressure-waves-400.png" float="left">
				pressure waves
			</html:object>
			<line>Sound waves consist of alternating high and low pressure zones.</line>
			<line>These zones oscillate in the direction of travel (a <keyword>longitudinal wave</keyword>)</line>
			<line>Sound waves travel through air at approx. 340 m/s (<keyword>v<index>0</index></keyword>, depending on temperature and humidity.</line>
			<line>The oscillating speed of sound is called the <keyword>frequency f</keyword>, measured in cycles per second or <keyword>Hertz [Hz]</keyword>.</line>
			<line>The combined length of one high- and one low-pressure zone is called the <keyword>wavelength &#955;</keyword>.</line>
			<line>We find: <formula>&#955; = v<index>0</index> / f</formula></line>
		</slide>

		<slide>
			<h>Hearing</h>
			<line>We detect sound with our ear-drums. Like a microphone diaphragm, they move along with the pressure waves.</line>
			<line>The softest sound humans can hear corresponds to an air pressure change of only 0.00002 Pa (Pascal). (The normal air pressure on earth is 102,300 Pa.)</line>
			<line>The loudest sound we can endure has a pressure change of 200 Pa.</line>
			<line>Our hearing range covers <strong>10 orders of magnitude</strong> of intensity!</line>
			<note>If it were one order more sensitive, we would almost be able to hear the air molecules bouncing off each other.</note>
			<line>The audible frequency range reaches from from 20 Hz to 20 kHz. The upper bound moves down with age.</line>
			<html:object data="graphics/warning-50.png" float="left">Watch out!</html:object>
			<line>We perceive frequency as <keyword>pitch</keyword>, in a <keyword>logarithmic</keyword> fashion: pitch intervals are <keyword>ratios</keyword> of frequencies, not <keyword>differences</keyword>.</line>
			<line>The range from a given frequency to twice that frequency is called an <keyword>octave</keyword>.</line>
		</slide>

		<slide>
			<h>Signal levels, or: The dreaded Decibel...</h>
			<line>To compute a <keyword>sound pressure level L</keyword>, a given pressure p is first normalized to a <keyword>reference</keyword>: our hearing threshold <keyword>p<index>0</index></keyword> (0,00002 Pa).</line>
			<line>Because of the huge range of pressures we can perceive, the value is then log'ed to make it more manageable: <formula>L<index>p</index> = 20 log p / p<index>0</index></formula> The unit of L<index>p</index> is dB SPL, or "Decibel Sound Pressure Level".</line>
			<line>For signals, we choose a <keyword>reference voltage u<index>0</index></keyword> of either 1V or 0.775V: <formula>L<index>u</index> = 20 log u / u<index>0</index></formula> The unit of L<index>u</index> is dBV (for 1V) or dBu (for 0.775V).</line>
			<line>With dB's, a change of +6dB indicates roughly twice the level, -6dB is about half the level.</line>
	  	<html:object data="graphics/warning-50.png" float="left">Watch out!</html:object>
			<line>Note that the Decibel is not an absolute measure, but a <strong>ratio</strong>, and that it is meaningless without a <keyword>reference</keyword>!</line>
		</slide>

	</section>

	<section>
		<h>Analog Signals</h>

		<slide>
			<h>From wave to signal</h>
			<line>A microphone diaphragm is moved back and forth by the pressure changes.</line>
			<line>Attached to it is a coil within a magnetic field.</line>
			<line>When it moves, an electric signal is <keyword>induced</keyword> in the coil.</line>
			<html:object data="graphics/speaker-microphone-signal.png">
				Illustration sound wave -> dynamic microphone -> voltage.
			</html:object>
			<line>The voltage changes with the speed and direction of the diaphragm movement.</line>
			<line>Ideally, the signal is a perfect and complete representation of the sound.</line>
		</slide>

		<slide>
			<h>Audio Signals</h>
			<html:object data="graphics/annotated_scope.png" float="left">
				an audio signal graph annotated with the introduced terms
			</html:object>
			<line>Audio signals can be visualized with an oscilloscope.</line>
			<line>It displays <keyword>voltage U</keyword> vs. <keyword>time t</keyword>.</line>
			<line>This is called the <keyword>time domain</keyword> view.</line>
			<line>The strength of the signal at any one time is called <keyword>amplitude</keyword> and roughly corresponds to <keyword>loudness</keyword>.</line>
			<line>Most audio signals are periodic - they follow a repeating pattern.</line>
			<line>One <keyword>period</keyword> is the section between three adjacent <keyword>zero crossings</keyword>.</line>
			<line>The signal's <keyword>frequency f</keyword> (in <keyword>Hertz</keyword>) is the number of such periods per second. It corresponds to <keyword>pitch</keyword>.</line>
			<line>The points of maximum amplitude are called <keyword>peaks</keyword>.</line>
		</slide>

		<slide>
			<h>Sine waves (1)</h>
			<html:object data="graphics/sine-400.png" float="right">
				a sine wave
			</html:object>
			<line>The most fundamental sound phenomenon is the <keyword>harmonic oscillation</keyword>.</line>
			<line>It produces just one single pitch. <html:a href="audio/sine-a1-2sec.wav">sine@440Hz</html:a></line>
			<line>In the time-domain view, it looks like a <keyword>sine</keyword> function.</line>
			<html:object data="graphics/two-sines-and-sum-400.png" float="left" clear="both">
				two sine waves, a fifth apart, and their result.
			</html:object>
			<line clear="right">Sine waves can be mixed into complex sounds.</line>
			<line>The amplitudes of the components at any one time add up to the result.</line>
			<line>
				<html:a href="audio/sine-e2-2sec.wav">sine@659.255Hz</html:a>,
				<html:a href="audio/sine-a1+e2-2sec.wav">both</html:a>
			</line>
			<note>It's a tempered fifth, thus the slight beat. The perfect fifth would of course have an upper frequency of 660 Hz and no beat at all.</note>
		</slide>

		<slide>
			<h>Sine waves (2)</h>
			<html:object data="graphics/two-in-phase-sines-and-sum-400.png" float="right">
				two sine waves of the same frequency, in phase, and their result
			</html:object>
			<line>Identical waves can amplify each other:</line>
			<html:object data="graphics/two-sines-out-of-phase-and-sum-400.png" float="left" clear="both">
				two sine waves of the same frequency, out of phase, and their result
			</html:object>
			<line clear="right">Or they can cancel each other out, depending on their relative position:</line>
			<line clear="both">This relative position is called the <keyword>phase &#966;</keyword>.</line>
		</slide>

		<slide>
			<h>Detour: balanced connections</h>
			<div>
			<line>Professional <keyword>balanced</keyword> audio cables have three wires.</line>
			<html:object data="graphics/balanced-connection-600.png" float="right">
				balanced connection with waveforms on each wire, noise comes in and is cancelled out at the input stage
			</html:object>
			<line>Pin 1 (screen) is the shielding foil or braid and is grounded.</line>
			<line>Pin 2 (hot) carries the audio signal.</line>
			<line>Pin 3 (cold) carries the inverted audio signal (180° out of phase).</line>
			</div>
			<line clear="both">When electro-magnetic fields interfere with the cable, both hot and cold wires pick them up the same way.</line>
			<line>At the input stage, the cold signal is inverted again and added to the hot.</line>
			<line>Since they are back in phase, they amplify each other.</line>
			<line>But the two halves of the noise are out-of-phase now - when added, they cancel out.</line>
		</slide>

		<slide>
			<h>Sine waves (3): analysis</h>
			<html:object data="graphics/spectrogram-vowel-a-400.png"  float="right">
				spectrogram of sung vowel "ah"
			</html:object>
			<line>Any periodic sound is composed of sine waves:</line>
			<line>The <keyword>fundamental frequency</keyword> determines the <keyword>pitch</keyword>. The <keyword>overtones</keyword> or <keyword>harmonics</keyword> affect the <keyword>timbre</keyword> ("sound").</line>
			<line>The sine components of a complex sound can be found with a <keyword>spectrum analyser</keyword>.</line>
			<line>A <keyword>spectrogram</keyword> plots intensity vs. frequency.</line>
			<line>This is called the <keyword>frequency domain view</keyword>, as opposed to the <keyword>time domain view</keyword> of the oscilloscope.</line>
		</slide>

		<slide>
			<h>Sine waves (3): analysis (cont'd)</h>
			<html:object data="graphics/noise-waveform.png" float="right">
				Noise viewed in a spectrum analyzer
			</html:object>
			<line><keyword>Noise</keyword> has a <keyword>non-periodic</keyword> waveform.</line>
			<line>It is not composed of a few distinct sine waves, but of an infinite number of arbitrarily close ones. The noise spectrum is continous, without any discernible overtones.</line>
			<html:object data="graphics/noise-white-300.png" float="left">
				White noise viewed in a spectrum analyzer
			</html:object>
			<line><html:a href="audio/noise_white.wav"><keyword>White noise</keyword></html:a> contains all frequencies with equal loudness, i.e. the octave from 10 kHz to 20kHz contains as much energy as all the other octaves below.</line>
			<line>Since humans perceive pitch logarithmically, white noise sounds very bright with exaggerated treble.</line>
			<html:object data="graphics/noise-pink-300.png" float="left" clear="both">
				Pink noise viewed in a spectrum analyzer
			</html:object>
			<line>To accomodate for this, low-pass-filtered white noise is used for acoustic measurements. It is called <html:a href="audio/noise_pink.wav"><keyword>pink noise</keyword></html:a> and contains a constant amount of energy per octave.</line>
		</slide>

		<slide>
			<h>Sine waves (3): analysis (cont'd)</h>
			<html:object data="graphics/sonogram-ah-eh-ee-oh-oo-f-s-sh-p-t-k.png" float="right">
				sonograms of sung vowels "ah", "eh", "ee", "oh", "oo", sibilants "f", "s", "sh" and plosives "p", "t", "k"
			</html:object>
			<line>A <keyword>sonogram</keyword> displays intensity (color) vs. time (y-axis) vs. frequency (x-axis). When running, it scrolls up as time passes.</line>
			<line>Here are some speech sounds: sung vowels at the same pitch, sibilants and plosives.</line>
			<line>Note the identical fundamental and distinct harmonics of the vowels, and the noisy spectrum of the consonants.</line>
		</slide>

		<slide>
			<h>Sine waves (4): synthesis</h>
			<line>New sounds can be generated by adding sine waves of different <keyword>frequency</keyword>, <keyword>amplitude</keyword> and <keyword>phase</keyword>. This is called <keyword>additive synthesis</keyword>.</line>
			<html:object data="graphics/wave-square-300.png" float="right">
				square wave
			</html:object>
			<html:object data="graphics/spectrum-square-300.png" float="right">
				square wave spectrum
			</html:object>
			<line><html:a href="audio/wave-square.wav"><keyword>square wave</keyword></html:a>, only odd harmonics, slow rolloff</line>
			<html:object data="graphics/wave-tri-300.png" float="left" clear="both">
			</html:object>
			<html:object data="graphics/spectrum-triangular-300.png" float="left">
				triangular wave spectrum
			</html:object>
			<line clear="right"><html:a href="audio/wave-triangular.wav"><keyword>triangular wave</keyword></html:a>, only odd harmonics, fast rolloff</line>
			<html:object data="graphics/wave-saw-300.png" float="right" clear="both">
				sawtooth wave
			</html:object>
			<html:object data="graphics/spectrum-sawtooth-300.png" float="right">
				sawtooth wave spectrum
			</html:object>
			<line clear="left"><html:a href="audio/wave-sawtooth.wav"><keyword>sawtooth wave</keyword></html:a>, all harmonics (bowed instruments)</line>
			<line clear="both"><html:a href="http://users.ece.gatech.edu/~bonnie/book/OnlineDemos/ConvergenceOfFourierSeries/SquareWave/BIN/applet.html">Fourier approximation of a square wave</html:a>, <html:a href="http://users.ece.gatech.edu/~bonnie/book/OnlineDemos/ConvergenceOfFourierSeries/TriangularWave/BIN/applet.html">Fourier approximation of a triangular wave</html:a></line>
		</slide>


		<slide>
			<h>Problems with analog signals: noise and clipping</h>
			<line>There are many sources of noise in analog signal processing:</line>
			<ul>
				<li>All electronic components produce <keyword>thermal noise</keyword> through the jiggling of their atoms (<keyword>Brownian motion</keyword>).</li>
				<li>Cables pick up noise via electro-magnetic interference (induction or capacitive coupling).</li>
				<li>Analog media introduce additional noise (<keyword>tape hiss</keyword> or <keyword>vinyl crackle</keyword>).</li>
			</ul>
			<line>Analog signal stages will <keyword>clip</keyword> the signal if the amplitude is too high, producing <keyword>distortion</keyword>.</line>
			<html:object data="graphics/clipping-transfer-function-400.png" float="right">
				graph: a sine comes in from -y and bounces off a non-linear transfer function in +x direction
			</html:object>
			<line>A clipping stage can not follow the input signal, and flattens out the peaks of the wave.</line>
			<line>The result now resembles a square wave.</line>
			<line>Clipping generates new harmonics, which produce the typical distorted sound.</line>
			<line clear="both">Both noise and clipping <strong>cannot be undone</strong>. Noise reduction and peak reconstruction are lossy processes.</line>
		</slide>

		<slide>
			<h>Problems with analog signals: dynamic range</h>
			<line>Audio systems are bounded between the <keyword>noise floor</keyword> and the clipping level.</line>
			<line>The usable room between those boundaries is the <keyword>dynamic range</keyword> or <keyword>signal-to-noise ratio (S/N)</keyword> of a system.</line>
			<line>The human ear has a dynamic range of about 120dB from hearing to pain threshold.</line>
			<line>Studio-grade analog tape recorders achieve 70dB S/N, consumer machines are a lot worse.</line>
			<line>Therefore, care must be taken to always fully exploit the available range.  Analog signals should always be kept as hot as possible without clipping.</line>
		</slide>

		<slide>
			<h>Questions?</h>
		</slide>

	</section>

  <section>
    <h>Digital Signals</h>

    <slide>
      <h>Continous v's. discrete signals</h>
      <html:object data="graphics/pcm.png">PCM waveform example</html:object>
    </slide>

    <slide>
      <h>Sampling (AD Conversion)</h>
      <line>Turning the analogue signal representation into digits</line>
      <line>Most commonly used encoding in software is <keyword>Pulse Codule Modulation</keyword> (PCM)</line>
      <ul>
	<li>Represented as impulses <em>n</em> times per second - a <keyword>pulse train</keyword></li>
	<li><em>n</em> is the sample rate</li>
	<li>Amplitude of the impulse is measured by passing the signal through a lowpass filter</li>
      </ul>
      <html:object data="graphics/sampling.png">AD conversion circuit</html:object>
    </slide>

    <slide>
      <h>Nyquist criterion and aliasing</h>

      <line>Nyquist criterion states that in order to be correctly sampled, all components of the signal must at less than half the sample rate</line>
      <line>Any compenents at a frequency at or over the nyquist frequency will appear as "aliased" components when converted to PCM</line>
      <html:object data="graphics/aliasing.png">Aliasing example</html:object>
      <line>Trying to PCM endode a signal at 21kHz that contains components obove 10.5kHz</line>
    </slide>

    <slide>
      <h>Why does aliasing do that?</h>

      <html:object data="graphics/aliased-sin.png">sinewave + aliased samples</html:object>
      <line>Sinewave at about 0.9 x the sampling frequency (1.8 x nyquist frequnecy)</line>

      <html:object data="graphics/aliased-sin-nowave.png">aliased samples</html:object>
      <line>Samples shown without wave</line>
      <line>Aliasing results in a sinewave appearing at a lower frequency</line>
    </slide>

    <slide>
       <h>Anti-aliasing filters</h>

       <line>The best thing to prevent aliasing would be a bricakwall lowpass filter:</line>
       <html:object data="graphics/brickwall.png">Brickwall filter freq-response</html:object>
       <line>In practice you can't get a response that good, but its the ideal</line>
    </slide>

    <slide>
      <h>Reconstrunction (DA Conversion)</h>

      <line>In theory the PCM data can be turned back into an anlogue signal by passing the impulse train through a lowpass filter</line>
      <html:object data="graphics/da.png">Impulse train from PCM data</html:object>
      <html:object float="left" data="graphics/da-interpolated.png">Analogue signal reconstructed from impulse train</html:object>
      <comment>The ideal filter would be the same brickwall filter we'd like for anti aliasing.</comment>
      <line>The reconstruction here was done using a filter thats very close to that</line>
    </slide>

    <slide>
      <h>Problems: aliasing</h>

      <line>Even though the analogue signal will have been antialiased on the way in it is still possible for aliasing to be created by processing</line>
      <line>This can happen if some processing causes the frequency compenents to be shifted below 0 or obove the Nyquist frequency</line>
      <line>Or if the PCM data is treated as if it were continuous in synthesis:</line>
      <html:object data="graphics/bad-saws.png">Naive PCM saw wave and the reconstructed wave</html:object>
      <line>If the signal is built up from sinewaves, all below the Nyquist freuency then the signal will look a bit odd in PCM form, but will reconstruct to something that sounds like a saw wave</line>
      <note>Once the signal as becomes aliased like this its not possible to recover the intended signal, as theres no way to distinguish the alised components of the PCM data from the intended ones.</note>
    </slide>

    <slide>
      <h>Quantisation</h>

      <line>Quatisation is the approxiation of the level of the analogue signal
to the most appropraite digital representation, eg. a 4 bit (16 level) sample of an arbitrary signal is quantised as:</line>
      <html:object data="graphics/noise-quantised.png">A 4 bit noise signal</html:object>
    </slide>

    <slide>
      <h>Problem: quantisation noise</h>

      <html:object float="right" data="graphics/noise-quantised-closeup.png">Quantisation</html:object>
      <comment>The quantised signal does not match the original curve exactly, some points are over, and some are under</comment>
      <line />
      <html:object float="left" data="graphics/quantisation-noise.png">Quantisation noise</html:object>
      <comment>The differenece between the source signal and the quantised one will be percieved as noise on top of the wanted signal:</comment>
      <html:a href="audio/ca2s.wav">source sine wave</html:a>,
      <html:a href="audio/ca2s-4bit.wav">4 bit sine wave</html:a>,
      <html:a href="audio/ca2s-qnoise.wav">quantisation noise</html:a>
      <line />
      <note>The quantisation noise from the sine wave contains aspects of the oringal sine, I'l come to why later...</note>
    </slide>

    <slide>
      <h>Interpolation</h>

      <line>To reconstruct a discrete signal we can lowpass filter it with a brickwall lowpass filter, so it makes sense we can do the same to interpolate</line>
      <line>We can get a brickwall filter by replacing every impulse in the descrete signal with the <keyword>"sinc"</keyword> function:</line>
      <html:object float="left" data="graphics/sinc.png">Sinc waveform</html:object>
      <html:object data="graphics/sinc-eqn.png">sinc(x) = sin(pi x) / (pi x)</html:object>

      <comment>The only problem with this is that the sinc function is infitinly wide, so we have to approiximate it</comment>

    </slide>

    <slide>
      <h>Interpolation (2) When do you need sinc</h>

      <html:object float="left" data="graphics/hf-sin.png">PCM data for highfreq sine wave</html:object>
      <html:object float="left" data="graphics/hf-sin-lin.png">linearly interpolated</html:object>
      <line>The original PCM data doesnt look like much, and linearly interpolating it just gives rubbish</line>
      <line clear="left" />

      <html:object float="left" data="graphics/hf-sin-sinc.png">Sinc waveform</html:object>
      <line>But when sinc interpolated it can clearly be seen as a sinewave</line>
    </slide>

    <slide>
      <h>Interpolation (3) Example stages of sinc interpolation</h>

      <html:object float="left" data="graphics/hf-sin-1pt.png">Sinc waveform</html:object>
      <html:object float="left" data="graphics/hf-sin-2pt.png">Sinc waveform</html:object>
      <comment>Sinc waveforms are progressivly added inplace of the impulses</comment>
      <html:object float="left" data="graphics/hf-sin-3pt.png">Sinc waveform</html:object>
      <html:object data="graphics/hf-sin-4pt.png">Sinc waveform</html:object>
      <line>This process is called <keyword>convolution</keyword></line>
    </slide>

    <slide>
      <h>Problem: intermodulation distortion</h>

      <line>A 4 bit sample of a generated sine wave appears as:</line>
      <html:object data="graphics/4-bit-sin.png">A 4 bit sine wave</html:object>
      <html:object float="left" data="graphics/intermodulation-distortion.png">Quantisation noise</html:object>
      <comment>Note that the quantisation noise from the sinewave contains regularly repeating signals.</comment>
    </slide>

    <slide>
      <h>Dither</h>

      <line>Dither is a way of masking the intermodulation distortion, a small ammount of noise is added to the signal before its truncated</line>
      <html:object data="graphics/4-bit-sin-dither.png">A dithered 4 bit sine wave</html:object>
      <line>This makes the signal noisier (hurts the SNR), but makes the intermodulation distortion even whitenoise, unrelated to the source signal and so less anoying</line>
    </slide>

    <slide>
      <h>Dither (2)</h>

      <line>This is a 1k Hz sine wave at -40dB's truncated to 8 bits, both undithered and dithered</line>
      <html:object data="graphics/1k-sin-8bit.png">A dithered 1kHz sine wave at -40dB, dithered and undithered</html:object>
      <line>The graph on the left shows the intermodulation distortion caused by the truncated, undithered signal</line>
      <line>The graph on the right shows the lack of distortion, but reduced signal to noise ratio</line>
      <line><html:a href="audio/1k-sin.wav">undithered sine</html:a>, <html:a href="audio/1k-sin-dithered.wav">dithered sine</html:a></line>
    </slide>

    <slide>
      <h>Aside: equal loudness curves</h>
      <html:object data="graphics/fletcher-munson.png">The Fletcher-Munson equal loudness curves</html:object>
      <line>These curves show signals of equal "loudness" (i.e. perceived volume)</line>
      <line>They are known as the <keyword>Fletcher-Munson</keyword> curves</line>
      <line>They indicate how loud a sinewave at a particular frequency will sound, compared to a sinewave at another frequency</line>
      <h></h>
      <line>This is relevant to dithering...</line>
    </slide>

    <slide>
      <h>Triangular dithering</h>

      <line>As the high frequencies are percieved less strongly by passing the noise through a gentle high pass filter and amplifiying it so it has the same ammount of energy we can still mask the distortion, but make the noise less "loud"</line>
      <html:object float="left" data="graphics/1k-sin-8bit-tri.png">triangular dithered freq graph</html:object>
      <line>The peak noise is higher - but that peak is around 20kHz where human hearing is not very sensitive.</line>
      <line>Around the crucial 1-4kHz mark the noise floor is lower (by about 5dB's) so we get more audible detail.</line>
      <line>This is called <keyword>triangular dithering</keyword> because the noise floor slopes upwards.</line>
      <line clear="left"><html:a href="audio/1k-sin-dithered.wav">rectangular dithered sine</html:a>, <html:a href="audio/1k-sin-dithered-tri.wav">triangular dithered sine</html:a></line>
      <line>Note this only works with audio, and only if you're not going to mess about with the frequency components afterwards, as its a psychoacoustic trick</line>
    </slide>

		    <slide>
      <h>Questions?</h>
    </slide>

  </section>


<section>
	<h>Basic signal operations</h>

	<slide>
		<h>Mixing</h>

		<line>Mixing audio is just the &#8721; operation, i.e. +</line>
		<line>So to mix signals x1[] and x2[] into y[] we simply do:</line>
		<html:pre>
for (i=0; i&lt;length; i++) {
	y[i] = x1[i] + x2[i];
}
		</html:pre>
		<line>Every time you add a channel the theoretical peak value doubles (if the peaks of the two signals are the same)</line>
		<line>You can divide by the number of channels to guarantee no clipping, but then the volume will appear to go down as the number of chanels increases</line>
	</slide>

	<slide>
		<h>Gain</h>

		<line>Amplifying/attenuating audio is just the &#8719; operation, i.e. *</line>
		<line>So to attenuate x[] by 20dB (-20dB gain) into y[] we simply do:</line>
		<html:pre>
for (i=0; i&lt;length; i++) {
	y[i] = x[i] * 0.1;
}
		</html:pre>
		<line>Gain is usally expressed in dB's, relative to a gain of 1.0 (unity) so we can do:</line>
		<html:pre>
double coefficient = pow(10.0, gain / 20.0);

for (i=0; i&lt;length; i++) {
	y[i] = x[i] * coefficient;
}
		</html:pre>
	</slide>

	<slide>
		<h>Pan</h>

		<line>Pannning is apply gain to a/sum channels to make them appear to come from somewhere between a set of speakers</line>
		<html:object data="graphics/pan-linear.png" float="right">linear gain pan</html:object>
		<line>The simple case is for a single channel to be panned between two speakers</line>
		<line>We want to maintain an equal power as the signal pans between the speakers, to avoid the dead spot if we do the naive thing of fading linearly between 0 at one end and 1.0 at the other</line>
		<html:object data="graphics/pan-const-power.png" float="left">constant power pan</html:object>
		<line>Constant power pan however try to retain a constant power aproximation (left^2 + right^2) to avoid the "dead spot"</line>
		<line><html:a href="audio/pan-linear.wav">linear pan</html:a>, <html:a href="audio/pan-const-power.wav">constant power pan</html:a></line>
	</slide>

	<slide>
	  <h>Delay</h>

	  <line>Another fundamental operation on digital signals is delay</line>
	  <line>Memory and delay are the same thing</line>
	  <line>Simply storing samples and getting them back later</line>
	  <line><html:object data="graphics/delay.png">delay</html:object></line>
	</slide>

	<slide>
	  <h>Phase shift</h>

	  <line><html:object float="right" data="graphics/1st-order-lp.png">1st order lowpass filter</html:object></line>
	  <line>From the block diagram or euqation you can see that part of the signal that makes up the output signal comes from back in time</line>
	  <line>The delay in time varies with the frequnecy of the input signal</line>
	  <line>This is known as <keyword>phase shift</keyword>. Its not possible to have a filter that does not cause phase shift, but it is possible to make the phase shift equal for all frequencies</line>
	  <line>Because the delay varies with frequency this means that filtering can cause different partials of the signal to become misaliged with each other in time. It's rarely a problem, and sometimes it's a desirable side-effect of filtering</line>
	</slide>

</section>

<section>
	<h>Controlling timing (delays)</h>

	<slide>
		<h>Delays (1): terms</h>
		<line>There are two meanings to the word <keyword>timing</keyword>:</line>
		<ul>
			<li>the <keyword>time feel</keyword> in the musical sense; whether the music is "sloppy" or "tight" and "ahead" or "laid-back";</li>
			<li>the way different sound sources <keyword>coincide</keyword>.</li>
		</ul>
		<line>Both can be manipulated by delay stages. Manipulating the first is purely <keyword>creative</keyword> (i.e. a matter of taste), while the second is <keyword>corrective</keyword> and needs to be done precisely right.</line>

	</slide>

	<slide>
		<h>Delays (2): Correlated signals</h>
		<line>Signals are said to be <keyword>correlated</keyword> if there is a fixed-phase relationship between them. This usually means they came from the same source at some time.</line>
		<line>Correlated signals can be <keyword>misaligned</keyword>. This happens in a number of situations:</line>
			<ul>
			<li>many microphones are used for a large band, and each player is picked up both by their own and their neighbour's microphones (which are farther away);</li>
			<li>a single microphone picks up both direct and reflected sound (which takes a little longer);</li>
			<li>a signal is combined with a very short delay effect;</li>
			<li>a huge P.A. system uses speaker clusters at different distances to the listener.</li>
		</ul>
		<line>When correlated but misaligned signals are mixed, there will be <keyword>interference</keyword>. They can be realigned with corrective delay.</line>
		<line>Uncorrelated signals can always be mixed together without artifacts: we are free to use creative delays as we please.</line>
	</slide>

	<slide>
		<h>Delays (3): The comb-filter effect</h>
		<html:object data="graphics/wave-sawtooth+combfiltered-300.png" float="right">
			waveforms of a sawtooth and combfiltered sawtooth at 440 hz
		</html:object>
		<line>Consider a sawtooth signal (maybe from a violin) being picked up by two microphones at different distances. The signals will look as follows (with the result at the bottom):</line>
		<html:object data="graphics/spectrum-sawtooth-440hz-300.png" float="left" clear="both">
			spectrum of a sawtooth at 440 hz
		</html:object>
		<line clear="right">All wavelengths in the signal that divide the distance between the microphones will amplify, while those which leave a remainder of half the wavelength will cancel.</line>
		<line>This is called the <keyword>comb-filter effect</keyword>. Comb-filtered signals sound hollow and are totally immune to equalization.</line>
		<html:object data="graphics/spectrum-sawtooth-440hz-combfiltered-300.png" float="left" clear="both">
			spectrum of a sawtooth at 440 hz
		</html:object>
		<line>It can be compensated by applying a corrective delay to the leading signal.</line>
		<line>To find the correct amount, do a rough calculation (time = distance / speed of sound), start with that value and fine-tune by ear until the sound is full and natural.</line>
		<note>Mention the 3:1 rule here and elaborate on different situations where comb filtering can occur.</note>
	</slide>

	<slide>
		<h>Delays (4): The Haas effect</h>
		<line>Timing is crucial to our perception of direction.</line>
		<line>Two sound sources more than 30 ms apart will be heard as an echo. If their timing difference is less than that, they will "blur" into one.</line>
		<line>Still, we will perceive the sound to originate from the earlier one, even if the other is louder.</line>
		<line>This is called the <keyword>Haas effect</keyword>, and is exploited for huge P.A. systems at rock festivals:</line>
		<line>A spectator standing behind the secondary P.A. rigs (the <keyword>delay line</keyword>) will get most of the sound energy from them. Since they are delayed a little more than their actual distance to the main rig, the main rig hits earlier, and the sounds seems to originate from the stage.</line>
		<line>You can do interesting panning tricks with short delays.</line>
	</slide>

	<slide>
		<h>Delays (5): Creative use</h>
		<html:object data="graphics/echo-effect-300.png" float="right">
			schematic of an echo effect
		</html:object>
		<line>Delays can be used as <keyword>echo effects</keyword>:</line>
		<line>Part of the signal is routed back through a delay, attenuated, and mixed into the original stream.</line>
		<line>The attenuator is important to avoid runaway feedback.</line>
		<line>Digital audio workstations or digital multitrack tapes provide <keyword>track delay</keyword>. Individual tracks can be moved back in time.</line>
		<line>Track delays can be used to change the "feel" of certain tracks, for example to make the bass more "laid back" compared to the drums.</line>
		<line>They can also be used correctively, to align correlated signals.</line>
	</slide>

	<slide>
		<h>Questions?</h>
	</slide>

</section>


<section>
	<h>Controlling spectrum: equalization</h>
	<slide>
		<h>Equalization (1): why and how</h>
		<line>The ideal audio chain has a linear <keyword>frequency response</keyword> - it does not color the sound at all.</line>
		<line>Of course, such a chain does not exist.</line>
		<line>We need a way to tweak the frequency response, either to correct for deficiencies in the chain, or for musical reasons.</line>
		<line>This can be accomplished by <keyword>filters</keyword>.</line>
		<line>A bank of filters is commonly referred to as an <keyword>equalizer</keyword>, since originally it was used to equalize (flatten out) the frequency response of a system.</line>
		<line></line>
		<line>Filters are frequency-selective circuits.</line>
		<line>There are two simple components that show frequency-dependent behaviour towards a current: <keyword>capacitors</keyword> and <keyword>inductors</keyword>.</line>
		<line>We can use them to build analog filters.</line>
	</slide>
	<slide>
		<h>Equalization (2): capacitors</h>
		<line>A capacitor can be thought of as two opposite plates that can store electrical charge.</line>
		<line>They are isolated from each other by an air gap or a special insulator (the dielectric), but are close enough to affect each other through an <keyword>electric field</keyword>.</line>
		<html:object data="graphics/capacitor.png" float="left">
			schematic of a capacitor
		</html:object>
		<line>No electrons can pass through the air gap, but their electric field can push those on the other side away.</line>
		<line>So, no DC goes through, but impulses do.</line>
		<line>At very high frequencies, where the electrons hardly move long ways but only shuffle back and forth, the capacitor behaves like a piece of wire - its <keyword>capacitive reactance X<index>C</index></keyword> is low.</line>
		<line>We have <formula>X<index>C</index> = 1 / (2 &#960; f C)</formula> where f is the frequency in Hertz and C is the <keyword>capacity</keyword> in Farad.</line>
		<line>Capacitors introduce a <keyword>phase shift</keyword>: the current <keyword>leads</keyword> the voltage by 90°.</line>
	</slide>
	<slide>
		<h>Equalization (2): capacitors (cont'd)</h>
		<html:object data="graphics/rc-circuit.png" float="right">
			schematic of an RC circuit
		</html:object>
		<line>The capacitor blocks low frequencies, and lets high ones pass.</line>
		<line>With an additional <keyword>resistor</keyword> acting as a <keyword>voltage divider</keyword>, we can build a simple <keyword>high-pass filter</keyword> with a slope of 6dB per octave.</line>
		<line>The <keyword>cut-off frequency f<index>0</index></keyword> (defined as the -3dB point) is <formula>f<index>0</index> = 1 / (2 &#960; R C)</formula> where R is the value of the resistor in <keyword>Ohm</keyword> and C is the capacity.</line>
		<html:object data="graphics/rc-freq-300.png" float="left">
			frequency response chart of an RC stage
		</html:object>
		<line>The frequency response of such an <keyword>RC circuit</keyword> is <formula>G(f) = 20 log (U<index>out</index> / U<index>in</index>)</formula> where G is the gain in dB, and U<index>out</index> and U<index>in</index> are proportional to the resistances across in- and output: <formula>U<index>out</index> ~ R,  U<index>in</index> ~ R + X<index>C</index>, X<index>C</index> = 1 / (2 &#960; f C)</formula></line>
	</slide>
	<slide>
		<h>Equalization (3): inductors</h>
		<line>An inductor is a coil of wire, either hollow or wrapped around a ferrit core.</line>
		<html:object data="graphics/inductor.png" float="left">
			schematic of an inductor coil, with magnetic field and electron flow
		</html:object>
	<line>Coils produce a <keyword>magnetic field</keyword> when current flows through them, and a voltage is <keyword>induced</keyword> into them when they are in a <em>changing</em> magnetic field.</line>
		<note>They are the key parts of <keyword>electro motors</keyword> and <keyword>generators</keyword> (which are identical in principle). Compare also how microphones and speakers are basically the same.</note>
		<line>When DC flows through the coil, its magnetic field is <em>static</em> - hence no induction.</line>
		<note>If there was, we could conveniently generate energy out of thin air by wrapping a wire around a magnet...</note>
		<line>When the current changes (as with AC audio signals), so does the field - and a voltage is induced.</line>
		<line>The coil induces a voltage into itself. It is opposite to the original and reduces the current that passes through the coil. The faster the field changes, the stronger this <keyword>self-induction</keyword>.</line>
		<line>Thus the higher the frequency, the higher the <keyword>inductive reactance X<index>L</index></keyword>.</line>
		<line>We find <formula>X<index>L</index> = 2 &#960; f L</formula> where L is the coil's <keyword>inductivity</keyword> in Henry.</line>
		<line>Inductors also introduce a <keyword>phase shift</keyword>: the current <keyword>lags</keyword> the voltage by 90°.</line>
	</slide>

	<slide>
		<h>Equalization (3): inductors (cont'd)</h>
		<html:object data="graphics/rl-circuit.png" float="right">
			schematic of an RL stage
		</html:object>
		<line>The inductor blocks high frequencies, and lets low ones pass.</line>
		<line>Again, with an additional <keyword>resistor</keyword> for <keyword>voltage divider</keyword>, we can build a simple <keyword>low-pass filter</keyword> with a slope of 6dB per octave.</line>
		<line>The cut-off frequency f<index>0</index> here is <formula>f<index>0</index> = R / (2 &#960; L)</formula></line>
		<html:object data="graphics/rl-freq-300.png" float="left">
			frequency response chart of an RL stage
		</html:object>
	<line>The frequency response of an <keyword>RL circuit</keyword> is <formula>G(f) = 20 log (U<index>out</index> / U<index>in</index>)</formula> with <formula>U<index>out</index> ~ R,  U<index>in</index> ~ R + X<index>L</index>, X<index>L</index> = 2 &#960; f L</formula></line>
	</slide>

	<slide>
		<h>Equalization (4): variants</h>
		<line>Circuits that affect all frequencies above or below a certain point are called <keyword>shelving filters</keyword>.</line>
		<html:object data="graphics/lcr-freq-300.png" float="left">
			frequency response of a band-pass filter
		</html:object>
		<line>High- and low-pass filters can be combined into <keyword>band-pass</keyword> or <keyword>peaking filters</keyword>.</line>
		<html:object data="graphics/lcr-circuit.png" float="right">
			schematic of a band pass
		</html:object>
		<line clear="both">Since they can only remove energy, they are called <keyword>passive filters</keyword>.</line>
		<line>By adding amplifiers, we can create <keyword>active filters</keyword> that allow boosting.</line>
		<line>The filter properties can be improved by cascading filter circuits, and made tweakable by using potentiometers instead of resistors.</line>
	</slide>

	<slide>
		<h>Equalization (5): the parametric EQ</h>
		<html:object data="graphics/parametric-q-400.png" float="left">
			frequency response chart of a parametric eq, annotated, with several q's superimposed
		</html:object>
		<html:object data="graphics/channel-eq.png" float="right">
			a Soundtracs Solo MIDI 32-8-2 channel equalizer
		</html:object>
		<line><keyword>Parametric equalizers</keyword> have three controls:</line>
		<ul>
			<li><keyword>center frequency</keyword>,</li>
			<li><keyword>gain</keyword> and</li>
			<li><keyword>bandwidth</keyword> or <keyword>q factor</keyword>.</li>
		</ul>
		<line>The center frequency is the frequency of the peak, the gain is the amount of boost or cut at that peak, and the bandwidth is width of the bell in octaves between its -3dB points.</line>
		<line>A filter with fixed bandwidth is called <keyword>semi-parametric</keyword>.</line>
		<line>A typical channel strip has high and low shelving filters and one or two (semi-)parametric bands.</line>
	</slide>

	<slide>
	  <h>Filters</h>

	  <line>The most basic filter is simply a delay, mix and gain operation</line>
	  <line><html:object float="right" data="graphics/1st-order-lp.png">1st order lowpass filter</html:object></line>
	  <line>This is the simplest <keyword>1st order lowpass filter</keyword></line>
	  <line>In maths form its:</line>
	  <line><formular>y<index>n</index> = (x<index>n</index> + x<index>n-1</index>) / 2</formular></line>
	  <line clear="right">All normal filters can be represented as a combination of delays, mixes and gains</line>
	  <line><html:object float="left" data="graphics/1st-order-lp-freqz.png">1st order frequency response</html:object></line>
	  <line>This frequency response of this filter shows a very shallow curve towards blocking the frequency componenets at half the sample rate.</line>
	</slide>

	<slide>
	  <h>Internal workings of EQs</h>
	  <html:object float="left" data="graphics/eqs.png">Serial and parallel filter arrangement</html:object>
	  <line>In the serial arrangement the filters are peaking filters. This means that the phase shifts, rounding errors and so on build up with each stage.</line>
	  <line>In the parallel arrangement each band only goes through one filter, so the errors do not build up as much, but the bandpass filters must allign exactly, otherwise there will always be peaks and/or throughs in the signal where the bands do not meet exactly</line>
	</slide>


	<slide>
		<h>Using an equalizer</h>
		<line>0th Rule: <strong>Listen!</strong></line>
		<line>- Before you do anything else, walk up to the instrument or singer and listen quietly and patiently. This is the ideal you want to recreate.</line>
		<line>1st Rule: <strong>The best EQ is no EQ!</strong></line>
		<line>- Don't try to compensate bad mic placement, cheap mikes or shabby room acoustics with EQ.</line>
		<line>2nd Rule: <strong>Down is good, up is evil!</strong></line>
		<line>- First try to listen for bands that need attenuation before boosting everything else.</line>
		<line>3rd Rule: <strong>Sweep is your friend.</strong></line>
		<line>- If you have a semi-parametric filter, boost the gain and sweep through the available range to get a feel for how all the frequencies sound.</line>
		<line>4th Rule: <strong>Start with low Q.</strong></line>
		<line>- If you have a fully parametric filter, set it to a broad bandwidth, zero in on the problem and then narrow the bell until the effect is lost, then back out a little.</line>
	</slide>

	<slide>
		<h>Using an equalizer (cont'd)</h>
		<line>5th Rule: <strong>A/B frequently.</strong></line>
		<line>- If you have an EQ bypass, use it often. The flat signal is your reference.</line>
		<line>6th Rule: <strong>You can't boost what isn't there.</strong></line>
		<line>- If you have room cancellation effects on your recording, or there's simply no sound in a particular range, there's no point in cranking up the EQ.</line>
		<line>7th Rule: <strong>Watch out when boosting a bass shelving filter!</strong></line>
		<line>- It will boost everything below, the deeper the louder, and you will almost certainly not realize the problem on your home monitors.</line>
		<line>8th and Ultimate Rule: <strong>Beware of smartasses telling you how to use an EQ!</strong></line>
		<line>- Anything goes. After all, the mix has to work, and if it means to bend the signal till it screams, so what!</line>
	</slide>

<!--
	* simple digital frequency-selective operations
	* digital parametric eqs
-->


		<slide>
			<h>Questions?</h>
		</slide>

</section>

<section>
	<h>Controlling dynamics (compressors/expanders)</h>

	<slide>
		<h>Compression (1): terms</h>
		<line>The difference between the softest and the loudest passages is called the <keyword>dynamic range</keyword> of a signal.</line>
		<line><keyword>Macrodynamics</keyword> is the loudness difference between sections (such as chorus, verse, bridge and solo). It affects the listener's perception of <keyword>suspense</keyword> and <keyword>drama</keyword>.</line>
		<line><keyword>Microdynamics</keyword> is the peakiness of the signal (imagine drums vs. pipe organ). It affects the perceived <keyword>loudness</keyword>, <keyword>punch</keyword> or <keyword>power</keyword>.</line>
		<line>Short, percussive peaks in the signal are called <keyword>transients</keyword>.</line>
		<line>In an ideal world, all media are good enough to faithfully reproduce the original dynamic range, all listening environments are quiet enough to reveal the soft passages, and all listeners are attentive and knowledgeable enough to enjoy it.</line>
		<line>Ok, forget it. Let's fiddle.</line>
		<line>Macrodynamics can be controlled by manual <keyword>gain riding</keyword> or mixing automation.</line>
		<line>Manipulating microdynamics calls for <keyword>automatic gain control</keyword>. Enter the <keyword>compressor</keyword>.</line>
	</slide>

	<slide>
		<h>Compression (2): how?</h>
		<line>A compressor can be thought of as an extremely quick audio engineer. It listens to a signal and controls its level in accordance with predefined rules.</line>
		<line>"Listening" here means measuring the signal loudness, either by looking at the <keyword>peaks</keyword> or by averaging the level over time (the <keyword>root-mean-square</keyword> or <keyword>RMS</keyword> algorithm), and producing a <keyword>control voltage</keyword>.</line>
		<line>This is then fed into a <keyword>VCA</keyword> or voltage-controlled amplifier that manipulates the signal.</line>
		<html:object data="graphics/compressor.png" float="right">
			front panel of a compressor
		</html:object>
		<line>The behaviour of the VCA can be controlled by a number of parameters:</line>
		<ul>
			<li><keyword>Threshold</keyword>: the level at which the compressor starts to act;</li>
			<li><keyword>Ratio</keyword>: the amount of compression;</li>
			<li><keyword>Attack</keyword>: how fast the compressor reacts to transients;</li>
			<li><keyword>Release</keyword>: how quickly it stops compressing after a peak;</li>
			<li><keyword>Knee</keyword>: how harshly the compression sets in.</li>
		</ul>
		<line>The current amount of compression can be monitored on the gain reduction meter.</line>
	</slide>

	<slide>
		<h>Compression (2): how? (cont'd)</h>
		<html:object data="graphics/compressor-linear.png" float="left">
			a jamin compressor curve with ratio 1:1
		</html:object>
		<line>Here is the transfer function of a compressor with ratio 1:1 - it will not do anything.</line>
		<html:object data="graphics/compressor-working.png" float="right" clear="both">
			a jamin compressor curve with ratio 5:1 and threshold -30dB
		</html:object>
		<line clear="left">Here, the ratio is 5:1 and the threshold is -30dB:</line>
		<line>Above the threshold, the output will be compressed. 5:1 means 5dB more input result in only 1dB more output.</line>
		<line>Note that a compressor at first only <keyword>softens</keyword> the signal.</line>
		<html:object data="graphics/compressor-working+makeup.png" float="left" clear="both">
			a jamin compressor curve with ratio 5:1, threshold -30dB and makeup gain.
		</html:object>
		<line clear="right">After the peaks are trimmed off, the level is raised to the old peak level with the <keyword>makeup</keyword> or <keyword>output gain</keyword>. Now the signal is louder, even though the peaks are the same height.</line>
	</slide>

	<slide>
	  <h>Internal workings of compressors</h>

	  <html:object data="graphics/comp.png">compressor block diagram</html:object>
	  <line>The envelope follower reads the signal level form either the side chain input or the main input, feeds it to the gain control module (which does the ratio conversion) and uses that to drive an amplifier on the main output</line>
	</slide>

	<slide>
	  <h>Compressor: envelope followers</h>
	  <html:object data="graphics/envelope-follower.png" float="left">envelope follower graphs</html:object>
	  <line>The envelope follower tracks the ampltude of the incoming signal. The output is unipolar (positive values only) as we dont care about the sign of the signal, just its amplitude.</line>
	  <line>Notice that the output shape of the envelope follower is bumpy and doesn't track the waveform very well. Thats because its a hard problem, and this is one just one I hacked up for this demonstation.</line>
	  <line>Tuning the envelope follower correctly is one of the hardest things to get right in digital compressors.</line>
	</slide>

	<slide>
		<h>Compression (3): why?</h>
		<line>Sometimes, gentle sum compression is needed because the dynamic range exceeds the S/N of the target medium or environment. This may be the case if you are mixing</line>
		<ul>
			<li>for analog tape, vinyl or radio;</li>
			<li>extremely demanding orchestra material for CD;</li>
			<li>for noisy environments (car radio etc.).</li>
		</ul>
		<line>(Some of these situations only call for gentle macrodynamics reduction and can be handled with manual gain riding.)</line>
		<line>Compression can be used on single tracks for purely esthetic or creative reasons, such as to give a singer or instrument more "presence".</line>
		<line>Most often, extreme compression is used indiscriminately on the sum, to make the mix louder than anyone else. This is why commercial pop music is so boring.</line>
	</slide>

	<slide>
		<h>Compression (4): Usage tips</h>
		<line>When using a compressor for the first time, switch its attack and release controls to "automatic".</line>
		<line>Set the threshold to "max" (= neutral) and decide whether you want strong (5:1 and up) or gentle compression (1.5:1 - 5:1).</line>
		<line>Move the threshold down until you begin to hear the desired effect.</line>
		<line>Calibrate the output gain so that the processed signal is as loud as the original, using the bypass switch.</line>
		<line>Now turn the attack and release knobs to the middle and switch to manual control.</line>
		<line>Use the attack time to control how much transients will be compressed. If the signal is too thin over all with very loud drum hits, use a short attack time to reduce them. If drums sound lifeless and squashed, set a longer attack.</line>
		<line>If the compressor is "pumping" (i.e. loud transients are followed by a dent in loudness), reduce the release time.</line>
		<html:object data="graphics/warning-50.png" float="left">Watch out!</html:object>
		<line>When compressing stereo signals, make sure you link the control voltages for both channels (most units have a "stereo link" switch). Otherwise, the stereo image will jump around.</line>
	</slide>

	<slide>
		<h>Compression (5): Other usage examples</h>
		<h>De-Essing</h>
		<line>Some compressors have a <keyword>side-chain</keyword> input. Whatever you send there is used for the loudness measurement instead of the normal signal. You can use this feature to build a <keyword>De-Esser</keyword>:</line>
		<line>Patch a vocal track with excessive sibilance into the compressor, and also through an equalizer. Use the EQ to boost the sibilance even more, and feed the resulting signal into the side-chain.</line>
		<line>You will get a compressor that is extremely sensitive to sibilance and will reduce the level whenever it gets ugly.</line>
		<h>Limiting</h>
		<line>A compressor with very high ratio (&#8734;:1) and short attack time is called <keyword>limiter</keyword> and can be used to protect digital media from overloading or P.A. systems from excessive level. It can also be abused to increase loudness at the cost of naturalness and "punch".</line>
	</slide>

	<slide>
		<h>Expansion</h>
		<line>An <keyword>expander</keyword> works complementary to a compressor: it makes soft signals even quieter.</line>
		<line>The most common use case for this is the <keyword>noise gate</keyword>: whenever the program material is so quiet that the noise in the chain becomes audible, it can be reduced or completely muted by the gate.</line>
		<html:object data="graphics/warning-50.png" float="left">Watch out!</html:object>
		<line>It is important to get the attack and release times right, or the gate will be "stuttering" around its threshold.</line>
		<line>Expanders can also be used to create the famous "In the Air Tonight" <keyword>gated reverb</keyword> drum sound. Mix drums with way too much reverb, and cut off the reverberation as soon as the drum sound has decayed.</line>
		<line>Unfortunately, it is almost impossible to liven up material with an expander that has been compressed to death.</line>
	</slide>

<!--
	* digital compressors/expanders: implementation and specialties (look-ahead)
-->


		<slide>
			<h>Questions?</h>
		</slide>

</section>

<section>
	<h>Space and spatialisation</h>

	<slide>
		<h>Spatial perception (1)</h>
		<line>There are two aspects to spatial perception:</line>
		<ul>
			<li>to hear from which <keyword>direction</keyword> and <keyword>distance</keyword> a sound comes, and</li>
			<li>to get a picture of the <keyword>acoustics</keyword> of the room</li>
		</ul>
		<line>From an audio engineering POV, the first boils down to stereo (and surround) techniques, and the second to reverberation.</line>
		<line>Both aspects can be captured during recording, or they can be faked afterwards.</line>
	</slide>

	<slide>
		<h>Spatial perception (2)</h>
		<line>Our brain gets three clues to work out the direction of a sound:</line>
		<ul>
			<li>loudness differences between the ears,</li>
			<li>timing differences between the ears, and</li>
			<li>sound coloration due to damping and refraction around the earlobes and head.</li>
		</ul>
		<line>Distance can be derived from</line>
		<ul>
			<li>the relative loudness,</li>
			<li>the amount of high-frequency damping (the duller, the further), and</li>
			<li>the ratio of direct to reverberated sound.</li>
		</ul>
		<line>All these mechanisms can be (and are) used in recording.</line>
	</slide>

	<slide>
		<h>Recording or faking distance information</h>
		<line>The placement of the microphone is the most crucial factor.</line>
		<line>For a certain microphone pattern in a certain room, there is a specific distance to the source at which the direct sound is as loud as the reverberated sound: the <keyword>reverb radius</keyword>.</line>
		<line>By moving the microphone in and out of the reverb radius, we can control the amount of reverb and thus the perceived distance.</line>
		<line>Air damping can be faked by filtering the treble.</line>
		<line>In pan-pot stereo, you can fake distance by reducing volume and adding more reverb and a a slight attenuation of the mid frequencies (the <keyword>presence range</keyword>).</line>
	</slide>
	
	<slide>
		<h>Stereophonic recording (1)</h>
		<line>Distance information can in theory conveyed with only one source (<keyword>monaural</keyword> or <keyword>monophonic</keyword> sound). But then everything seems to come from the same place, so this is not very interesting.</line>
		<line>To create or recreate an impression of direction and spatial sound, it is essential to have at least two sources (<keyword>binaural</keyword> or <keyword>stereophonic</keyword> sound).</line>
		<line>There are two basic stereo techniques: <keyword>intensity stereo</keyword> and <keyword>phase stereo</keyword>.</line>
		<line>Things to keep in mind are <keyword>mono compatibility</keyword> and control of <keyword>stereo width</keyword>.</line>
	</slide>
	
	<slide>
		<h>Stereo (2): Intensity stereo</h>
		<line>Intensity stereo utilizes the brain's sensitivity to loudness differences, and can be done with two directional microphones in one spot, turned slightly outwards (<keyword>X/Y</keyword> miking).</line>
		<line>The perceived width of the stereo field is determined by the <keyword>opening angle</keyword> of the microphones.</line>
		<line>Intensity stereo recordings can be mixed down to mono without problems.</line>
		<html:object data="graphics/warning-50.png" float="left">Watch out!</html:object>
		<line>When increasing width, watch out for a hole in the middle of the stereo field.</line>
	</slide>
	
	<slide>
		<h>Stereo (3): Phase stereo</h>
		<line>Phase stereo works through timing differences, and is usually accomplished by two omnidirectional microphones at placed a distance (<keyword>A/B</keyword> miking).</line>
		<line>The perceived width is controlled by the distance between the microphones.</line>
		<html:object data="graphics/warning-50.png" float="left">Watch out!</html:object>
		<line>Again, there will be a hole in the middle of the stereo field if the mikes are pushed too far apart.</line>
		<line>Phase stereo recordings can suffer from comb filtering effects when mixed down to mono.</line>
	</slide>
	
	<slide>
		<h>Stereo (4): other techniques</h>
		<line>It is also possible to combine the two techniques by using slightly angled directional microphones at ear distance (NOS and ORTF patterns). They generally convey a more convincing stereo image, since they recreate two different spatial clues.</line>
		<line>A nice variant of intensity stereo is <keyword>mid/side (M/S) stereo</keyword>. It consists of an omni or directional center microphone and a figure eight one with the lobes aimed left and right. It is equivalent to X/Y and must be converted as follows: <formula>X = M + S, Y = M - S</formula> The nice thing is you can control the width after the recording by changing the S level.</line>
		<line>The crudest stereo technique is <keyword>pan-pot stereo</keyword>, achieved by panning close-miked or DI mono sources. It needs artificial reverb to sound convincing.</line>
	</slide>

	<slide>
		<h>Reverb (1): some terms</h>
		<line>Reverberating sound has a number of phases:</line>
		<ul>
			<li>the dry-sounding <keyword>pre-delay</keyword> phase before the sound has hit the walls;</li>
			<li>the distinct <keyword>early reflections</keyword>; and</li>
			<li>the <keyword>tail</keyword> where the reflections are so numerous and so dense that they blur into a continous sound.</li>
		</ul>
	</slide>
	<slide>
	  <h>Reverb (2): Artificial reverb</h>
	  <line>Artificial reverb attempts to recreate the sense of space got from the reflections from the walls of a physical room</line>
	  <html:object data="graphics/reverb-bd.png">reverb block diagram</html:object>
	  <line>The delay lines (in reality there are more than 4) feed into allpass filters and then into a multiplication matrix that mixes portions of the input signals into each output.</line>
	  <line>The delay line lengths and allpass filters need to be very carefully tuned to prevent metalic or grainy sounds.</line>
	</slide>

	<slide>
	  <h>Reverb (3): Convolved reverb</h>

	  <line>Convolution can be used to recreate reverb from impulse responses</line>
	  <line>If the source signal is convolved with an impulse response captured from a room it will recreate all the linear (time and frequency response) characteristics of the room</line>
	  <html:object float="right" data="graphics/impulse.png">impulse reponse</html:object>
	  <line>Impulse response captured from Volksbad</line>
	  <line clear="right">This impulse response is used inplace of each sample in the source signal, just as for sinc interpolation</line>
	  <note>Actually impulses are convolved using the FFT operation</note>
	</slide>

	<slide>
	  <h>Reverb (4): Capturing impulses</h>

	  <line>The simplest way to capture impulses is to play a single sample pulse in the environment you wish to capture and recording it with a microphone</line>
	  <html:object float="right" data="graphics/reflections.png">room reflectsion</html:object>
	  <line>Sometimes better results can be got by playing a "chirp" or swept sinewave and <keyword>deconvolving</keyword> it back to the equivalent impulse</line>
	  <line><html:a href="audio/volksbad.wav">Volksbad impulse</html:a></line>
	  <line>Impulses can also be captured by passing impulses through outboard equipment</line>
	  <line>One thing that cannot be captured properly is dynamics control (eg. compressors) and non-linear effects (eg. distortion)</line>
	</slide>
	
	<slide>
		<h>Reverb (5): Reverb chambers</h>
		<line>Another simple method to add reverb to a sound is to feed it to a speaker in a good-sounding room and pick it up with a microphone. When patched through an aux send, the amount of reverb can be controlled precisely.</line>
		<line>With good rooms, speakers and microphones, the result can be very good.</line>
		<line>On the downside, the reverb properties are fixed, as with convolution reverb.</line>
		<line>Reverb chambers can be thought of as "acoustic convolvers".</line>		
	</slide>
	
	<slide>
		<h>Reverb (6): Using reverb units</h>
		<line>Algorithmic reverb units have a number of tweakable parameters:</line>
		<ul>
			<li><keyword>Decay time</keyword> is the time it takes for the reverb to fade away (= to fall -60dB below the original signal level). Rule of thumb is long decay for slow pieces, short decay for faster ones.</li>
			<li><keyword>Pre-Delay</keyword> is the time span between the original signal and the first reflections. If set too long, it can create an unnatural delay effect. Used sparingly, it can help increase speech intelligibility without reducing the reverb density.</li>
			<li><keyword>High-frequency damping</keyword> allows you to simulate hard or carpeted walls.</li>
		</ul>
		<line>Some reverbs allow detailed configuration of the room dimensions, or to choose from simulations of mechanical reverb generators (plate, spring). Some also let you tune the levels of the early reflections and the reverb tail separately.</line>
	</slide>
	
	<slide>
		<h>Some ideas for spatial-sounding mixes</h>
		<line>Try to capture space during the recording stage. Choose good sounding rooms.</line>
		<line>If you want natural sounding space, use the same reverb for all signals.</line>
		<line>Use the reverb amount to control the perceived distance (the drier, the closer).</line>
		<line>Use additional ambience mikes. If they color the close-miked sound too much, EQ the low and low-mid frequencies away and just keep the "air" quality.</line>
		<line>Try omni mics, or directional mics at a greater distance.</line>
		<line>To widen the stereo image, use phasing: it is sometimes possible to make a sound come from outside the speakers by adding some phase-reversed signal to the opposite channel.</line>
	  <html:object data="graphics/warning-50.png" float="left">Watch out!</html:object>
		<line>All phasing tricks can potentially mess up the low end. Carefully check for cancellation effects.</line>
	</slide>
<!--
	* aural perception of space

	* head-related stereo
	* standard stereo reproduction
	* x-y (m-s), a-b, and "pan-pot" stereo

	* caveats w/ stereo signals (polarity, stereo compression, mono compatibility)

	* natural reverb
	* analog "convolution": the reverb chamber
	* digital convolution reverb
	* reverb parameters: duration, early reflections, pre-delay, room size, damping
	* artificial digital algorithmic reverb

	* using reverb in mixes, z-axis "panning"
-->
</section>

<section>

	<slide>
		<h>References and recommended reading</h>
		<line>Bernsee, Stephan M.: "The DSP Dimension" <html:a href="http://dspdimension.com/">http://dspdimension.com/</html:a></line>
		<line>Capel, Vivian: "Public Address Systems", Focal Press 1992</line>
		<line>Görne, Thomas: "Mikrophone in Theorie und Praxis", Elektor-Verlag Aachen/Germany, 1994</line>
		<line>Katz, Bob: "Mastering Audio, The Art and the Science", Focal Press 2002</line>
		<line>Katz, Bob: "Digital Domain" <html:a href="http://www.digido.com">http://www.digido.com/</html:a></line>
		<line>Roads, Curtis: "The Computer Music Tutorial", MIT Press 1996</line>
		<line>Smith, Steven W.: "The Scientist and Engineer's Guide to Digital Signal Processing", California Technical Publishing 2003 <html:a href="http://www.dspguide.com">http://www.dspguide.com</html:a></line>
		<line>Stark, Peter A.: "Electronics 101", 1998 - 2004 <html:a href="http://www.users.cloud9.net/~stark/elbook.html">http://www.users.cloud9.net/~stark/elbook.html</html:a></line>
		<line>Various authors: "Music-DSP Source Code Archive" <html:a href="http://www.musicdsp.org">http://www.musicdsp.org</html:a></line>
		<line>Warstadt, Michael / Görne, Thomas: "Studiotechnik, Hintergrund und Praxiswissen", Elektor-Verlag Aachen/Germany 1994</line>
	</slide>

</section>

<section>
	<h>Thank you.</h>
</section>

<section>
	<h>Q &amp; A</h>
</section>

</section>
<!--

test signals needed:
sine waves
some dynamic music
pink noise
[some noisy percussive music]
[a frequency sweep]

equipment needed:
a parametric eq
a compressor
[an expander]
a simple reverb unit
a delay
two speakers, not too wide apart
-->
</presentation>
<!-- vi:set ts=8 sts=2 sw=2: -->

