this post was submitted on 11 Feb 2024
90 points (100.0% liked)
196
667 readers
74 users here now
Be sure to follow the rule before you head out.
Rule: You must post before you leave.
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
My favorite sin is cos(2πft) = sin(2πft+π/2), because it's easy to work with (because the frequency is exactly f Hz if t is in seconds).
Incomprehensible, tell me more :3
So in electrical engineering and audio applications, we often decompose a signal into a (possibly infinite [1]) weighted sum of sines and cosines. Because each sine has a frequency [2], each weight roughly represents how much of each frequency is in the decomposed signal. Similarly, if such a decomposition is performed on certain test signals, you can characterize how a system will act on any signals.
In audio applications, this has a particularly intuitive interpretation: this characterizes how bright or dull, bassy or trebly, "sounds good" or "sounds like shit", a sound is, depending on what frequencies are present. For a system, it describes what frequencies it emphasizes and can be used as a figure of merit to decide if it is fit for purpose.
Also, because in audio applications we need to do things in nearly real-time, and because we can safely throw out all frequencies above 20kHz (we can't hear them!), all the infinities and most of the calculus drops out in favor of matrix algebra. This is why if you use an equalizer plugin (like ReaEQ or Izotope Ozone) you can see a(n approximate) chart of the frequencies that are sounding at any given time (technically in a window of time that is tiny compared to the progression of the music) and look visually for anything that shouldn't be there.
For example, even if your speakers can't reproduce 60Hz, you can check if a track has 60Hz hum from the power system by looking for a spike in the frequency response at 60Hz that stays up the whole time. To fix it, you would put in a notch filter that "throws out" 60Hz.
I prefer cos to sin because if you solve for both in terms of complex exponentials, you end up with real weights in the answer. Practically [3], cos(t) = 1/2 * ( e^jt + e^-jt ) and sin(t) = 1/(2j) * ( e^jt – e^-jt ), the latter of which is annoying. I prefer the form cos(2πft) because you can measure a real wave directly in terms of its frequency (=1/period). Since the post "asked for" a sin(e), and sin(x+π/2) = cos(x) for any x, I plugged in my "pet" argument to get sin(2πft+π/2).
Also on a more advanced note, if you derive the Fourier transform using e^j2πft as a basis, you end up with a unitary (read: mathematically convenient) transform. Unfortunately, using e^jωt where ω=2πf actually doesn't yield a unitary transform, but e^jωt still constitutes an orthogonal basis so it is still just as used in engineering applications.
I literally have dozens of books about sin(e)s and how to use them to get what I want (Fourier analysis). It's such a deep and interesting topic that I recommend everyone look into at some point.
[1] In the real world, because there is only finite computer storage, any infinities are practically truncated or otherwise approximated away. Still, the full theory is useful for understanding and possibly deriving your way out of some complex calculation.
[2] The input to the sine function sin(2πft) must not have units, i.e. it needs to just be a number. Therefore, if the independent variable t is in terms of some unit, the frequency is in terms of 1/unit. For example, if the input is in seconds, the frequency is in 1/s = Hz.
[3] j = sqrt(-1). Yes, j is for jmaginary. Electrical engineers use j instead of i for the imaginary unit. Also, all arguments to sin() and cos() are in radians, not degrees. π radians = 180°, π/2 radians = 90°, and 2π radians = 360° = 1 rotation.
Still incomprehesible but also somehow very interesting X3 thank u so much for the in-depth explaination! :D (cuz I'm hoping this is in-depth? this is normally when u sqy "actually, that's not in-depth at all" and fill my DMs with an ocean of math LOL) I'm studying something that includes electrical stuff and audio but DAMN thank god it's not this complicated cuz that would be too much for my silly head >u<
What is the difference between these two? I can only imagine the infinite becoming the limit of the computer or maybe just a very very high number
Truncation is a primitive way to approximate something. In any case, truncating a process means to "cut off" the process after some point.
For example, take the number π ≈ 3.141592653589793... ad infinitum. If you need to do a calculation with π, you typically round it to some number of significant figures. For example, 3.1416 is π rounded to 5 significant figures. Truncation is even more primitive; for example, 3.1415 is π truncated to 5 significant figures by simply "cutting off" the rest.
So Fourier analysis in its most general form requires you to compute an uncountably infinite (one element per real number) number of points to represent a frequency response. If your signal has a start time and an end time, you can get that down to a countable infinity (one element per integer) of points. This is equivalent to truncating the signal in time. Audio signals typically have a beginning and end, so theoretically no work needs to be done. However, for real-time processing, we typically break up the signal into tiny windows and analyze each of these windows piece by piece.
Now you can have a computer start your task, but it will never finish it. It won't even finish processing one single window. To do that, you have to "ban" any frequencies above a fixed maximum from your analysis. This is equivalent to truncating the signal in its frequency response. For audio signals, this means that if there is anything above 22050Hz (or half your sample frequency), you throw it out before you process it any further. After this, you get an algorithm that will terminate in a finite number of steps.
Truncating the frequency response results in Gibb's oscillations (audible ringing) if done "irresponsibly". There are other methods (e.g. Cesaro summation) that can be used to reduce these oscillations, but it's kind of a technical topic. Practically, we use filters that "slowly" begin to throw out frequencies lower than the desired cutoff. These "gradual" filters don't cause ringing.
The infinite would be how many measured values are needed to recover the signal and its frequency response without losing any information. You need to iterate over each of these when doing Fourier analysis on a computer.
So I went to recording school several years before I went to engineering school. We were taught about frequency response and how to manipulate audio signals with canned software, but without any of the mathematics behind it. This is about as in-depth as that. Engineering school went into more depth, but considering that I want to actually write audio software, eventually with my own hand-rolled math, I really feel a need to understand Fourier analysis at a depth that my even engineering education alone has been unable to provide.
So there is a much more in-depth explanation (several books worth at least), but I'll spare you the details ☺️. But if you ever want those details, feel free to ask for textbook recommendations.
I used to think math was too complicated for me to learn too. That's why I waited so long to go to engineering school after high school. And it is complicated. But IMO when I approached math like I approached my creative pursuits, i.e. something I planned on retaining for the rest my life, that is when it clicked for me. I have a terrible memory for random stuff that makes no sense and has no pattern. However, if I understand why something is the way it is, and what motivated mathematicians to come up with some new abstraction, it all of a sudden becomes a lot easier to internalize.
Ooo yea that makes the truncation thing a lot clearer thank u! :D and damn writing audio software sounds so cool, I always saw them as black magic X3 I wish u luck in ur studies and work :>
And ye I feel ya on that last paragraph, math is actually so fun when I'm in the mood but I just need to try really hard to get in that mood >u<
Please stop! The flashbacks, oh god, the flashbacks!
Sinusoids have infinite support and therefore never stop 😈.