Coding Adventure: Sound (and the Fourier Transform)

Sdílet
Vložit
  • čas přidán 9. 09. 2024

Komentáře • 1,1K

  • @Agent-uj8ud
    @Agent-uj8ud Před měsícem +2486

    Sebastian Lague’s videos trick me into thinking programming is fun. Thanks!

    • @Yee_.
      @Yee_. Před měsícem +42

      "trick"

    • @Me-0063
      @Me-0063 Před měsícem +57

      @@Agent-uj8ud and easy

    • @stickguy9109
      @stickguy9109 Před měsícem +16

      It used to be 😭

    • @renx81
      @renx81 Před měsícem +37

      It is. Or at least, it can be.

    • @w花b
      @w花b Před měsícem +17

      It is, it's just math with a fancy calculator. Who wouldn't have fun with that?

  • @blizzy78
    @blizzy78 Před měsícem +1847

    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

    • @amirulmedia3603
      @amirulmedia3603 Před měsícem +5

      ❤😂🎉😢

    • @akc21adt
      @akc21adt Před měsícem +35

      How this dude comment is 6 hr ago. Since video is 9 min old

    • @stefanoscintilla5225
      @stefanoscintilla5225 Před měsícem +101

      ​@@akc21adtpatreon maybe

    • @johnnysvensson
      @johnnysvensson Před měsícem +18

      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

    • @bronsoncarder2491
      @bronsoncarder2491 Před měsícem +20

      No need to subtract it.
      Just reverse the phase, it will subtract itself.

  • @Simat_0
    @Simat_0 Před měsícem +1111

    The ''person that talk about something with nice visual and get you invested no mater what the subject is'' got to be my favorite CZcams genre.
    Edit : mom I'm famous

    • @jeffreyrehm8320
      @jeffreyrehm8320 Před 29 dny +26

      3blue1brown

    • @Simat_0
      @Simat_0 Před 29 dny +7

      @@jeffreyrehm8320 yup

    • @fubbernuckin
      @fubbernuckin Před 29 dny

      sebastian lague and posy are some of my favorite youtubers. always a good time.

    • @tomnewsom9124
      @tomnewsom9124 Před 29 dny +18

      Freya Holmér - beautiful videos about splines, beziers and plenty more

    • @Simat_0
      @Simat_0 Před 29 dny +7

      @@tomnewsom9124 just realizing I've seen plenty of her videos and never actually subscribe because CZcams just kept recommending them, I'm'a correct that right now.

  • @matzibeater
    @matzibeater Před měsícem +425

    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.

    • @erictheepic5019
      @erictheepic5019 Před 29 dny +24

      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.

    • @4.0.4
      @4.0.4 Před 29 dny +16

      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.

    • @R.B.
      @R.B. Před 29 dny +6

      ​@@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.

    • @timschulz9563
      @timschulz9563 Před 26 dny

      Or change the boundary conditions to not reflect but absorb the waves.

    • @thesenamesaretaken
      @thesenamesaretaken Před 15 dny

      ​@@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.

  • @Dedicatedfollower467
    @Dedicatedfollower467 Před měsícem +198

    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.

    • @lev7509
      @lev7509 Před 20 dny +2

      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!

  • @rarelycomments
    @rarelycomments Před měsícem +611

    The FFT is seriously clever and enabled a lot of modern technology. It deserves an entire video tbh

    • @stickguy9109
      @stickguy9109 Před měsícem +19

      Veritasium has an entire video on it

    • @rarelycomments
      @rarelycomments Před měsícem +32

      But not about coding it.

    • @washieman2445
      @washieman2445 Před měsícem +15

      @@rarelycomments Reducible has a great video on it.

    • @JonahNelson7
      @JonahNelson7 Před měsícem

      Fuck modern technology!

    • @lbgstzockt8493
      @lbgstzockt8493 Před měsícem +5

      It may be the most important algorithm of the modern age.

  • @kurushimee
    @kurushimee Před měsícem +362

    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

    • @sleepy-monax
      @sleepy-monax Před měsícem +83

      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
      @uhrguhrguhrg Před měsícem +9

      any big project can be divided into smaller solveable projects
      start small, experiment, prototype, and you'll learn as you go

    • @kurushimee
      @kurushimee Před měsícem +6

      @@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.

    • @craftycactus7735
      @craftycactus7735 Před měsícem +19

      ​@@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.

    • @uhrguhrguhrg
      @uhrguhrguhrg Před měsícem +1

      @@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.

  • @gammapunkgamingproductions6199
    @gammapunkgamingproductions6199 Před měsícem +974

    11:41 "sounds pretty normal"
    Bro that sounded like a demon mimicking human speech 😭

  • @vrawl5461
    @vrawl5461 Před měsícem +313

    Just did a Fourier transform exam last week
    Sebastian always blows my mind while making me feel like a bad programmer

    • @feldamar2
      @feldamar2 Před měsícem +33

      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.

    • @quickpert1382
      @quickpert1382 Před měsícem +1

      try be very good at something (just a single domain, either is game dev, web designer, machine learning) and you'll feel better.

    • @GabrielPettier
      @GabrielPettier Před měsícem +28

      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.

    • @feldamar2
      @feldamar2 Před měsícem +15

      @@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?"

    • @quickpert1382
      @quickpert1382 Před měsícem

      @@GabrielPettier right, every good piece of content requires hard work, debugging and curiosity.

  • @MrHalfLoaf
    @MrHalfLoaf Před měsícem +166

    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.

    • @nankinink
      @nankinink Před měsícem +3

      I would add Reducible as well!! The trio for maths and programming!

    • @nikal8437
      @nikal8437 Před měsícem +2

      This actually sounds like a pretty interesting video idea!

    • @2xKTfc
      @2xKTfc Před 29 dny

      Have a look at braintruffle. His most recent video on orbital mechanics was extremely mind-blowing to me.

    • @abbasuccess3155
      @abbasuccess3155 Před 23 dny +1

      ​@@nankinink For real! The first time I watched a Reducible video, I spent the whole video wondering why 3b1b was sounding different 😂😂

  • @ismailalsaad5481
    @ismailalsaad5481 Před měsícem +72

    18:00 Sebastian was the cat all along

  • @98ahni
    @98ahni Před měsícem +53

    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!

  • @PocinTheTech
    @PocinTheTech Před měsícem +48

    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

  • @lucbloom
    @lucbloom Před měsícem +83

    Sorry kids, I know we’re on vacation, but daddy’s gonna take 43:31 minutes to relax.

  • @haydenwhite8350
    @haydenwhite8350 Před měsícem +118

    "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!

    • @agentscott8329
      @agentscott8329 Před měsícem +26

      As a German I thought this sounded a lot like Danish.

    • @PKMartin
      @PKMartin Před měsícem +9

      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"

  • @Quazlyy
    @Quazlyy Před měsícem +34

    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!

  • @Sillybowler
    @Sillybowler Před měsícem +60

    I hope you know how much joy seeing a Sebastian Lague upload brings!

  • @MandoRick1978
    @MandoRick1978 Před měsícem +38

    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.

  • @fakeaccount6694
    @fakeaccount6694 Před měsícem +67

    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

    • @atomictraveller
      @atomictraveller Před měsícem +1

      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.

    • @SomebodyHere-cm8dj
      @SomebodyHere-cm8dj Před měsícem

      thanks for the description, I'll stay on the lookout​@@atomictraveller

    • @bobmarley2658
      @bobmarley2658 Před měsícem

      @@atomictraveller huh

    • @Alexander_Grant
      @Alexander_Grant Před měsícem +1

      @@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.

    • @atomictraveller
      @atomictraveller Před měsícem

      @@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.

  • @theparawarrior
    @theparawarrior Před 29 dny +2

    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.

  • @refreshfr
    @refreshfr Před měsícem +36

    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.

    • @malbacato91
      @malbacato91 Před měsícem +15

      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.

    • @Laiserball8
      @Laiserball8 Před měsícem +1

      @@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!

    • @dojohansen123
      @dojohansen123 Před 24 dny

      @@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

  • @EvenTheDogAgrees
    @EvenTheDogAgrees Před měsícem +15

    18:04: What??? I never knew you were a cat! I was already impressed, but now you completely blew my mind!

    • @aaschulz
      @aaschulz Před měsícem +1

      we went from watching cat videos to watching videos made by cats !😀

  • @zmania101
    @zmania101 Před měsícem +13

    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!

  • @_rr_-qm5og
    @_rr_-qm5og Před měsícem +24

    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.

    • @akaHarvesteR
      @akaHarvesteR Před 26 dny

      Thanks! I was wondering about that here.

    • @lev7509
      @lev7509 Před 20 dny

      Yep, as someone who knows a bit, i was gonna point out, thanks for doing that! ^^

  • @XandaPanda42
    @XandaPanda42 Před 26 dny +5

    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.

  • @justkirou
    @justkirou Před měsícem +10

    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 CZcams for a while now

  • @AruthaSilverthorn
    @AruthaSilverthorn Před měsícem +18

    I like the new lore that you are actually the cat coding and watching research videos 😮 Amazing voice for a cat!

  • @MiniePixie
    @MiniePixie Před měsícem +13

    Best explanation of the nyquist theorem ive ever seen, that visual changed how i think of it

  • @ahmetenesbulguru2985
    @ahmetenesbulguru2985 Před měsícem +14

    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!

  • @Luzgar
    @Luzgar Před 29 dny +2

    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.

  • @mariandev
    @mariandev Před měsícem +30

    Great video as always. Keep up the good work 🎉

    • @SebastianLague
      @SebastianLague  Před měsícem +9

      @@mariandev Thank you!

    • @lycor
      @lycor Před měsícem

      How is this posted 14 hrs ago... when the video was uploaded 45 mins ago!

    • @GabrielPettier
      @GabrielPettier Před měsícem +4

      @@lycor surely patreons get access to it before it's public.

    • @lycor
      @lycor Před měsícem

      You're right!

  • @MichaelFlambe
    @MichaelFlambe Před měsícem +7

    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!!!

  • @ImLoLGamer1002
    @ImLoLGamer1002 Před měsícem +235

    im here 45 SECONDS after upload, and somehow 94 people were here before me. This is insane, and very deserved

    • @darklord3176
      @darklord3176 Před měsícem +3

      Same😂

    • @danisanchez1737
      @danisanchez1737 Před měsícem +1

      4min after XD, i love this guy, if i see him instaly hit his video, youtube knows so he recomends right after upluoad

    • @GameBacardi
      @GameBacardi Před měsícem +2

      ...bots

    • @user-ee7jf8yx2e
      @user-ee7jf8yx2e Před měsícem

      after 6minutes 1400 😂😂

    • @stevenmathews7621
      @stevenmathews7621 Před měsícem

      Exactly what I was thinking,
      Lague is the shizzle

  • @benmolitor1519
    @benmolitor1519 Před měsícem +3

    Lools like Sebastian is a Tau person lol. Good to see other chronically online math nerds are out there

  • @Gwilo
    @Gwilo Před měsícem +8

    that cos and sin spinny thingy was everything i always wanted to understand but never did. blew my mind so casually

    • @atomictraveller
      @atomictraveller Před měsícem +1

      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.

    • @General12th
      @General12th Před 28 dny

      @@atomictraveller There's a point there. I can feel it.

    • @atomictraveller
      @atomictraveller Před 28 dny

      @@General12th you know ufeelit

  • @slaeh2225
    @slaeh2225 Před měsícem +2

    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

  • @4547466
    @4547466 Před měsícem +4

    "Hello everyone, welcome back to another episode of coding adventures" In that buttery smooth voice gets me every time.

  • @ImecWarriors
    @ImecWarriors Před 15 dny +1

    As an predictive maintenance engineer, interpreting vibration patterns of bearings and other rotating equipment (FFT for days)... this was amazing.

  • @IRLtwigstan
    @IRLtwigstan Před měsícem +15

    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!

  • @SimonMeskens
    @SimonMeskens Před měsícem +2

    Fun fact: 360 is not that arbitrary of a number, there are these numbers called the Highly Composite Numbers, which are the numbers with the highest amount of divisors basically. Kinda like the opposite of a prime. 360 is one of them, so are 12, 24, 60, all numbers that you see pop up when you want to make it easy for people to further divide something (like on a clock, or degrees of a circle).

  • @SongStudios
    @SongStudios Před měsícem +18

    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!!

  • @Subnite
    @Subnite Před měsícem +2

    To combat the spectral leakage, you should look into windowing functions like Hann and Hamming.
    They essentially just fade in and fade out the input signal which results in a much more accurate spectral output

  • @Zolbat
    @Zolbat Před měsícem +3

    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

  • @olhoTron
    @olhoTron Před 25 dny +2

    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

  • @levb258
    @levb258 Před měsícem +9

    Sebastian Lague is actually the cat.

  • @zix2421
    @zix2421 Před měsícem +2

    Oh my, sound exist!
    Interesting theme, thank you

  • @ninojamestan8895
    @ninojamestan8895 Před měsícem +4

    Imagine having a bad day then you saw Sebastian uploaded a new video.

  • @OtisLaundon
    @OtisLaundon Před 28 dny +1

    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

  • @hsvfanjan17
    @hsvfanjan17 Před měsícem +6

    Love watching these tech adventures accompanied with Sebastian's happy voice, it's almost soothing for the soul!

    • @adamrushford
      @adamrushford Před měsícem +1

      unless you're me, then it's enraging

    • @average6317
      @average6317 Před 29 dny

      @@adamrushford Right? It sounds like he's forcing a smile the entire video, it gives me uncomfortable goosebumps

    • @adamrushford
      @adamrushford Před 29 dny

      @@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

    • @adamrushford
      @adamrushford Před 29 dny

      @@average6317 for me I can't stand anyone who deliberately acts nice or bubbly, it's removed from reality AND their true emotions

  • @eltonbergruh8339
    @eltonbergruh8339 Před měsícem +2

    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.

  • @RealTwiner
    @RealTwiner Před měsícem +3

    Ah, good morning indeed! Always a good day when a new coding adventure drops.

  • @caraffa3621
    @caraffa3621 Před 25 dny +2

    27:30 Those bumps are there for a reason! It's one of the basic properties of the Fourier transform. Ideally, you would be working on a continuous and infinite signal, but you are working on a small fragment of it. Exactly for this reason ideal spectrum of sinusoidal waves is combined with absolute value of Sinc function which is a FT of a rectangular pulse.
    Assuming that the signal X is an infinite combination of selected frequencies and Y is a 'rectangle' (takes the value 1 or 0) which shrinks the infinite function to a small fragment, in your code you analyse the function x(t) ⋅ y(t). In the frequency domain, the equivalent of multiplication is the convolution , so you get X(f) * Y(f), where f is the frequency. After applying the Fourier Transform to pure sinusoids, we expect to see Dirac delta functions shifted to specific locations along the frequency axis. By convolving these delta functions with the frequency domain representation of the signal we get repeated spectrum of the signal at those shifted positions. In this case, the spectrum takes the form of a Sinc function (also known as the "Sa" function) because the original signal was windowed using a square window in the time domain.
    You may want to read the Wikipedia article 'window function' and I suggest you delve into the topic of signal processing.
    EDIT: 31:20 This result is probably a mix of an issue with your code and another DFT property which is signal/spectrum repetition. It's also described in DTF Wikipedia article

  • @CloudPhase
    @CloudPhase Před měsícem +3

    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!

  • @frechesbienchen4720
    @frechesbienchen4720 Před 18 dny +1

    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.

  • @justputitdown
    @justputitdown Před měsícem +3

    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.

  • @ThePicklish
    @ThePicklish Před 15 dny +1

    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

  • @AjinGixtas
    @AjinGixtas Před měsícem +3

    Just finished the video. Thank you for teaching me about sounds. Excited for the next video!

  • @leeoiou7295
    @leeoiou7295 Před měsícem +2

    what a great day with a sebastian upload

  • @The_master_of_frogs
    @The_master_of_frogs Před měsícem +7

    It's a good day when Sebastian blesses us with another god tier video

  • @user-sd4ng2qe1o
    @user-sd4ng2qe1o Před měsícem +1

    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

  • @blazen_gaming3290
    @blazen_gaming3290 Před měsícem +4

    i get so happy whenever i see any of your videos on my recommended :D

  • @woosix7735
    @woosix7735 Před měsícem +2

    40:48 One trick for these kind of vissualisations is that often it is more meaningfull to represent frequency on a logarithmic scale, scine that's how we hear sound typicly. so for example the frequencies between 100 and 1 000 Hz get the same amount of space in the graph as from 1 000 to 10 000.
    41:12 It's also usefull to represent amplitudes on a log scale as well. You can still hear it if the amplitude is "extreemly small" compared to the loudests amplitude

  • @nom21304
    @nom21304 Před měsícem +3

    no wayy I was watching your videos all week and was sad I've seen the last one 😂 I love it 🤩

  • @Ouvii
    @Ouvii Před 15 dny +2

    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.

  • @LetsSmiley
    @LetsSmiley Před měsícem +3

    Thats a phenomenal start into the day. Thanks

  • @kierkegaard54
    @kierkegaard54 Před měsícem +2

    This is by far my favorite CZcams voice

  • @abellematheux7632
    @abellematheux7632 Před měsícem +5

    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.

    • @Solanaar
      @Solanaar Před měsícem +2

      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.

    • @RoyalArthurio
      @RoyalArthurio Před měsícem +2

      ​@@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.

  • @SaadTheGlad
    @SaadTheGlad Před měsícem +2

    LETS GOOOOOOOO
    Dude you don't know how excited seeing one of your videos on my recommended makes me.

  • @PadPalon
    @PadPalon Před měsícem +4

    Only just started the video, but can't get over the frightening teeth at 0:18

  • @chriskaprys
    @chriskaprys Před 16 dny

    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.

  • @metashrew
    @metashrew Před měsícem +4

    Oh my god a video about sound.
    I've been waiting for this

  • @AkioJunichiro
    @AkioJunichiro Před měsícem +2

    Always a pleasure to see your take on a topic. Here since Platformer2D with raycast collision.

  • @siomek101
    @siomek101 Před měsícem +3

    babe wake up sebastian uploaded

  • @lukaspc2892
    @lukaspc2892 Před měsícem +2

    This first part of simulating speaker and microphone could be pretty cool if you somehow get that to be more performant. Imagine being able to simulate room echo and how differently shaped objects in the room affect the sound. That could be very interesting! You could even simulate different pickup patterns and everything!

  • @ninjacodertech
    @ninjacodertech Před měsícem +3

    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.

  • @98Vuk
    @98Vuk Před 29 dny

    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 ❤

  • @lominero5
    @lominero5 Před měsícem +3

    Today is a great day! 🎉

  • @bluemond100
    @bluemond100 Před měsícem +2

    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

    • @bluemond100
      @bluemond100 Před měsícem +1

      I did mess around with the FT at some point to try to make a sound denoiser. FT is mad powerful

  • @Shlaboza
    @Shlaboza Před měsícem +10

    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

    • @donotoliver
      @donotoliver Před měsícem +1

      nah u trippin balls

    • @Shlaboza
      @Shlaboza Před měsícem +4

      @@donotoliver you can literally see the waves rebounding and hitting the mic again when he visualised it

    • @atomictraveller
      @atomictraveller Před měsícem

      you could fft(log10(fft())) cepstrum them away to magical not here land just liek where masons send people who can actually do anything

    • @donotoliver
      @donotoliver Před měsícem +4

      @@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

  • @yetntplayz
    @yetntplayz Před měsícem +2

    Yesss my yearly dose of Sebastian Lague

  • @outoftime9071
    @outoftime9071 Před měsícem +3

    Is the cat coding and making all the videos? ARE YOU THE CATTTT?

  • @JackTheFoxOtter
    @JackTheFoxOtter Před měsícem +2

    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! :)

  • @EshaanKataria-qx8rp
    @EshaanKataria-qx8rp Před měsícem +3

    vote for who want how do computers work series back

  • @sirflimflam
    @sirflimflam Před měsícem +1

    Man this brings me back to many years ago when it first clicked to me that the AnimationCurve class could be used to define simple waveforms, and I built a small synthesizer program in Unity.

  • @ToadJimmy
    @ToadJimmy Před měsícem

    I appreciate the low-frequencies being visualized as red and higher ones as violet, it fits. makes me happy.

  • @tamrat_assefa
    @tamrat_assefa Před 22 dny

    As always... got lost when Fourier Transforms came into play... Its just incredible how much information is packed in your videos. So good!

  • @manuelpena3988
    @manuelpena3988 Před měsícem +1

    22:52
    I think that when you don't have an integer frequency your "average" point does not fall in the center because you are not ploting the frequencies in a wide enought range. But, the wider you chose the range, the closer that point will be to the center. With two exception:
    - the test frequency matches the frequency of the signal (case that you already mention)
    - the test frequency and the signal frequency are two integers with a very small Least Common Multiple (that fits in your range)

  • @michelepinato1158
    @michelepinato1158 Před 26 dny

    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

  • @chitlitlah
    @chitlitlah Před měsícem +1

    I did this same thing a few years ago experimenting with audio compression and I think it was 3Blue1Brown's video on the FFT that inspired me. I made a program that would read in a wav file, do an FFT on it, remove all but the most prominent frequencies based on a compression ratio I specify, and convert it back to a wav file so I can hear it. It's surprising just how much you can remove and it still sounds pretty good. I had more bleeps and bloops when using extreme compression rather than that underwater sound you got.

  • @gold_apple_vn4657
    @gold_apple_vn4657 Před měsícem +1

    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??

  • @cazza358
    @cazza358 Před 22 dny

    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 CZcams.

  • @IstasPumaNevada
    @IstasPumaNevada Před měsícem +1

    I like the mild implication at 18:00 that you are actually the cat, and the cat has been making and narrating this whole video.

  • @P4INKiller
    @P4INKiller Před 22 dny

    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!

  • @mylesbuckley9675
    @mylesbuckley9675 Před měsícem

    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 ☺️☺️

  • @soviut303
    @soviut303 Před 29 dny

    Your visualizations for these concepts are really good. This should be required viewing for anyone getting into audio programming.

  • @danielmiskin8468
    @danielmiskin8468 Před 29 dny

    Sebastian’s videos gives me the confidence to start a project that would need a team of 10 people multiple years to make, then I’m brought back to reality

  • @uniqueflowsnake
    @uniqueflowsnake Před 21 dnem

    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

  • @SaludYExitoClips
    @SaludYExitoClips Před měsícem +1

    For the first time in my life, I've actually attempted this before watching this video and not after

  • @someone9927
    @someone9927 Před měsícem +2

    I love your video so much

  • @markosrpak1444
    @markosrpak1444 Před měsícem

    Being deep into signal processing study, this video gave me yet another different visualisation of signals. Very cool to see more people learn this stuff :D