Drag Loudness below zero, then bring it back and drag Baseline instead, and watch what each one does to the shape.
Louder, quieter, and shifted
The faint stems are the original sequence, unchanged.
Describe this picture
One plot of a 32-sample sequence, amplitude against sample number: the original as faint stems and the result over it. The “Loudness” slider, the gain , runs from to 2; the “Baseline” slider, the offset , runs from to 1. The readout “The result” shows the formula for the current settings, starting at .
The values, not the timing
In Shifting, reversing and scaling time (2.1), I moved a signal around in time: I slid it, stretched it, reversed it, but I never touched what it measured at each moment. Here I do the opposite. I leave every sample’s timing alone and change its value instead: how loud it is, what happens when two signals add, what happens when a signal runs into a limit. That makes seven small operations, and you already use most of them without a name for them.
Louder, quieter, and shifted
Turn a volume knob and a song gets louder or quieter, but it still sounds like the same song, bigger or smaller. Now picture a bathroom scale that is a little off, always reading one kilogram heavy no matter what is on it. Fixing that scale means sliding every reading down by one kilogram, not stretching or shrinking anything.
Those are the two simplest things you can do to a signal’s values. Multiplying every sample by a number (the gain) makes the whole trace bigger or smaller, and if is negative it also flips the trace upside down around zero. Adding a constant (the offset, the same “DC” idea from How big is a signal (1.3)) slides the whole trace up or down without changing its shape. Put together:
Here is the original signal’s value at sample , is the gain you multiply by, is the constant you add, and is the result.
In the picture at the top of the page, Loudness is the gain and Baseline is the offset . Loudness stretches, shrinks, or flips the trace around zero, while Baseline slides the whole trace up or down, leaving its up-and-down shape as it was.
Adding two signals together
Two people talk at once near a microphone. The microphone can’t tell the voices apart: at every instant it records however much the air pressure has changed, and that is the two voices’ pushes added together.
Adding two signals works the same way: at each sample, you add the two values.
and are the two signals’ values at sample , and is their sum at that same sample.
Switch between Show them apart and Show the sum, and compare each sum stem with the two above it.
Adding two signals
A tone, and a slower, quieter tone.
Describe this picture
Two panels against sample number. The upper one draws a fast tone, “tone”, and a slower, quieter one, “slow tone”, 40 samples each, their stems slightly to either side of each sample number. The lower panel holds their sum, . The “Display” buttons, “Show them apart” and “Show the sum”, empty or fill the sum panel; it starts on the sum.
At every sample, the sum stem’s height is the two stems’ heights added: where both are high together the sum peaks higher than either one alone, and where one dips below zero it pulls the sum down.
Multiplying by an envelope
A guitarist’s tremolo pedal doesn’t change the pitch of a note. It makes the loudness swell and fade in a slow, steady rhythm while the note keeps ringing underneath. A recording engineer does something similar by hand at the start and end of a track, fading it in from silence and fading it out again at the end.
Both are the same operation: multiplying a signal by a second, slower signal called an envelope. Multiplying scales one signal’s value by the other’s value at that same instant.
is the fast signal, like a musical tone, is the slow envelope, and is the product. Wherever is zero, is zero no matter what was doing; wherever is one, equals .
Switch between Swell and Fade in and out, and watch the outline of the product.
Multiplying by an envelope
Each sample of the tone is multiplied by the envelope's value at the same sample.
Describe this picture
Three panels against sample number: the tone , 64 samples at about eight samples per cycle; the envelope ; and the product . The “Envelope shape” buttons choose “Swell”, a repeating swell with two humps, or “Fade in and out”, a single fade-in, fade-out window.
The product’s outline follows the envelope: it is silent wherever the envelope is zero, full-strength wherever the envelope is one, and in between it is partway.
How much it changed
If you read a car’s odometer once a second, you can work out how fast it was going without a speedometer: subtract each reading from the one after it. A big jump means fast driving; almost no jump means the car barely moved.
That subtraction is called the first difference. It measures how much a signal changed from one sample to the next:
is the current sample, is the previous one, and is how much the signal changed between them. If you’ve met derivatives in calculus, this is their discrete-time version. Either way, it is near zero on flat stretches and large wherever the signal is changing fast.
Drag Position along the sequence and watch Change at this step.
How much it changed
Drag the marker, or use the slider.
Describe this picture
Two panels against sample number: a smooth 16-sample sequence on top, with a marker on the current sample and the sample before it highlighted, and the change below, with the same marker. The marker starts at sample 2 and moves by dragging or with the “Position” slider. Three readouts show “Sample x[n]”, “Sample before, x[n-1]” and “Change at this step”.
Right where the original trace is flattest, at a peak or a trough, the difference is close to zero and changes sign; wherever the original is steepest, the difference is at its largest.
Adding it up as you go
A bank statement lists each day’s deposits and withdrawals separately, but what you actually care about is your running balance: add up every entry so far, and that running total is your balance at any given day.
That running total is called the running sum: at each sample, add up every value the signal has taken so far, including the current one.
or, written with the summation symbol,
Here the signal starts at sample . is its value at sample , and is the running total once you’ve added up every sample from up to and including .
Drag Position along the sequence and watch Running total.
Adding it up as you go
Drag the marker, or use the slider.
Describe this picture
Two panels against sample number: deposits (positive) and withdrawals (negative) on top, with the entries still to come drawn faint, and the running total below, built up to the marker. The marker moves by dragging or with the “Position” slider, and two readouts show “Deposit x[n]” and “Running total”.
A run of positive deposits makes the running sum climb steadily, while a run of withdrawals makes it fall.
Key idea
Differencing and running-summing undo each other. Take the difference of a signal, then run a sum back over that difference, and you land back on the original signal exactly (as long as the signal starts from zero, like every recording that begins in silence). Differencing asks “how much did it change since last time?”; summing asks “how much has it built up to?”, and running one right after the other cancels out.
Capping and folding
Push an amplifier past what it can put out and the tops of the wave don’t get louder. They get chopped flat, which is why an overdriven speaker sounds harsh instead of loud. That flattening is called clipping: any value past a fixed limit gets capped at that limit instead of being allowed through.
Here is for a positive value and for a negative one, so a value past the limit is capped at or , matching its own sign.
A different operation, rectification, keeps a signal’s size but throws away its sign: every negative value gets flipped positive instead.
Here is a quick test that separates these two from a plain gain. With a gain, double the input and the output doubles too, every time. Clipping fails that test: double an input that is already past the limit and the output does not change; it stays at . Rectification fails a sign-flip test: flipping the input’s sign should flip the output’s sign, but , not . An operation that fails tests like these is called nonlinear.
Switch between As is, Capped, and Folded up, and watch what happens past the limit and below zero.
Capping and folding
The limit is drawn as dashed lines when capping is on.
Describe this picture
One plot of a 48-sample sine-like sequence, amplitude against sample number, with three “Operation” buttons: “As is”, “Capped” and “Folded up”; it starts on Capped. When capping is on, the limit is drawn as dashed lines and labelled "". When an operation is on, the original is drawn faint behind the result. The readout “Samples changed” counts how many of the 48 samples the operation altered.
Capping leaves flat plateaus wherever the original went past the limit, while folding (rectification) lifts every dip below zero to above it.
Worked example
Take the sequence for (zero everywhere else).
Its first difference, : for . The last value comes from the signal dropping back to zero: .
Its running sum, : .
Run a sum back over and you get : exactly again (with ), which is the difference and the running sum undoing each other.
Now cap that same sequence at a limit . Clipped: (only the and the get capped down to ). Rectified instead (no capping, ): .
Where you’ll meet this
A mixing console’s fader is a gain; a sensor’s “zero” adjustment is an offset. Two microphones feeding one recording channel are added together exactly as here. A synthesizer’s tremolo and a video editor’s audio fade are both multiplication by an envelope. A speedometer estimating speed from odometer readings is a first difference; a bank balance is a running sum. And an overdriven amplifier, or a circuit that turns every negative swing of a wave positive, is clipping or rectification.
Reference card
| Operation | Formula | Notes |
|---|---|---|
| Scale & offset | : gain, negative flips it; : constant offset | |
| Addition | sample-by-sample sum | |
| Multiplication | envelope × tone: tremolo, fades | |
| First difference | how much it changed since the last sample | |
| Running sum | total built up so far; undoes the first difference | |
| Clipping | if , else | caps peaks at a limit ; nonlinear |
| Rectification | keeps size, drops sign; nonlinear |