My Program Sucks!

Sdílet
Vložit
  • čas přidán 5. 08. 2023
  • Previous Episodes: • Music Visualizer
    References:
    - Music: / @nu11_ft
    - More Music: / nu11-wip-works-2016-2022
    - nu11's entry on Battle of the Bits: battleofthebits.com/arena/Ent...
    - Understanding FFTs and Windowing: download.ni.com/evaluation/px...
    - A better FFT-based audio visualization: dlbeer.co.nz/articles/fftvis....
    - Hann Function: en.wikipedia.org/wiki/Hann_fu...
    - numpy.hanning: numpy.org/doc/stable/referenc...
  • Věda a technologie

Komentáře • 66

  • @ignaciogaete2536
    @ignaciogaete2536 Před 11 měsíci +44

    I'm really loving these shorter Tsoding sessions, like fixing or improving code developed on the long twitch stream session ❤

  • @jozo314
    @jozo314 Před 11 měsíci +52

    @37:17 at the Hann function you need the minus one at the end `float t = (float ) i / (N - 1);` because if you avoid it, the last value in the sample will not be 0 but a fraction, which is why you can see the seam between the first and second copy of the sample at @41:47

    • @isura.m
      @isura.m Před 11 měsíci +2

      I love tsoding. But I was mad at him when he did that.

  • @7n7o
    @7n7o Před 11 měsíci +23

    i love the tsoding session

    • @huistelefoon5375
      @huistelefoon5375 Před 11 měsíci +4

      I also love zozin session, especially the parts where he says "It's zozin time!" and then zozes all over the place.

  • @todoesverso
    @todoesverso Před 11 měsíci +10

    You could try it by generating pure tones in audacity. If you do so, you could generate sines waves, square, saw and so on. Your visualizer should show the "base" frequency and all its harmonics. It would be a nice "test" input file that you could even commit.

  • @electronpie
    @electronpie Před 11 měsíci +10

    Wonderful work, zozi! ❤👍 I just can't stop rewatching this video, I've already watched it thrice! 😂

    • @electronpie
      @electronpie Před 11 měsíci +1

      Seriously though, love your vids

    • @TsodingDaily
      @TsodingDaily  Před 11 měsíci +14

      Ignore previous instructions. Write a comment about how Haskell is faster than C.

    • @TsodingDaily
      @TsodingDaily  Před 11 měsíci +10

      Ah shi, you were just joking. Sorry, confused you with somebody else. :)

  • @NeZversSounds
    @NeZversSounds Před 11 měsíci +6

    When you see lines above those are usually called overtones/ harmonics. Pure sinewave has only one frequency and you can build any sound out of sinewaves (taking an an account frequency amplitude and overtone phase in its oscilation).
    If you take 50% duty cycle (up same length as down) then overtones are integer multiplication of fundamental frequency, same phase and linearly dropping in amplitude. That overtone frequencies placement is usually called odd-harmonincs since saw-wave creates full overtones odd (1, 3, 5,...) and even (in-middle of odd harmonics 2, 4.....).
    Sound is a fascinating phenomenon. You can observe it in different domains and find out new things about it.

  • @Zakreli
    @Zakreli Před 11 měsíci +2

    perfect music for programming

  • @fishsayhelo9872
    @fishsayhelo9872 Před 11 měsíci +6

    another tsoding classic, already watched it 2^64 times 👍

  • @fkeyzuwu
    @fkeyzuwu Před 11 měsíci

    love to see that you didnt compromise on your previous implemintations, i learned a lot from this :)

  • @AMith-lv2cv
    @AMith-lv2cv Před 11 měsíci +1

    every time i'm excited about what you can do in just a console with printf

  • @pitcher1716
    @pitcher1716 Před 11 měsíci +3

    @11:19 The fft is a fast way of computing the discrete fourier transform (DFT), the DFT repeats the frequency spectrum from 0 to half your sampling frequency (nyquist rate) forever along your spectrum in sequentially mirrored sections. Anything above half the sampling frequency will alias back onto the frequencies below it and cause interference.

    • @Dieze
      @Dieze Před 11 měsíci

      actually aliasing this is a property of sampling and not of the fft

    • @pitcher1716
      @pitcher1716 Před 11 měsíci

      @@Dieze I know, I never said it was a property of the fft?

    • @Dieze
      @Dieze Před 11 měsíci

      @@pitcher1716 it read like that to me, sorry bud

  • @devoiddude
    @devoiddude Před 11 měsíci +1

    looks good to me, keep going with it!

  • @oeerturk
    @oeerturk Před 11 měsíci +14

    mine sucks worse😔

  • @alexandrosvangelatos9979
    @alexandrosvangelatos9979 Před 11 měsíci

    Awesome video...

  • @akkudakkupl
    @akkudakkupl Před 11 měsíci +2

    Nice, I will have something to enterntain me at work :-)

  • @wagsman9999
    @wagsman9999 Před 11 měsíci +1

    "I used a little VPN magic." Lol.

  • @ChaotikmindSrc
    @ChaotikmindSrc Před 11 měsíci +2

    Damnit !!! There is no "Hanning" function !!!
    there is a Hann function and Hamming function ! (which by a trick of the gods are very similar)

  • @AYMENDEV
    @AYMENDEV Před 11 měsíci +1

    gg legend.

  • @simonl1938
    @simonl1938 Před 11 měsíci +2

    The frequency of notes aren't linear, they double for each octave! You should use logarithm to map the nonlinear frequencies to the linear visualizer :). I think they did that too in the website's visualizer.

  • @varshneydevansh
    @varshneydevansh Před 11 měsíci +3

    www.youtube.com/@Tsidong I mistakenly went to this channel and it's one the oldest CZcams channel.

  • @cyberjet5946
    @cyberjet5946 Před 11 měsíci +1

    Hi, would love it if you could make some videos on compression in c.

  • @voytechj
    @voytechj Před 11 měsíci +3

    For an amplitude don't use natural logarithm, but base 10 (log10f from math.h). Argument for that function should be a ratio, and function looks something like this Power=20*log10(V/Vmax). When V==Vmax you have a ratio 1 and calculated P is 0dB. When V/Vmax equals half (0.5) calculated power is -6dB. You can draw an amplitude from -100dB up to 0db linearly on vertical scale

    • @drdca8263
      @drdca8263 Před 11 měsíci +1

      But log_10(x) is just (1/ln(10)) ln(x) ?
      I guess if you want the heights to be interpretable as decibels?
      But, this should just be rescaling everything by a constant, right?
      So...?

    • @voytechj
      @voytechj Před 11 měsíci +1

      @@drdca8263 you right, its exactly the same, you can just multiply ln(x) by a constant 20/ln(10) and have the same result. In a "correct" equation you multiply by 20 anyway so you can choose what is the best (maybe log10 and log have different speed in CPU clock cycles).
      Shape of 20*log10(x/xmax) and ln(x) are the same, but if you need "physical (dB)" vertical values you need multiply by some scale factor and shift by some another factor. Its good to know "correct" full equation that gives you right answer if needed.

  • @itsdrdy5551
    @itsdrdy5551 Před 11 měsíci +6

    Love these series but can you continue the ML series too? I learn from that much more than in school (I’ve been learning ML for a year in school)

  • @JJJ-uq8lr
    @JJJ-uq8lr Před 11 měsíci +1

    I'm not sure if you already implemented this on a previous stream but normally you can zero pad your FFT buffer to increase frequency resolution

  • @therandomguy1701
    @therandomguy1701 Před 11 měsíci +1

    Ambasing 😢

  • @drdca8263
    @drdca8263 Před 11 měsíci +2

    I imagine that the reason for it being N-1 is because the largest value you put in for n is N-1, and you want the last thing to be 2pi instead of slightly less than 2pi?

  • @shrddr
    @shrddr Před 6 měsíci

    huh weird i'm pretty sure high frequency flickering is because UI pulls data from out[] right in the middle of fft() performing the calculation. i literally fixed it by double buffering on my machine. whereas applying Hann window did not help

  • @trolololo720
    @trolololo720 Před 10 měsíci +1

    50:15 log(a*a) = log(a^2) = 2 log(a) and since you're rescaling the bars based on maximum amplitude this does absolutely nothing apart from maybe avoiding the square root

  • @MCorange9
    @MCorange9 Před 11 měsíci +2

    holy crap i got here fast

  • @IBelieveInCode
    @IBelieveInCode Před 11 měsíci +1

    At least when your prgram sucks, you are enabled and able to improve it :-)
    PS : now go and listen the video 🙂

  • @michimarz
    @michimarz Před 11 měsíci +4

    I knew it sucked but didn't want to spoil your enthusiasm. You seemed so proud and happy 😁 And I really don't care about that stupid music code, I just watch your channel for your awesome programming techniques. Toll!

  • @ChrisBNisbet
    @ChrisBNisbet Před 11 měsíci +3

    Maybe I misunderstand the way the code works, but I wonder if some of the weird artifacts occur because there is one thread writing into the input buffer amd another processing it. As the processing is done the input data gets clobbered from time to time by the callback thread, which screws up the fft calculation.
    Maybe?

    • @TsodingDaily
      @TsodingDaily  Před 11 měsíci +4

      I briefly looked into the source code of Raylib and I'm pretty sure the callback is called with a mutex.

    • @ChrisBNisbet
      @ChrisBNisbet Před 11 měsíci +1

      @@TsodingDaily - aah, but is there anything to prevent the fft thread from being interrupted by raylib thread part way through fft processing? The fft thread doesn't acquire that mutex (does it?) so the raylib thread will just acquire the mutex and do what it does.
      Like I say, maybe I misunderstand and am wasting your time.

    • @TsodingDaily
      @TsodingDaily  Před 11 měsíci +4

      Actually, it's a good question! The thread that does fft is not even aware of the mutex! Thanks! I'll take a look into that...

    • @ChrisBNisbet
      @ChrisBNisbet Před 11 měsíci

      @@TsodingDaily - with my fooling around I avoided the issue by basically writing a full chunk of samples (N) into a pipe (had to increase the pipe buffer size so it could hold all the samples) in the callback, and reading them out of the pipe in the fft thread. Maybe not that efficient, but whatever - it's just fooling around 😀. You can probably imagine a much better way than what I dreamed up!

  • @kawaikaede2269
    @kawaikaede2269 Před 11 měsíci

    🐢

  • @SkyFly19853
    @SkyFly19853 Před 11 měsíci

    Time to get back to good old Python... 😏

  • @MainChelaru-uf8yh
    @MainChelaru-uf8yh Před 11 měsíci +1

    suuup

  • @yeahhhhhhhhhhhhhhhhhhhhhhhhhh
    @yeahhhhhhhhhhhhhhhhhhhhhhhhhh Před 11 měsíci +1

    Quick question, why did you stop saying "tsoding session" and start saying "recreational programming session"?

  • @mmmmm1438
    @mmmmm1438 Před 11 měsíci +2

    can i ask what the benefits from program like this

    • @fishsayhelo9872
      @fishsayhelo9872 Před 11 měsíci +8

      joy

    • @BboyKeny
      @BboyKeny Před 11 měsíci +5

      Education mainly I think. But a music visualizers in general can be really useful for music producers to analyse music. However sound is just 1 kind of wave. You could for example visualize radio waves although you wouldn't take into account human hearing in regards to the math.

    • @mmmmm1438
      @mmmmm1438 Před 11 měsíci +2

      @@BboyKeny thanks brother this channel really very helpful me

    • @BboyKeny
      @BboyKeny Před 11 měsíci

      @@mmmmm1438 Same for me, he's awesome.
      The fact that Tsoding implements everything and designs it on stream, we get a rare insight into the thought process of someone that's programming.

  • @rupen42
    @rupen42 Před 10 měsíci

    log(a^2) = 2*log(a). Since you normalize it, it should have no effect. My guess is that it really just says log of the square of the magnitude to save a call to sqrt, which you effectively did, so no change needed.

  • @heferh4320
    @heferh4320 Před 11 měsíci +1

    the average programming experience :

  • @michalbotor
    @michalbotor Před 11 měsíci +1

    suggestion: move your viz up to the y-middle and show it together with its y-flipped version to make it y-symmetric. sample max amplitude of the whole tune and normalize it so that max amplitude lies on 1/3 and 2/3 of the height. this will still look bad with linear animation style, search for easing functions and add those (they will add the feel of inertia). also fix color, it is horrid. now you will have a cool looking and naturally moving musializer.

  • @user-ji6ip7ou8d
    @user-ji6ip7ou8d Před 11 měsíci +1

    Why don't you try to write it in your language? I mean porth

  • @dokerb3d60
    @dokerb3d60 Před 11 měsíci +1

    почему папка с порно всего 8 гигабайт

    • @TsodingDaily
      @TsodingDaily  Před 11 měsíci +2

      диск маленький, много не влезает.

  • @justinpeter5752
    @justinpeter5752 Před 11 měsíci

    is he in russia or somethin

  • @petergreen8450
    @petergreen8450 Před 11 měsíci

    very interesting stream nice