## The Little Vulgar Book of Mechanics (v0.3.0)

Last updated: February 3rd 2022

Just added this new section to the book.

## Fourier Transform I #

**At all times, I want you to think "We want to build an equalizer. That's is the point of what I'm reading."** Literally, at all points, remind yourself that our goal is to build an EQ.

So here we go, a quick Fourier primer:

**We start with a waveform.**- I.e. The sound we're gonna fuck with.
- I.e. Your death metal riff.

**As a***mathematical object*, the waveform is a function.- It is a
*function of time*. - Think of
*time*as the horizontal axis on the plane. - Just think of
*time*going left to right, like in a DAW.

- It is a
**Let's call the waveform**`s(t)`

, like the mathematicians do.- Using the letter "s" cos of the "signal" concept.
- Using the letter "t" cos time.

- Where we're heading:
**We're going to extract information from**`s(t)`

. **Before some programmers confuse themselves and others:***Neither*of these two programming notions will help you: "Functions are first class, bro" (FP). Or "*everything*is a object, so a function is just another object!" (OOP).- E.g.
`function f() { } let x = f`

and then you say "`x`

is a function." - E.g.
`let square = new Function(x => x * x);`

and then you say "the function`square`

is an object, like everything else!" - Don't bring any of
*that*programming*language*shit here. It's not helpful here.

**To the mathematician, the function is the whole thing.**The graph. The table. However you visualize it.- I.e. the function is all the inputs with all their respective outputs.
- Bringing
*that*to programming: A collection of pairs`[ [1, x(1)], [2, x(2)], ..., [1000, x(1000)] ]`

. - Pairs of inputs and outputs.
*That*is (our programmer translation of) the function as a*mathematical*object.- (Of course, the mathematician thinks of it with infinitely many inputs, going infinitely to the left and right in the time domain, infinitely infinite between any two numbers, and blablabla. They can't control themselves, with their Infinity nonsense.)

**Aside on why we named the waveform**`s(t)`

.- "s" because "signal" (
*Information*-wise. Put on your "Signal Processing" engineer hat.) - "t" because it's a "function of time."
- "Function of time" = time is the input, and the x-axis on a graph.
- (Btw the vertical axis here is gonna be telling us the
*amplitude*.) - Have you seen audio and sound tools referring to "DSP"? That stands for "Digital Signal Processing."
- Your death metal riff, i.e. our waveform
`s(t)`

, is the*signal*we'll be*digitally processing*here.

- "s" because "signal" (
- Stop here and remember:
**We're walking towards the data we would need to build an EQ.** **Enter Fourier: From a clever analysis of**`s(t)`

, we can synthesize two sinusoids of different frequencies.- (Two
*or more*, of course. But think two for now. As a minimal non-trivial mental picture.)

- (Two
**I.e. we "decompose" big fat**`s(t)`

into two thin sinusoids of different frequencies and amplitudes.- In practice: It's an algorithm. Put on the programmer hat. It's just a fucking algorithm.
- (Of course, in the real world it's actually various algorithms, for different practical purposes.)

**The sinusoids, if added back together, untouched, would give us the original waveform back.**- I.e. the analysis gives us a "lossless" decomposition of
`s(t)`

into its "building blocks." - (By "lossless" I mean as a mathematical principle.)
- (Nothing is really "lossless" in practice, except for a
*copy*operation on a digital file.) - In the real world, "lossless" processing = "Rounding errors during computation were not too bad."

- I.e. the analysis gives us a "lossless" decomposition of
**Remember**`s(t)`

is the waveform. The whole thing. The audio recording.- The mathematician does not mean a "return value" of "calling
`s`

" with a`t`

, when he tells you "Let's analyze`s(t)`

" - He means analyze whole thing. The whole signal. Which he refers to as "
`s(t)`

" (and pronounces "s of t.")

- The mathematician does not mean a "return value" of "calling
- Anyway, computationally:
**After analysis, we get two "collections of amplitudes." The data for the two sinusoids.**- Think
`300Hz = [ ... ], 1Khz = [ ... ]`

. - I.e. Separate amplitude data for the "children waves/signals/sinusoids" of the big wave
`s(t)`

.

- Think
**Now we can step through, and mess around with, the amplitudes of each sinusoid.**- We can step through them, individually, in time
- (Not the original
`t`

, obviously. That's the time when we recorded. Not*that*time. But, say, the timeline in your DAW, now during mixing mode.) - Programming speak: We'll step through them using an
`index`

in the collection of amplitudes. - (And likely some arithmetic involving the "sampling rate" of the recording and shit. But let's talk about that later.)

This is just getting started with the *intuition* of the Fourier Transform. The next section will continue the story at this intuition level. And *then* I'll get more into the math. But at this point, you should already understand why this is the basis that lets us e.g. build an EQ (or any other form of processing.)

- Meanwhile, listen to this random track of mine: Zander Noriega - Took Too Long, Already Rotten