i love that most of coding adventures these days feels like reinventing the wheel, for the purposes of determining the actual principles behind why a wheel and how the wheel works. not necessarily to build a BETTER wheel, but just because you're curious about wheels and how they work.
Yes indeed. I have researched the Fast Fourier Transform myself a year ago, written my own simple implementation for learning purposes. Learned about complex numbers before it was even taught in math class!
as for the 100k waves signal being indistinguishable from the original, you could subtract it from the original in an audio editor and listen to the difference
The ''person that talk about something with nice visual and get you invested no mater what the subject is'' got to be my favorite UA-cam genre. Edit : mom I'm famous
@@tomnewsom9124 just realizing I've seen plenty of her videos and never actually subscribe because UA-cam just kept recommending them, I'm'a correct that right now.
9:07 I think that's a very accurate simulation of microphones used in aviation. Pilots always sound like that somehow. But for the simulation at least I see two very easy ways in that it could be improved: 1. Instead of a rectangle for the speaker, try to use a bowl or cone shape instead. Currently the sound waves are very unfocused and are getting dispersed too quickly. 2. More space. Due to the very limited space in the simulation, the waves are reflected from the walls and begin bounding around, causing a ton of interference. The microphone very quickly begins to swim in a soup of noise. This would also be part of why adding more simulation steps helped so much: it gave the noise time to settle. Obviously, simply simulating more space would also mean you'd need a lot more particles, but there's also a very simple way to fake it. Instead of letting particles get reflected by the outer walls, you could simply remove them from the simulation and spawn in new particles in low-density areas around the walls, essentially simulating air leaving and rushing into the volume from outside. Alternatively, and visually more interesting, you could try adding ripple shapes around the walls to work as noise dispersion. But I also get that this wasn't the main focus of the video and I probably already put too much thought into it. But maybe it'll help if you were intending to make a full version of "Bad Apple, but the audio is a fluid simulation too". The part on the DFT was great and I'm looking forward to the video on the FFT. Also: Yay, cat. Very cute.
I also seen an issue in the speed of the speaker. Based on the speed that sound waves propagate, it seems to be supersonic... No real-life speaker moves that fast, so I can't say exactly *what* effect it would have on audio quality, but I feel that it can't be good.
@@erictheepic5019 piling onto this critique, the speaker driver has mass and the voice coil should need to accelerate and decelerate the driver. There was also a lot of reflected interference from sound bouncing off the walls. So depending on the type of microphone, the recorded sound isn't necessarily just the voltage. And when driving the speaker the voltage isn't just an absolute position of the cone. The microphone must compensate for those raw voltages to define the actual waveform, but similarly the circuit driving the speaker needs to compensate for the physical properties. Assuming that the microphone is making those calculations itself, Sebastian really just needs to adjust the speaker design so that there are different drivers which are tailored to operate in notched filtered frequencies which aren't as affected by trying to accelerate the speaker cone outside their range. This is easiest to accomplish with a sub, a mid range, and a tweet, working together. Baffling on the walls should absorb any sound pressure and impart no reflected resonance. The software mic would need to have a gain amplified to pick up the reduced audio sound and normalize the volume again. I'd be real curious how this sort of processing would affect audio fingerprinting as the sampled audio would not match the original anymore from a binary perspective, and having the different speaker positions offset would affect the phasing at different frequencies. Passing it through the transform again, I expect that the same frequencies are found again even though the raw data would look indistinguishable.
@@timschulz9563that was my instinctive thought because the visualisation makes it look like it's using finite element method or similar but if the simulation is based on particles moving around a region then removing particles is going to mess things up.
Fortunately, the field of programming is vast enough that there is enough room for EVERYONE to be a bad programmer. So equal footing as long as you are legitimately trying.
The thing with this kind of content is, despite him hinting at it (which is great already), you just can't see the hours and hours of failing and trying to understand what's wrong. It seems so easy watching him do it, but really i have no doubt there was painful work here, he's smart for sure, but his "can do" attitude certainly does more of the work than pure brain power.
@@GabrielPettier Absolutely. This is the edited shots of all his SUCCESS. Not the hours of hair pulling "I'm an idiot, why isn't this working. Dang it, I freaking missed a SPACE in the variable?"
This world is full of people that are insanely smart. But being this smart and also so great at communicating/teaching is a feat even many professors do not achieve. I take my hat off to you
These coding adventures always excite me and at the same time reignite my imposter syndrome when I realize that I couldn't be farther from making any of these on my own without a ready solution
Sometimes it's just a matter of giving yourself time to think about the problem and read through the theory. These videos are awesome but they hide most of the actual work behind the scene required to pull them off
@@uhrguhrguhrg not most of his coding adventures though, you'd need to be pretty good at math to do these, and I'm just not. It's not easy to learn math at all, and so far I've failed miserably each time I tried to do so, but I keep trying.
@@kurushimeeMaths itself is not the difficult part (usually). It's just not very accessible because there often aren't many resources to give people without an aptitude towards abstraction a good grip on the concepts. With that said, these resources and ideas do exist: They are what makes 3blue1brown, etc. successful. You're not bad at maths, you can do it! It's that you are trying to rebuild centuries of experience, experimentation and research from nothing in a few hours or days. You can do it! Many times have I heard that people don't understand a topic until someday they hear somebody explain it in whacky way and it just clicks for them.
@@kurushimee then make small projects about the math you're learning. You can't just bash your head against theory, practice is also required to understand things.
I love the confluence of 3b1b and Sebastian. Please let these two collaborate in the future! They are both so very good at visualizing the learning process. I feel like either of them could give a masterclass on effective visual communication, so I would love to hear the two of them talking about what they've learned.
Oh my god. As I'm a programmer and a musician, I've found myself attempting to make audio plugins and such multiple times now, but the DFT/FFT was what always stopped me. I am yet to find a video which explains it in such a clear and good way as u do, thank u Sebastian, keep up the good work! Coding Adventures has been my favorite series on UA-cam for a while now
Don't know how it's taken me this long to notice, but I really appreciate that you use a darkmode background for your videos, you speak softly and calmly, and you ALWAYS put in the effort to do subtitles. An amazing teacher and you always pick the coolest topics and explain them so well. I'm due for my yearly rewatch of your boolean logic videos I think.
I'm currently working on implementing a sound engine in a project I'm making. I can not get it to work at all and literally said to myself *"Man, why can't there be a Sebastian Lague video about fourier transforms. That would make my job so easy!"* Thanks for literally saving my project!
Dude, the way you explain things is admirable. Natural teacher. For those of us that struggle with numbers, you make understanding possible. Showed my son your explanation of sin and cos and he was like "now I get it", and that sir is invaluable. Thank you for the excellent videos.
I work at an ISP, so we deal a lot with spectral analysis and similar concepts when implementing DWDM. It's awesome seeing someone coming across a lot of the concepts I know, except coming from a starting point of audio processing. Great video as always!
Seeing the 3b1b DFT visualization animated with tunable parameters was absolutely beautiful! Also, as someone who has been working with Fourier transforms for many years now, it's very nice to see someone going through the process of gaining an intuition for how sample duration and sampling frequency affect the frequency domain resolution. Thank you so much for sharing some of the beauty that's hidden behind maths!
I can't code, I don't understand more than half of what you are doing, yet every coding adventure of yours is amazing dude, I hope you keep doing this!
I am a Senior, graduating from college next year. Since the Junior Dev market has been so bad here in the US, I find myself struggling to keep going at it. Thanks to you Seb. I just watch one of your videos and feel motivated to keep studying and grinding. Really re-energizes my curiously and drive.
"In today's episode of Coding Adventures, Sebastian proves that you can speak German by just speaking in English backwards!" Love your videos! They remind me why I wanted to get into coding!
When I was playing with reversing speech years ago, I observed the reversed audio sounded Scandinavian, so I recorded myself saying that and learned that backwards the word Scandinavian sounds like "naervindanahks"
I work as a scientist in X-Ray crystallography - which basically relies on 3D Fourier synthesis to generate the positions of atoms within a crystal, so I thoroughly enjoyed this little adventure getting close to my field! haha, great to see you planning on tackling FFT, bravo and goodluck!!!
i’d just like to explain why it was "necessary" to double the amplitude of all of the frequencies except for the 0 and N/2 frequencies in order to get the correct output. it mostly has to do with the fact that a "true" discrete fourier transform does actually output a complete N amount of input signals for a given input signal of length N. however, due to aliasing and the nyquist sampling theorem, the second half of the output array effectively ends up measuring "negative frequencies", mirroring the first half of the array. eg, the exact frequency measured by each element of the output array would look something like [0, 1, 2, 3… N/2-1, N/2, -N/2+1.. -3, -2, -1]. "but how does a negative frequency make sense?" it’s pretty simple actually. having a negative frequency can be thought of as wrapping the signal around the circle at the *opposite* direction, but at the same speed to its corresponding positive frequency. it’s helpful in this case to interpret the "center of mass" of the spiraled up waveform as also having a horizontal and vertical component, and not just as a magnitude and phase*. the horizontal component measures how much of a pure cosine wave at the given frequency is present in the signal, and the vertical component does the same for a pure sine component. it turns out that, for any given negative frequency, its horizontal component (or real part) stays unaffected, but its vertical component (or imaginary part) gets flipped around the x axis, or effectively negated. this holds true for all frequencies between 1 and N/2-1, but not for the frequencies 0 and N/2 as they only are measured once each even by the full FFT. now why does this matter? when you do an inverse DFT you should expect that you get exactly the signal that you put into the DFT, and indeed you do thanks to these negative frequencies. notice that *all* of the frequencies play a role in the final sum, meaning that every frequency (that has a negative) will be summed with its negative; because the real parts are the exact same and the imaginary parts are negations between the two, the effect of the summation is that the real part of each frequency finally gets doubled, while the imaginary part vanishes due to additive inverses. the negative frequencies account for the missing half of the amplitude that sebastian had to "double" as a shortcut to get the correct result basically. TLDR: the full DFT calculates corresponding negative frequencies along with the positive ones, except for the frequencies 0 and N/2. when an inverse DFT is performed, these negative frequencies account for the missing half of the amplitude that occurred when only the positive frequencies were considered.
It's absolutely insane the amount of effort that goes into these videos. I really liked the final showcase of only using the X most "important" frequencies, it's impressive how many different frequencies human speech makes/requires.
to be fair, the demonstration is a bit deceptive. because Sebastian's voice is not some repeating signal, the highest amplitude frequencies are background noise, and then the algorithm has to spread out the voice part over many quiet frequencies. those frequencies aren't actually there in the continuous signal (which is how your ears and brain analyse sound), but because of the discrete sampling it's mathematically indistinguishable. had you isolated small portions of the recording, such that every portion only contained some specific sound (part of a letter basically), you would need far less frequencies to reconstruct understandable speech, as the frequencies calculated by the DFT would match very closely the actual signal of the sound. this is how audio compression and processing algorithms actually work.
@@malbacato91 wow that is super interesting. Thanks! Had to read it like 5 times tough. So what you‘re saying is that audio compression algorithms first split a recording into many chunks and then apply the DFT for each one? If so I have some follow-up questions that I’m hoping you could help me out with: 1. Is there an optimal way to choose the chunk size? 2. With this approach we now have to save a spectrum for each chunk right? So if the chunk size is too large, can we end up with more frequencies than using the entire recording? A larger file so to say? 3. Is there a further optimization possible by noticing that a frequency can occur in multiple chunks? 4. When replaying the spectrums chunk by chunk, is it ever a problem that a transition is noticeable? Like a jump in the signal? Does this require further processing? Thank you for your time!
@@Laiserball8 It's a two-step process, and the frequency domain representation is actually used to *remove information* and thereby make the signal *more compressible* (lowering its entropy) based on a "psycho-acoustic model" with rules like "humans can't really hear the difference between a high-amplitude wave alone and that same high-amplitude wave plus a much lower-amplitude wave close in frequency". Essentially you remove components of the signal that the model deems inaudible, then reconstruct the audio, and then compress the simplified, lower-entropy wave using ordinary lossless compression methods. The actual compression part of MP3 isn't all that different from gzip compression. There are also simpler schemes available. About twenty years ago when I was young and promising :) one of my fellow students and myself thought we invented a super basic sound compression algorithm that we called logsound during a telephone call. It began with me asking questions about CD audio - I was a hifi guy in a small way but had only just begun to learn about digital signal processing. I argued that if we perceive an amplitude of 65536 relative to one of 32768 (half) in the same way we do an amplitude of 2 to 1, using linear sample values would result in _subjectively_ "poor resolution with respect to amplitude" for weak (components of) a signal, while at the same time "wasting resolution" for loud parts of the signal. My friend is a very skillful coder and quickly implemented linear and logarithmic downsampling to 8 bits so we could test this, and lo and behold, while both 8-bit files produced from processing a 16-bit file ripped from a CD, the version using the logarithm of the amplitude rather than the amplitude itself was clearly superiour. The irony is that we later discovered that the telephone network actually made use of this very trick already! So the whole time when we were discussing and testing "logsound", we were unknowingly using the very encoding scheme we were "inventing". Encoder and decoder can both be implemented with a simple lookup table (there are only 65536 possible sample values, so precalculate the logarithm of them all and store your 8-bit downsampled logsound value, and you can look them up by using the sample value as the index; for the decoder you go the other way, but only need 1024 entries if, like the phone networks did, you used 8-bit logarithmic values). For those nerdy enough to want to know more about this - or, I guess, those who think I'm making it all up, here is some more info on such a scheme: www.nxp.com/docs/en/application-note/ANE408.pdf
25 years ago I cried tears of blood at the university while learning about discrete Fourrier transformation and Nyqist-Shanon theorem. And now, look at me, I enjoy watching a video talking about this :D
i remember when after 16 years, a human being accidentally let me see fft(log10(fft())) i was so pissed it took me three fing years to touch it and then they have the nerve to microwave me when i'm in bed. they're a bunch of guys who wear aprons.
@@atomictraveller I feel like this is some sort of deep joke where the fast fourier transform is used to look like boobs or something. Maybe I don't get the joke though.
@@Alexander_Grant that short expression there is the cepstrum. that's all the notation i saw and all it needs. if you use fft some, you can infer the log10 applies to the mag bins to nyquist same as you would for a graphic readout. then you fft those and you have the cepstrum. now you can do formant shifting and higher level spectral ops like that. that's 16 years of car chases and fist fights and plane crashes into a burning lake of dog farts.
This is one of the few channels I will drop what I am doing to watch. I don't even use notifications often but this channel I do. Sebastian you are great! Thanks for your amazing work!
Everytime I start one of Sebastian's videos I wonder how he can make the subject interesting. Everytime I'm totally blown away by his ideas and execution.
I love your videos! The editing, the quality, the voice over. You always sound so excited and curious. Ive obviously not watched the video within this split second of me commenting but I know it's going to be good! Thank you for your content!!
s0 = 1; s1 = 0; w = 2 * pi * freq / samplerate // loop s0 -= w * s1; s1 += w * s0; // s0 (cosine) is a half sample behind s1 (sine) at this point. very occasionally renormalise s0 and s1 no one else ever notices. people really are stupid. graphics programmers don't understand inter[olation isn't first order.
I love coding adventures because this dude just calmly explains how to do the most complicated things ever as if it is just everyday knowledge. This man is what I want to be one day as a programmer.
Yet another masterpiece of a video. You could teach anything and it would be fascinating because of how you approach things. If only programming was as easy as you make it seem... I absolutely understand that this is because you are infinitely more intelligent than I will ever be, but I love how interesting you make things and it inspires me to explore more fun programming concepts like these.
This was the best video by you yet, at least for me as an audio engineer. It made me feel smart that I knew a bunch of stuff that you didn't, especially: "you don't need to set a max frequency since that is determined by the sample rate." But your approach also showed some insights that were very very interesting! Also I learned a bunch of stuff I didn't know, particularly about the actual math. And the sounds you made make me want to become a programmer to unlock this world of strange sound processing you are stumbling through for creative uses. And as always, your visualizations are art. By the way, fun fact about the aliasing frequencies: they are a reflection off the "ceiling" set by the nyquist frequency. You get this commonly in digital sound processing with purposeful distortion, which is why distortion plugins for DAWs typically have oversampling built in, to stop aliasing and then filter out the higher frequencies that would cause aliasing, because aliasing sounds really unmusical.
as a retired programmer, i really enjoy watching you code even when the subject isn't something i'd even think of being interested in. thank you for your work
@@average6317 I don't think it's a forced smile, he doesn't need to force his voice like troublechute does.. but the fact that it's not forced makes it that much creepier... he's not a creep though, but I feel your pain
The reflections from the boundaries of the simulation box at 9:30 were probably affecting the sound quality a lot. In electromagnetics, people use absorbers or perfectly matched layers (PMLs) at the boundaries to remedy this issue.
I do enjoy seeing content about sound related things when it comes to data, but I've seen it already many times, what I haven't seen is running a air sim to make that sound! If you are to continue this project please please keep doing the air sim, don't get me wrong I do enjoy the Fourier Transform stuff too, just the simulated sound instead of emulated sound is so cool!
1. I'm really happy to see a new video appear! Once again, it looks very interesting. 2. 9:55 It's possible that the saturated sound is coming from the loudspeaker, which sometimes goes faster than the speed of sound. So perhaps slowing down the sound even more would result in a much clearer sound. 3. I feel like there's a lot of content that could be used for another episode, like slowing down or speeding up a sound without changing its pitch, or changing the pitch of a sound without slowing it down or speeding it up. Also, I'm pretty sure that a prism performs a Fourier transform on light. 4. I really like your way of programming, which consists in understanding things and creating them from scratch. That's something rare, and it's precisely what I'm looking for and why I like your channel. The amont of visualization is also a great idea.
The idea that something that exists in real life like a prism can essentially perform an algorithm is incredible and shows how closely connected digital concepts are to the real world. Reminds me a bit of how motors and gear shifting exists on the microbiological level.
@@SolanaarYes! I just recently saw this video by Smarter Every Day about these bacterial flagellar motors. I previously thought these things probably just vibrate or wiggle in some way but no there are actually gears and rotation involved on molecular level and it's amazing.
Fantastic video as always. I sort of understood the principle behind Fourier transforms before, but now I have a much more robust understanding that will surely come in handy some day! :)
This video teaches you more than 3 CS courses on signal processing combined.. truly incredible.. if we were thought like this in school and uni, everyone would be a genius ❤
I suffered so much while I was learning things about waves and their interactions during cyber security training at the academy, and 5 years later I see this video. How much simpler things would have been if I had seen it then
A Sebastian Lague video about audio programming? Is it my birthday? Incredible video, and I’d love to see more stuff like this in the audio space as someone with aspirations of creating audio software.
In my field of sleep research, we use the fast fourier transform to help visualise sleep stages - if you search for images of something like "hypnogram spectral analysis" you will see how the sleep stages pop out. A video looking at how to code this would be interesting. Thanks for your very interesting videos
So much effort to these videos for such a long time (years by now) and yet 1M subs. That's something that touching. Why aren't my peers that interested??
Worked in audio for a bit in the past. It has been my beloved hobby before and after. Always eager to learn more about how stuff works in the field. Was happily using DAWs without knowing all the complex coding that goes on behind the scenes. Now I feel like I know a fraction of a 10th of a percent of it. Thanks! :D
very interesting topic! just a few hours ago, i was rewatching one of your videos, and i was thinking "when's the next video gonna be out?"... well, my answer has arrived.
Absolutely gorgeous. Reminds me of how fascinated / inspired I was after the first time I watched 'The Conversation' .. watching the character do this kind of calculation and reconstruction with his home-grown recording equipment. I marvel at the knowledge and skill, and this was so beautifully presented.
I understand next to nothing you're talking about, I'm only in tenth grade, but your calm voice and the nice visuals are so calming to me, it sounds like you are constantly smiling whilst recording. And I get so excited whenever you talk about something I actually already learned about in school. I hope one day, I will understand everything you're doing.
This video was delightfull. And this is coming from a guy who already had boring college classes that taught this. Congratulations on the incredible explanation! I love your channel for these!
Whenever I watch a Sebastian Lague video it reminds me how much fun my side project is and I go and do it instead of doom scrolling. Thanks Sebastian ☺️☺️
I really hope you see this comment! So, this is actually something I've been thinking about for a long time. I'm a music producer, and aspiring video game programmer, and I've been thinking for a while how there hasn't ever really been any huge advancements in realistic live soundstaging technology, and if someone did it they could revolutionize gaming. ...But, frankly, I'm not a great programmer, so I haven't gotten anywhere close to the point of doing the research to make this a reality... Anyway, here's my idea, that I think might actually have just become possible with the research you've just done: In music production, there are things called Impulses. Frankly, I don't know exactly how they work, but basically you record a simple sound in an area, and then you can use that sound as an impulse, to create a reverb effect. Any sound you play through this reverb effect will sound like it was recorded in the same location as the impulse. And I've thought for a long time now, that if you could take impulses of computer generated spaces, you could create an accurate soundstage of that space. Imagine firing a gun in a tunnel, and actually listening to the sound of it reverberate down that entire space. Or something shifts in the distance, and you can hear it, and know accurately where it is, just the same as you could in real life. Or take advantage of the acoustics of an area, bounce a sound off of a wall to make it sound like it's coming from a different direction. All of this would theoretically be possible if we could take live impulses of computer generated spaces... And that's basically exactly what you've just programmed. I never thought to simulate the air itself. That's actually genius.
You are a god. That Fourier transform visualisation is not only the best Fourier explanation I've seen, but probably the best mathematical explanation of anything I've ever seen on UA-cam.
It was amazing! You visually presented everything I learned in my university Signals and Systems course, making the concepts much more understandable for those who find them difficult to grasp.
The DFT visualization is the perfect addition to the 3b1b video. It's one of the most beautiful (and useful!) bits of maths and seeing it presented in such an effective way is awesome
I love messing with fourier transforms, but you transmitting sound within a fluid sim is probably my favorite part of the video. it sounded like an old-timey gramophone recording!
at 31:01 i’m pretty sure that “strange background noise” is naturally generated reverb. This is because the “recording room” you generated is a box with perfectly flat walls and no pass through for the sound waves to disperse. You could work around this by simulating an anechoic chamber with spiked walls and a high absorption rate. I’d assume this would remove that nasty echo you would expect from a polished concrete room. (see reverberation chamber) TLDR: what you thought was a bug is actually just physics :D
@@Shlaboza yeah but i highly doubt he's still using the rectangle room at the point in the video when he's reconstructing the fourier transform, if he was using the room model you would hear room modes/resonances (and the distortions we heard because of the way the air particles interacted), and not a perfectly smeared signal
Thank you for actually showing this in terms of code. In every other video explaining the Fourier transform, they just start jotting down a bunch of Greek symbols in doctor's handwriting like it's supposed to make immediate sense. I don't understand mathematical notation, so this is a blessing. I can't wait for your FFT implementation!
Incredible video! When working in automobile industry R&D, we had a rule of "sample at least 10 times the maximum frequency you want to observe". Even that is true sampling a little above Nyquist frequency to ensure no frequency information is lost, some amplitude data of the waves can be lost. There was a table with those results (I could not find it sadly), but sampling at Nyquist we could ensure like we kept 50% of the average amplitude. With 10 times the maximum signal frequency (5 times Nyquist's), if I remember correctly, the sampled signal preserves around 95% of the average amplitude. The amplitude were very significant for vehicle R&D, we were usually interested up to 50Hz, so we sampled at 512-1024 Hz (just to be safe). For audio, I think it is ok some kind of loss in higher frequencies, that's probably why standard samples are 44-48 kHz. Just wanted to share how FFT impact places we not even imagine, thanks again for the great content!
29:20 One way to test for "non-integer frequencies" is to use the Goertzel algorithm (with slight modifications), its also faster than the FFT when you want to detect only a few particular frequencies To get hid of the bumps you can apply a window function to the input signal to smooth a few of the first and last samples
I love how you answer your own question in this video! At the beginning you wonder "How can we store something as complex as an audio signal with so few samples", and by the end you're covering the Nyquist Shannon theorem. Signal processing and audio is one of my favorite fields, and it's always great seeing someone else discover it -- especially with your beautiful animations!
29:17 Those bumps are the secondary lobs of the sinc function that is the correct result for a Fourier transform of a non-periodic (with a finite number of sample) signal. It's working as intended, you just need an infinite number of samples to make them disappear, and then you get a Fourier series. It is also intended behaviour to have the energy of frequencies that are not a multiple of the frequency resolution shared on both sides. The max frequency that you need to look for is 2 times your sampling rate, a time discreet signal can not mathematically contain any frequency higher.
I was like bet, another indepth coding exploration of some interesting programming principle. Then the legend BUSTS OUT THE FLUID SIMULATION from earlier and re-records the god damn sound in the simulation. Was not expecting that. He's insane
Sebastian Lague’s videos trick me into thinking programming is fun. Thanks!
"trick"
@@Agent-uj8ud and easy
It used to be 😭
It is. Or at least, it can be.
It is, it's just math with a fancy calculator. Who wouldn't have fun with that?
i love that most of coding adventures these days feels like reinventing the wheel, for the purposes of determining the actual principles behind why a wheel and how the wheel works. not necessarily to build a BETTER wheel, but just because you're curious about wheels and how they work.
Yes indeed. I have researched the Fast Fourier Transform myself a year ago, written my own simple implementation for learning purposes. Learned about complex numbers before it was even taught in math class!
as for the 100k waves signal being indistinguishable from the original, you could subtract it from the original in an audio editor and listen to the difference
❤😂🎉😢
How this dude comment is 6 hr ago. Since video is 9 min old
@@akc21adtpatreon maybe
considering all the work is already done, he can probably just do it in unity and it'd be faster than booting up audacity :D
No need to subtract it.
Just reverse the phase, it will subtract itself.
The ''person that talk about something with nice visual and get you invested no mater what the subject is'' got to be my favorite UA-cam genre.
Edit : mom I'm famous
3blue1brown
@@jeffreyrehm8320 yup
sebastian lague and posy are some of my favorite youtubers. always a good time.
Freya Holmér - beautiful videos about splines, beziers and plenty more
@@tomnewsom9124 just realizing I've seen plenty of her videos and never actually subscribe because UA-cam just kept recommending them, I'm'a correct that right now.
9:07 I think that's a very accurate simulation of microphones used in aviation. Pilots always sound like that somehow. But for the simulation at least I see two very easy ways in that it could be improved:
1. Instead of a rectangle for the speaker, try to use a bowl or cone shape instead. Currently the sound waves are very unfocused and are getting dispersed too quickly.
2. More space. Due to the very limited space in the simulation, the waves are reflected from the walls and begin bounding around, causing a ton of interference. The microphone very quickly begins to swim in a soup of noise. This would also be part of why adding more simulation steps helped so much: it gave the noise time to settle.
Obviously, simply simulating more space would also mean you'd need a lot more particles, but there's also a very simple way to fake it. Instead of letting particles get reflected by the outer walls, you could simply remove them from the simulation and spawn in new particles in low-density areas around the walls, essentially simulating air leaving and rushing into the volume from outside.
Alternatively, and visually more interesting, you could try adding ripple shapes around the walls to work as noise dispersion.
But I also get that this wasn't the main focus of the video and I probably already put too much thought into it. But maybe it'll help if you were intending to make a full version of "Bad Apple, but the audio is a fluid simulation too". The part on the DFT was great and I'm looking forward to the video on the FFT.
Also: Yay, cat. Very cute.
I also seen an issue in the speed of the speaker. Based on the speed that sound waves propagate, it seems to be supersonic... No real-life speaker moves that fast, so I can't say exactly *what* effect it would have on audio quality, but I feel that it can't be good.
Yes but that's because in aviation it's customary to chew on the microphone to soothe the nerves and fend off boredom, it's common knowledge.
@@erictheepic5019 piling onto this critique, the speaker driver has mass and the voice coil should need to accelerate and decelerate the driver. There was also a lot of reflected interference from sound bouncing off the walls.
So depending on the type of microphone, the recorded sound isn't necessarily just the voltage. And when driving the speaker the voltage isn't just an absolute position of the cone. The microphone must compensate for those raw voltages to define the actual waveform, but similarly the circuit driving the speaker needs to compensate for the physical properties. Assuming that the microphone is making those calculations itself, Sebastian really just needs to adjust the speaker design so that there are different drivers which are tailored to operate in notched filtered frequencies which aren't as affected by trying to accelerate the speaker cone outside their range. This is easiest to accomplish with a sub, a mid range, and a tweet, working together. Baffling on the walls should absorb any sound pressure and impart no reflected resonance. The software mic would need to have a gain amplified to pick up the reduced audio sound and normalize the volume again.
I'd be real curious how this sort of processing would affect audio fingerprinting as the sampled audio would not match the original anymore from a binary perspective, and having the different speaker positions offset would affect the phasing at different frequencies. Passing it through the transform again, I expect that the same frequencies are found again even though the raw data would look indistinguishable.
Or change the boundary conditions to not reflect but absorb the waves.
@@timschulz9563that was my instinctive thought because the visualisation makes it look like it's using finite element method or similar but if the simulation is based on particles moving around a region then removing particles is going to mess things up.
The FFT is seriously clever and enabled a lot of modern technology. It deserves an entire video tbh
Veritasium has an entire video on it
But not about coding it.
@@rarelycomments Reducible has a great video on it.
Fuck modern technology!
It may be the most important algorithm of the modern age.
Just did a Fourier transform exam last week
Sebastian always blows my mind while making me feel like a bad programmer
Fortunately, the field of programming is vast enough that there is enough room for EVERYONE to be a bad programmer. So equal footing as long as you are legitimately trying.
try be very good at something (just a single domain, either is game dev, web designer, machine learning) and you'll feel better.
The thing with this kind of content is, despite him hinting at it (which is great already), you just can't see the hours and hours of failing and trying to understand what's wrong. It seems so easy watching him do it, but really i have no doubt there was painful work here, he's smart for sure, but his "can do" attitude certainly does more of the work than pure brain power.
@@GabrielPettier Absolutely. This is the edited shots of all his SUCCESS. Not the hours of hair pulling "I'm an idiot, why isn't this working. Dang it, I freaking missed a SPACE in the variable?"
@@GabrielPettier right, every good piece of content requires hard work, debugging and curiosity.
This world is full of people that are insanely smart. But being this smart and also so great at communicating/teaching is a feat even many professors do not achieve. I take my hat off to you
These coding adventures always excite me and at the same time reignite my imposter syndrome when I realize that I couldn't be farther from making any of these on my own without a ready solution
Sometimes it's just a matter of giving yourself time to think about the problem and read through the theory. These videos are awesome but they hide most of the actual work behind the scene required to pull them off
any big project can be divided into smaller solveable projects
start small, experiment, prototype, and you'll learn as you go
@@uhrguhrguhrg not most of his coding adventures though, you'd need to be pretty good at math to do these, and I'm just not. It's not easy to learn math at all, and so far I've failed miserably each time I tried to do so, but I keep trying.
@@kurushimeeMaths itself is not the difficult part (usually). It's just not very accessible because there often aren't many resources to give people without an aptitude towards abstraction a good grip on the concepts. With that said, these resources and ideas do exist: They are what makes 3blue1brown, etc. successful.
You're not bad at maths, you can do it! It's that you are trying to rebuild centuries of experience, experimentation and research from nothing in a few hours or days.
You can do it! Many times have I heard that people don't understand a topic until someday they hear somebody explain it in whacky way and it just clicks for them.
@@kurushimee then make small projects about the math you're learning. You can't just bash your head against theory, practice is also required to understand things.
I love the confluence of 3b1b and Sebastian. Please let these two collaborate in the future!
They are both so very good at visualizing the learning process. I feel like either of them could give a masterclass on effective visual communication, so I would love to hear the two of them talking about what they've learned.
I would add Reducible as well!! The trio for maths and programming!
This actually sounds like a pretty interesting video idea!
Have a look at braintruffle. His most recent video on orbital mechanics was extremely mind-blowing to me.
@@nankinink For real! The first time I watched a Reducible video, I spent the whole video wondering why 3b1b was sounding different 😂😂
Oh my god. As I'm a programmer and a musician, I've found myself attempting to make audio plugins and such multiple times now, but the DFT/FFT was what always stopped me. I am yet to find a video which explains it in such a clear and good way as u do, thank u Sebastian, keep up the good work! Coding Adventures has been my favorite series on UA-cam for a while now
You're me except you actually tried, I've been thinking of making my own plugins for years haha
18:00 Sebastian was the cat all along
18:04: What??? I never knew you were a cat! I was already impressed, but now you completely blew my mind!
we went from watching cat videos to watching videos made by cats !😀
Don't know how it's taken me this long to notice, but I really appreciate that you use a darkmode background for your videos, you speak softly and calmly, and you ALWAYS put in the effort to do subtitles.
An amazing teacher and you always pick the coolest topics and explain them so well. I'm due for my yearly rewatch of your boolean logic videos I think.
I'm currently working on implementing a sound engine in a project I'm making. I can not get it to work at all and literally said to myself *"Man, why can't there be a Sebastian Lague video about fourier transforms. That would make my job so easy!"*
Thanks for literally saving my project!
Dude, the way you explain things is admirable. Natural teacher. For those of us that struggle with numbers, you make understanding possible. Showed my son your explanation of sin and cos and he was like "now I get it", and that sir is invaluable. Thank you for the excellent videos.
At 12:20 I liked that the slow sound was in red, and the fast sound was in blue. Nice touch hinting at red/blueshift
I hope you know how much joy seeing a Sebastian Lague upload brings!
*gaping mouth* I f*cking love science!!!!
I work at an ISP, so we deal a lot with spectral analysis and similar concepts when implementing DWDM. It's awesome seeing someone coming across a lot of the concepts I know, except coming from a starting point of audio processing. Great video as always!
Seeing the 3b1b DFT visualization animated with tunable parameters was absolutely beautiful!
Also, as someone who has been working with Fourier transforms for many years now, it's very nice to see someone going through the process of gaining an intuition for how sample duration and sampling frequency affect the frequency domain resolution.
Thank you so much for sharing some of the beauty that's hidden behind maths!
I can't code, I don't understand more than half of what you are doing, yet every coding adventure of yours is amazing dude, I hope you keep doing this!
I am a Senior, graduating from college next year. Since the Junior Dev market has been so bad here in the US, I find myself struggling to keep going at it.
Thanks to you Seb. I just watch one of your videos and feel motivated to keep studying and grinding. Really re-energizes my curiously and drive.
"In today's episode of Coding Adventures, Sebastian proves that you can speak German by just speaking in English backwards!"
Love your videos! They remind me why I wanted to get into coding!
As a German I thought this sounded a lot like Danish.
When I was playing with reversing speech years ago, I observed the reversed audio sounded Scandinavian, so I recorded myself saying that and learned that backwards the word Scandinavian sounds like "naervindanahks"
I work as a scientist in X-Ray crystallography - which basically relies on 3D Fourier synthesis to generate the positions of atoms within a crystal, so I thoroughly enjoyed this little adventure getting close to my field! haha, great to see you planning on tackling FFT, bravo and goodluck!!!
i’d just like to explain why it was "necessary" to double the amplitude of all of the frequencies except for the 0 and N/2 frequencies in order to get the correct output. it mostly has to do with the fact that a "true" discrete fourier transform does actually output a complete N amount of input signals for a given input signal of length N. however, due to aliasing and the nyquist sampling theorem, the second half of the output array effectively ends up measuring "negative frequencies", mirroring the first half of the array. eg, the exact frequency measured by each element of the output array would look something like [0, 1, 2, 3… N/2-1, N/2, -N/2+1.. -3, -2, -1]. "but how does a negative frequency make sense?" it’s pretty simple actually. having a negative frequency can be thought of as wrapping the signal around the circle at the *opposite* direction, but at the same speed to its corresponding positive frequency. it’s helpful in this case to interpret the "center of mass" of the spiraled up waveform as also having a horizontal and vertical component, and not just as a magnitude and phase*. the horizontal component measures how much of a pure cosine wave at the given frequency is present in the signal, and the vertical component does the same for a pure sine component. it turns out that, for any given negative frequency, its horizontal component (or real part) stays unaffected, but its vertical component (or imaginary part) gets flipped around the x axis, or effectively negated. this holds true for all frequencies between 1 and N/2-1, but not for the frequencies 0 and N/2 as they only are measured once each even by the full FFT. now why does this matter? when you do an inverse DFT you should expect that you get exactly the signal that you put into the DFT, and indeed you do thanks to these negative frequencies. notice that *all* of the frequencies play a role in the final sum, meaning that every frequency (that has a negative) will be summed with its negative; because the real parts are the exact same and the imaginary parts are negations between the two, the effect of the summation is that the real part of each frequency finally gets doubled, while the imaginary part vanishes due to additive inverses. the negative frequencies account for the missing half of the amplitude that sebastian had to "double" as a shortcut to get the correct result basically.
TLDR: the full DFT calculates corresponding negative frequencies along with the positive ones, except for the frequencies 0 and N/2. when an inverse DFT is performed, these negative frequencies account for the missing half of the amplitude that occurred when only the positive frequencies were considered.
Thanks! I was wondering about that here.
Yep, as someone who knows a bit, i was gonna point out, thanks for doing that! ^^
It's absolutely insane the amount of effort that goes into these videos. I really liked the final showcase of only using the X most "important" frequencies, it's impressive how many different frequencies human speech makes/requires.
to be fair, the demonstration is a bit deceptive. because Sebastian's voice is not some repeating signal, the highest amplitude frequencies are background noise, and then the algorithm has to spread out the voice part over many quiet frequencies. those frequencies aren't actually there in the continuous signal (which is how your ears and brain analyse sound), but because of the discrete sampling it's mathematically indistinguishable.
had you isolated small portions of the recording, such that every portion only contained some specific sound (part of a letter basically), you would need far less frequencies to reconstruct understandable speech, as the frequencies calculated by the DFT would match very closely the actual signal of the sound. this is how audio compression and processing algorithms actually work.
@@malbacato91 wow that is super interesting. Thanks! Had to read it like 5 times tough.
So what you‘re saying is that audio compression algorithms first split a recording into many chunks and then apply the DFT for each one? If so I have some follow-up questions that I’m hoping you could help me out with:
1. Is there an optimal way to choose the chunk size?
2. With this approach we now have to save a spectrum for each chunk right? So if the chunk size is too large, can we end up with more frequencies than using the entire recording? A larger file so to say?
3. Is there a further optimization possible by noticing that a frequency can occur in multiple chunks?
4. When replaying the spectrums chunk by chunk, is it ever a problem that a transition is noticeable? Like a jump in the signal? Does this require further processing?
Thank you for your time!
@@Laiserball8 It's a two-step process, and the frequency domain representation is actually used to *remove information* and thereby make the signal *more compressible* (lowering its entropy) based on a "psycho-acoustic model" with rules like "humans can't really hear the difference between a high-amplitude wave alone and that same high-amplitude wave plus a much lower-amplitude wave close in frequency". Essentially you remove components of the signal that the model deems inaudible, then reconstruct the audio, and then compress the simplified, lower-entropy wave using ordinary lossless compression methods. The actual compression part of MP3 isn't all that different from gzip compression.
There are also simpler schemes available. About twenty years ago when I was young and promising :) one of my fellow students and myself thought we invented a super basic sound compression algorithm that we called logsound during a telephone call. It began with me asking questions about CD audio - I was a hifi guy in a small way but had only just begun to learn about digital signal processing. I argued that if we perceive an amplitude of 65536 relative to one of 32768 (half) in the same way we do an amplitude of 2 to 1, using linear sample values would result in _subjectively_ "poor resolution with respect to amplitude" for weak (components of) a signal, while at the same time "wasting resolution" for loud parts of the signal. My friend is a very skillful coder and quickly implemented linear and logarithmic downsampling to 8 bits so we could test this, and lo and behold, while both 8-bit files produced from processing a 16-bit file ripped from a CD, the version using the logarithm of the amplitude rather than the amplitude itself was clearly superiour.
The irony is that we later discovered that the telephone network actually made use of this very trick already! So the whole time when we were discussing and testing "logsound", we were unknowingly using the very encoding scheme we were "inventing". Encoder and decoder can both be implemented with a simple lookup table (there are only 65536 possible sample values, so precalculate the logarithm of them all and store your 8-bit downsampled logsound value, and you can look them up by using the sample value as the index; for the decoder you go the other way, but only need 1024 entries if, like the phone networks did, you used 8-bit logarithmic values). For those nerdy enough to want to know more about this - or, I guess, those who think I'm making it all up, here is some more info on such a scheme: www.nxp.com/docs/en/application-note/ANE408.pdf
25 years ago I cried tears of blood at the university while learning about discrete Fourrier transformation and Nyqist-Shanon theorem. And now, look at me, I enjoy watching a video talking about this :D
i remember when after 16 years, a human being accidentally let me see fft(log10(fft()))
i was so pissed it took me three fing years to touch it
and then they have the nerve to microwave me when i'm in bed. they're a bunch of guys who wear aprons.
thanks for the description, I'll stay on the lookout@@atomictraveller
@@atomictraveller huh
@@atomictraveller I feel like this is some sort of deep joke where the fast fourier transform is used to look like boobs or something. Maybe I don't get the joke though.
@@Alexander_Grant that short expression there is the cepstrum.
that's all the notation i saw and all it needs. if you use fft some, you can infer the log10 applies to the mag bins to nyquist same as you would for a graphic readout. then you fft those and you have the cepstrum. now you can do formant shifting and higher level spectral ops like that.
that's 16 years of car chases and fist fights and plane crashes into a burning lake of dog farts.
Your videos helped rediscover my passion for coding.
I remember implementing FFT for uni, and I also remember not understanding anything I had to do. I'm excited for you to shine light on it
11:41 "sounds pretty normal"
Bro that sounded like a demon mimicking human speech 😭
11:34 you mean?
Lol
@@Optimus97 yea, lol
It kinda sounded like a German accent
sounds like German. Hallo Ävelon, noch Ich bin wißt so lauf
This is one of the few channels I will drop what I am doing to watch. I don't even use notifications often but this channel I do. Sebastian you are great! Thanks for your amazing work!
Everytime I start one of Sebastian's videos I wonder how he can make the subject interesting. Everytime I'm totally blown away by his ideas and execution.
I love your videos! The editing, the quality, the voice over. You always sound so excited and curious. Ive obviously not watched the video within this split second of me commenting but I know it's going to be good!
Thank you for your content!!
HOW CONVINIENT! I've been reasearching about digital audio for a fun project, and bam, when the world needed the most, he did not vanished
that cos and sin spinny thingy was everything i always wanted to understand but never did. blew my mind so casually
s0 = 1; s1 = 0; w = 2 * pi * freq / samplerate
// loop
s0 -= w * s1; s1 += w * s0;
// s0 (cosine) is a half sample behind s1 (sine) at this point. very occasionally renormalise s0 and s1
no one else ever notices. people really are stupid. graphics programmers don't understand inter[olation isn't first order.
@@atomictraveller There's a point there. I can feel it.
@@General12th you know ufeelit
I love coding adventures because this dude just calmly explains how to do the most complicated things ever as if it is just everyday knowledge. This man is what I want to be one day as a programmer.
Yet another masterpiece of a video. You could teach anything and it would be fascinating because of how you approach things. If only programming was as easy as you make it seem... I absolutely understand that this is because you are infinitely more intelligent than I will ever be, but I love how interesting you make things and it inspires me to explore more fun programming concepts like these.
This was the best video by you yet, at least for me as an audio engineer.
It made me feel smart that I knew a bunch of stuff that you didn't, especially: "you don't need to set a max frequency since that is determined by the sample rate."
But your approach also showed some insights that were very very interesting! Also I learned a bunch of stuff I didn't know, particularly about the actual math. And the sounds you made make me want to become a programmer to unlock this world of strange sound processing you are stumbling through for creative uses.
And as always, your visualizations are art.
By the way, fun fact about the aliasing frequencies: they are a reflection off the "ceiling" set by the nyquist frequency. You get this commonly in digital sound processing with purposeful distortion, which is why distortion plugins for DAWs typically have oversampling built in, to stop aliasing and then filter out the higher frequencies that would cause aliasing, because aliasing sounds really unmusical.
Just finished the video. Thank you for teaching me about sounds. Excited for the next video!
As an predictive maintenance engineer, interpreting vibration patterns of bearings and other rotating equipment (FFT for days)... this was amazing.
Best explanation of the nyquist theorem ive ever seen, that visual changed how i think of it
as a retired programmer, i really enjoy watching you code even when the subject isn't something i'd even think of being interested in. thank you for your work
Love watching these tech adventures accompanied with Sebastian's happy voice, it's almost soothing for the soul!
unless you're me, then it's enraging
@@adamrushford Right? It sounds like he's forcing a smile the entire video, it gives me uncomfortable goosebumps
@@average6317 I don't think it's a forced smile, he doesn't need to force his voice like troublechute does.. but the fact that it's not forced makes it that much creepier... he's not a creep though, but I feel your pain
@@average6317 for me I can't stand anyone who deliberately acts nice or bubbly, it's removed from reality AND their true emotions
I love when he talks about something I've learnt about before. It makes me kinda happy to see how my education has made me a more knowledgable person.
The reflections from the boundaries of the simulation box at 9:30 were probably affecting the sound quality a lot. In electromagnetics, people use absorbers or perfectly matched layers (PMLs) at the boundaries to remedy this issue.
This is by far my favorite UA-cam voice
I do enjoy seeing content about sound related things when it comes to data, but I've seen it already many times, what I haven't seen is running a air sim to make that sound! If you are to continue this project please please keep doing the air sim, don't get me wrong I do enjoy the Fourier Transform stuff too, just the simulated sound instead of emulated sound is so cool!
14:05 Never would've guessed that watching a video at 4am about simulating sound waves is how I'd learn what a radian is actually defined as
Ah, good morning indeed! Always a good day when a new coding adventure drops.
This is great! I'd been hoping you'd cover audio, DSP, and DFT/FFT someday, and this was a great video to come home from work to!
1. I'm really happy to see a new video appear! Once again, it looks very interesting.
2. 9:55 It's possible that the saturated sound is coming from the loudspeaker, which sometimes goes faster than the speed of sound. So perhaps slowing down the sound even more would result in a much clearer sound.
3. I feel like there's a lot of content that could be used for another episode, like slowing down or speeding up a sound without changing its pitch, or changing the pitch of a sound without slowing it down or speeding it up. Also, I'm pretty sure that a prism performs a Fourier transform on light.
4. I really like your way of programming, which consists in understanding things and creating them from scratch. That's something rare, and it's precisely what I'm looking for and why I like your channel. The amont of visualization is also a great idea.
The idea that something that exists in real life like a prism can essentially perform an algorithm is incredible and shows how closely connected digital concepts are to the real world. Reminds me a bit of how motors and gear shifting exists on the microbiological level.
@@SolanaarYes! I just recently saw this video by Smarter Every Day about these bacterial flagellar motors. I previously thought these things probably just vibrate or wiggle in some way but no there are actually gears and rotation involved on molecular level and it's amazing.
I love your clear explanations for what you're doing and why you're doing it and the math involved, I love your voice, I love your cat.
Thats a phenomenal start into the day. Thanks
Fantastic video as always. I sort of understood the principle behind Fourier transforms before, but now I have a much more robust understanding that will surely come in handy some day! :)
no wayy I was watching your videos all week and was sad I've seen the last one 😂 I love it 🤩
This video teaches you more than 3 CS courses on signal processing combined.. truly incredible.. if we were thought like this in school and uni, everyone would be a genius ❤
"Hello everyone, welcome back to another episode of coding adventures" In that buttery smooth voice gets me every time.
I suffered so much while I was learning things about waves and their interactions during cyber security training at the academy, and 5 years later I see this video. How much simpler things would have been if I had seen it then
Great video as always. Keep up the good work 🎉
@@mariandev Thank you!
How is this posted 14 hrs ago... when the video was uploaded 45 mins ago!
@@lycor surely patreons get access to it before it's public.
You're right!
A Sebastian Lague video about audio programming? Is it my birthday? Incredible video, and I’d love to see more stuff like this in the audio space as someone with aspirations of creating audio software.
Imagine having a bad day then you saw Sebastian uploaded a new video.
In my field of sleep research, we use the fast fourier transform to help visualise sleep stages - if you search for images of something like "hypnogram spectral analysis" you will see how the sleep stages pop out. A video looking at how to code this would be interesting. Thanks for your very interesting videos
i get so happy whenever i see any of your videos on my recommended :D
As always... got lost when Fourier Transforms came into play... Its just incredible how much information is packed in your videos. So good!
Sorry kids, I know we’re on vacation, but daddy’s gonna take 43:31 minutes to relax.
So much effort to these videos for such a long time (years by now) and yet 1M subs. That's something that touching. Why aren't my peers that interested??
Oh my god a video about sound.
I've been waiting for this
Worked in audio for a bit in the past. It has been my beloved hobby before and after. Always eager to learn more about how stuff works in the field. Was happily using DAWs without knowing all the complex coding that goes on behind the scenes. Now I feel like I know a fraction of a 10th of a percent of it. Thanks! :D
very interesting topic!
just a few hours ago, i was rewatching one of your videos, and i was thinking "when's the next video gonna be out?"... well, my answer has arrived.
Still mesmerized by your ability to make topics that are incomprehensible to me so fascinating and riveting to watch.
Sebastian Lague is actually the cat.
Absolutely gorgeous. Reminds me of how fascinated / inspired I was after the first time I watched 'The Conversation' .. watching the character do this kind of calculation and reconstruction with his home-grown recording equipment. I marvel at the knowledge and skill, and this was so beautifully presented.
It's a good day when Sebastian blesses us with another god tier video
you need to get out more
I understand next to nothing you're talking about, I'm only in tenth grade, but your calm voice and the nice visuals are so calming to me, it sounds like you are constantly smiling whilst recording. And I get so excited whenever you talk about something I actually already learned about in school. I hope one day, I will understand everything you're doing.
Lools like Sebastian is a Tau person lol. Good to see other chronically online math nerds are out there
This video was delightfull. And this is coming from a guy who already had boring college classes that taught this. Congratulations on the incredible explanation! I love your channel for these!
im here 45 SECONDS after upload, and somehow 94 people were here before me. This is insane, and very deserved
Same😂
4min after XD, i love this guy, if i see him instaly hit his video, youtube knows so he recomends right after upluoad
...bots
after 6minutes 1400 😂😂
Exactly what I was thinking,
Lague is the shizzle
Whenever I watch a Sebastian Lague video it reminds me how much fun my side project is and I go and do it instead of doom scrolling. Thanks Sebastian ☺️☺️
I really hope you see this comment!
So, this is actually something I've been thinking about for a long time. I'm a music producer, and aspiring video game programmer, and I've been thinking for a while how there hasn't ever really been any huge advancements in realistic live soundstaging technology, and if someone did it they could revolutionize gaming.
...But, frankly, I'm not a great programmer, so I haven't gotten anywhere close to the point of doing the research to make this a reality...
Anyway, here's my idea, that I think might actually have just become possible with the research you've just done:
In music production, there are things called Impulses. Frankly, I don't know exactly how they work, but basically you record a simple sound in an area, and then you can use that sound as an impulse, to create a reverb effect. Any sound you play through this reverb effect will sound like it was recorded in the same location as the impulse.
And I've thought for a long time now, that if you could take impulses of computer generated spaces, you could create an accurate soundstage of that space.
Imagine firing a gun in a tunnel, and actually listening to the sound of it reverberate down that entire space.
Or something shifts in the distance, and you can hear it, and know accurately where it is, just the same as you could in real life.
Or take advantage of the acoustics of an area, bounce a sound off of a wall to make it sound like it's coming from a different direction.
All of this would theoretically be possible if we could take live impulses of computer generated spaces...
And that's basically exactly what you've just programmed.
I never thought to simulate the air itself. That's actually genius.
Your visualizations for these concepts are really good. This should be required viewing for anyone getting into audio programming.
babe wake up sebastian uploaded
You are a god. That Fourier transform visualisation is not only the best Fourier explanation I've seen, but probably the best mathematical explanation of anything I've ever seen on UA-cam.
Only just started the video, but can't get over the frightening teeth at 0:18
It was amazing! You visually presented everything I learned in my university Signals and Systems course, making the concepts much more understandable for those who find them difficult to grasp.
Today is a great day! 🎉
The DFT visualization is the perfect addition to the 3b1b video. It's one of the most beautiful (and useful!) bits of maths and seeing it presented in such an effective way is awesome
Is the cat coding and making all the videos? ARE YOU THE CATTTT?
I love messing with fourier transforms, but you transmitting sound within a fluid sim is probably my favorite part of the video. it sounded like an old-timey gramophone recording!
vote for who want how do computers work series back
In his refined voice, I would like Sebastian Lague narrate the exact word by word script of a DankPods video. That would be something to behold.
at 31:01 i’m pretty sure that “strange background noise” is naturally generated reverb. This is because the “recording room” you generated is a box with perfectly flat walls and no pass through for the sound waves to disperse.
You could work around this by simulating an anechoic chamber with spiked walls and a high absorption rate. I’d assume this would remove that nasty echo you would expect from a polished concrete room. (see reverberation chamber)
TLDR: what you thought was a bug is actually just physics :D
nah u trippin balls
@@donotoliver you can literally see the waves rebounding and hitting the mic again when he visualised it
you could fft(log10(fft())) cepstrum them away to magical not here land just liek where masons send people who can actually do anything
@@Shlaboza yeah but i highly doubt he's still using the rectangle room at the point in the video when he's reconstructing the fourier transform, if he was using the room model you would hear room modes/resonances (and the distortions we heard because of the way the air particles interacted), and not a perfectly smeared signal
Thank you for actually showing this in terms of code.
In every other video explaining the Fourier transform, they just start jotting down a bunch of Greek symbols in doctor's handwriting like it's supposed to make immediate sense.
I don't understand mathematical notation, so this is a blessing.
I can't wait for your FFT implementation!
Incredible video!
When working in automobile industry R&D, we had a rule of "sample at least 10 times the maximum frequency you want to observe". Even that is true sampling a little above Nyquist frequency to ensure no frequency information is lost, some amplitude data of the waves can be lost. There was a table with those results (I could not find it sadly), but sampling at Nyquist we could ensure like we kept 50% of the average amplitude. With 10 times the maximum signal frequency (5 times Nyquist's), if I remember correctly, the sampled signal preserves around 95% of the average amplitude. The amplitude were very significant for vehicle R&D, we were usually interested up to 50Hz, so we sampled at 512-1024 Hz (just to be safe).
For audio, I think it is ok some kind of loss in higher frequencies, that's probably why standard samples are 44-48 kHz.
Just wanted to share how FFT impact places we not even imagine, thanks again for the great content!
29:20 One way to test for "non-integer frequencies" is to use the Goertzel algorithm (with slight modifications), its also faster than the FFT when you want to detect only a few particular frequencies
To get hid of the bumps you can apply a window function to the input signal to smooth a few of the first and last samples
I stopped understanding the video at 00:00 but still keep watching because you are really fun
Always a pleasure to see your take on a topic. Here since Platformer2D with raycast collision.
I love how you answer your own question in this video! At the beginning you wonder "How can we store something as complex as an audio signal with so few samples", and by the end you're covering the Nyquist Shannon theorem. Signal processing and audio is one of my favorite fields, and it's always great seeing someone else discover it -- especially with your beautiful animations!
29:17 Those bumps are the secondary lobs of the sinc function that is the correct result for a Fourier transform of a non-periodic (with a finite number of sample) signal.
It's working as intended, you just need an infinite number of samples to make them disappear, and then you get a Fourier series.
It is also intended behaviour to have the energy of frequencies that are not a multiple of the frequency resolution shared on both sides.
The max frequency that you need to look for is 2 times your sampling rate, a time discreet signal can not mathematically contain any frequency higher.
I was like bet, another indepth coding exploration of some interesting programming principle. Then the legend BUSTS OUT THE FLUID SIMULATION from earlier and re-records the god damn sound in the simulation. Was not expecting that. He's insane
I did mess around with the FT at some point to try to make a sound denoiser. FT is mad powerful
Oh my, sound exist!
Interesting theme, thank you