130 lines
5.1 KiB
Markdown
130 lines
5.1 KiB
Markdown
# Audio Visualization for less than $10!
|
||
|
||
## TODO: introduction
|
||
|
||
## TODO: Block diagram
|
||
|
||
## Input signal: ["Line level"](https://en.wikipedia.org/wiki/Line_level)
|
||
|
||
First, let’s get a view of the signal we are accepting on the circuit’s input.
|
||
|
||
### Magnitude
|
||
|
||
With some variation, it's common knowledge (by means of human
|
||
experience) that most devices which accept a set of headphones through
|
||
a 3.5mm "TRS" audio jack will output roughly the same maximum volume
|
||
through that set of headphones.
|
||
|
||
|  |
|
||
|:--:|
|
||
| *A typical, well-loved 3.5mm TRS jack besides a laptop line-out port.* |
|
||
|
||
Don't believe me? Grab a 3.5mm cable meant to connect an output, like
|
||
a phone, to a speaker, and use a multimeter to measure the unloaded
|
||
RMS AC output voltage of a 60Hz tone. Be sure to use the same software
|
||
on multiple devices to get a normalized comparison of different
|
||
hardware.
|
||
|
||
|  |
|
||
|:--:|
|
||
| *We generated [this 60Hz tone](./files/60hz.aac) using Audacity, under Generate > Tone > Sine, 60 Hz, Amplitude 1 (100%)* |
|
||
|
||
- Experiment pitfalls:
|
||
|
||
- Q: Uhh ... which conductors am I measuring?
|
||
|
||
<details> If you're unsure which conductors to measure between:
|
||
the sleeve is usually a common reference ground, but in doubt,
|
||
use your multimeter in continuity mode and see if you can find
|
||
contuinty to the computer case or, for example, the outer shield
|
||
of a USB connector. </details>
|
||
|
||
- Q: Why 60Hz?
|
||
|
||
<details>Not all multimeters are equal, but some things don't
|
||
change: any portable multimeter equipped to probe the 60Hz,
|
||
120VAC signal provided by your household electrical socket is
|
||
also suited to calculate RMS AC voltages for 60Hz sinusoidal
|
||
signals. The Asian-market Fluke 12E+ used here was able to
|
||
measure the highest frequencies our sound cards could produce --
|
||
around 20 kHz -- but a cheaper Centech multimeter struggled past
|
||
a perfectly audible 1 kHz tone.</details>
|
||
|
||
- We tried this experiment on a Thinkpad and a Dell desktop, using
|
||
the `mpv` media player on two Fedora Workstation systems:
|
||
|
||
|  |  |  |  |
|
||
|:--:|:--:|:--:|:--:|
|
||
| *Laptop, 100%* | *Laptop, 130%* | *Desktop, 100%* | *Desktop, 130%* |
|
||
|
||
The signal was identical at 100% volume on each system ... but when we
|
||
asked `mpv` to overamplify the volume to "130%", the laptop and
|
||
desktop began to deviate.
|
||
|
||
<details> I guess that's why I start to get tinnitis after a stressful
|
||
day on my laptop. :joy:</details>
|
||
|
||
### Frequencies
|
||
Depending on what type of music you listen to, you'll find that the
|
||
frequencies that are most pronounced vary widely. If you already have
|
||
a piece of audio in mind that you want to visualize using your board,
|
||
you can use [this neat online tool published by
|
||
Academo](https://academo.org/demos/spectrum-analyzer/) to find some
|
||
frequencies at which the audio peaks.
|
||
|
||
I've already made my choice, of course. Folks who grew up with a
|
||
first-generation PlayStation (or who had older siblings who did, in my
|
||
case) might find my online handle oddly familiar -- as a kid, I always
|
||
liked watching the rain, so when I encontered the stormy
|
||
puzzle-platform level *Hurricos* in my first playthrough of
|
||
Insomniac's _Spyro 2: Ripto's Rage_, I felt right at home.
|
||
|
||
|  |
|
||
|:--:|
|
||
| *Concept art for Hurricos, produced by John Loren for the **Spyro: Reigited Trilogy.*** |
|
||
|
||
The soundtrack for this level shows pronounced frequencies around
|
||
$G_2$ and $G_4$; as it continues, the composer Stuart Copeland (yes,
|
||
[that Copeland](https://www.youtube.com/watch?v=tQq6rXdFGwE))
|
||
integrates some sort of electric arc sound effect reminiscent of
|
||
either a hi-hat or a brush-slapped snare -- the tone centers around
|
||
$G_8$.
|
||
|
||
|  |
|
||
|:--:|
|
||
| ***Hurricos**, as seen by a custom `mpv` visualizer* |
|
||
|
||
Converting those notes back from
|
||
[A440](https://en.wikipedia.org/wiki/A440_(pitch_standard)) under
|
||
[12-tone equal
|
||
temperment](https://en.wikipedia.org/wiki/12_equal_temperament) into
|
||
Hz is easy. If you count the number of downward keyboard half-steps
|
||
$n$ from your note down to $A_4$, your frequency in Hertz will be
|
||
|
||
$$
|
||
f_{\text{Hz}} = 440 \times 2^{\left(\frac{n}{12}\right)}
|
||
$$
|
||
|
||
For example, $G_2 = 440 \times 2^{\left(\frac{-26}{12}\right)} \approx 98 \ \text{Hz}$.
|
||
|
||
#### Pitfalls
|
||
|
||
- How precise should I be?
|
||
|
||
Because of the *quality factor* ($Q$) of the band-pass filters we're
|
||
going to construct, the precision of your measurement here is not
|
||
important past the first one or two significant figures. If you
|
||
can't tell between 800 Hz and 810 Hz, don't fret it. (Get it? Fret?)
|
||
|
||
#### Our values
|
||
|
||
| A440, note | Frequency, Hz | Frequency, rad./s |
|
||
|------------|---------------|-------------------|
|
||
| $G_2$ | 98 | 616 |
|
||
| $G_4$ | 392 | 2463 |
|
||
| $G_8$ | 5588 | 35108 |
|
||
|
||
### An aside about the attributes of (passive) bandpass filters
|
||
|
||
TODO: Band-pass filters .,.,.
|