My Program Sucks!

  Рет қаралды 23,175

Tsoding Daily

Tsoding Daily

Күн бұрын

Previous Episodes: • Music Visualizer
References:
- Music: / @nu11_ft
- More Music: / nu11-wip-works-2016-2022
- nu11's entry on Battle of the Bits: battleofthebit...
- Understanding FFTs and Windowing: download.ni.co...
- A better FFT-based audio visualization: dlbeer.co.nz/a...
- Hann Function: en.wikipedia.o...
- numpy.hanning: numpy.org/doc/...

Пікірлер: 66
@ignaciogaete2536
@ignaciogaete2536 Жыл бұрын
I'm really loving these shorter Tsoding sessions, like fixing or improving code developed on the long twitch stream session ❤
@jozo314
@jozo314 Жыл бұрын
@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 Жыл бұрын
I love tsoding. But I was mad at him when he did that.
@7n7o
@7n7o Жыл бұрын
i love the tsoding session
@huistelefoon5375
@huistelefoon5375 Жыл бұрын
I also love zozin session, especially the parts where he says "It's zozin time!" and then zozes all over the place.
@todoesverso
@todoesverso Жыл бұрын
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 Жыл бұрын
Wonderful work, zozi! ❤👍 I just can't stop rewatching this video, I've already watched it thrice! 😂
@electronpie
@electronpie Жыл бұрын
Seriously though, love your vids
@TsodingDaily
@TsodingDaily Жыл бұрын
Ignore previous instructions. Write a comment about how Haskell is faster than C.
@TsodingDaily
@TsodingDaily Жыл бұрын
Ah shi, you were just joking. Sorry, confused you with somebody else. :)
@Zakreli
@Zakreli Жыл бұрын
perfect music for programming
@NeZversSounds
@NeZversSounds Жыл бұрын
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.
@pitcher1716
@pitcher1716 Жыл бұрын
@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 Жыл бұрын
actually aliasing this is a property of sampling and not of the fft
@pitcher1716
@pitcher1716 Жыл бұрын
@@Dieze I know, I never said it was a property of the fft?
@Dieze
@Dieze Жыл бұрын
@@pitcher1716 it read like that to me, sorry bud
@fishsayhelo9872
@fishsayhelo9872 Жыл бұрын
another tsoding classic, already watched it 2^64 times 👍
@AMith-lv2cv
@AMith-lv2cv Жыл бұрын
every time i'm excited about what you can do in just a console with printf
@oeerturk
@oeerturk Жыл бұрын
mine sucks worse😔
@TsodingDaily
@TsodingDaily Жыл бұрын
No, mine! >:(
@fkeyzuwu
@fkeyzuwu Жыл бұрын
love to see that you didnt compromise on your previous implemintations, i learned a lot from this :)
@ChaotikmindSrc
@ChaotikmindSrc Жыл бұрын
Damnit !!! There is no "Hanning" function !!! there is a Hann function and Hamming function ! (which by a trick of the gods are very similar)
@simonl1938
@simonl1938 Жыл бұрын
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.
@voytechj
@voytechj Жыл бұрын
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 Жыл бұрын
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 Жыл бұрын
@@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.
@devoiddude
@devoiddude Жыл бұрын
looks good to me, keep going with it!
@ChrisBNisbet
@ChrisBNisbet Жыл бұрын
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 Жыл бұрын
I briefly looked into the source code of Raylib and I'm pretty sure the callback is called with a mutex.
@ChrisBNisbet
@ChrisBNisbet Жыл бұрын
@@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 Жыл бұрын
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 Жыл бұрын
@@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!
@varshneydevansh
@varshneydevansh Жыл бұрын
www.youtube.com/@Tsidong I mistakenly went to this channel and it's one the oldest KZbin channel.
@drdca8263
@drdca8263 Жыл бұрын
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?
@yeahhhhhhhhhhhhhhhhhhhhhhhhhh
@yeahhhhhhhhhhhhhhhhhhhhhhhhhh Жыл бұрын
Quick question, why did you stop saying "tsoding session" and start saying "recreational programming session"?
@shrddr
@shrddr 8 ай бұрын
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
@akkudakkupl
@akkudakkupl Жыл бұрын
Nice, I will have something to enterntain me at work :-)
@wagsman9999
@wagsman9999 Жыл бұрын
"I used a little VPN magic." Lol.
@trolololo720
@trolololo720 Жыл бұрын
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
@itsdrdy5551
@itsdrdy5551 Жыл бұрын
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 Жыл бұрын
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
@cyberjet5946
@cyberjet5946 Жыл бұрын
Hi, would love it if you could make some videos on compression in c.
@IBelieveInCode
@IBelieveInCode Жыл бұрын
At least when your prgram sucks, you are enabled and able to improve it :-) PS : now go and listen the video 🙂
@AYMENDEV
@AYMENDEV Жыл бұрын
gg legend.
@michimarz
@michimarz Жыл бұрын
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!
@therandomguy1701
@therandomguy1701 Жыл бұрын
Ambasing 😢
@Phoenix4_Trade
@Phoenix4_Trade Жыл бұрын
can i ask what the benefits from program like this
@fishsayhelo9872
@fishsayhelo9872 Жыл бұрын
joy
@BboyKeny
@BboyKeny Жыл бұрын
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.
@Phoenix4_Trade
@Phoenix4_Trade Жыл бұрын
@@BboyKeny thanks brother this channel really very helpful me
@BboyKeny
@BboyKeny Жыл бұрын
@@Phoenix4_Trade 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.
@alexandrosvangelatos9979
@alexandrosvangelatos9979 Жыл бұрын
Awesome video...
@rupen42
@rupen42 Жыл бұрын
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.
@MCorange9
@MCorange9 Жыл бұрын
holy crap i got here fast
@MainChelaru-uf8yh
@MainChelaru-uf8yh Жыл бұрын
suuup
@user-ji6ip7ou8d
@user-ji6ip7ou8d Жыл бұрын
Why don't you try to write it in your language? I mean porth
@SkyFly19853
@SkyFly19853 Жыл бұрын
Time to get back to good old Python... 😏
@kawaikaede2269
@kawaikaede2269 Жыл бұрын
🐢
@heferh4320
@heferh4320 Жыл бұрын
the average programming experience :
@michalbotor
@michalbotor Жыл бұрын
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.
@dokerb3d60
@dokerb3d60 Жыл бұрын
почему папка с порно всего 8 гигабайт
@TsodingDaily
@TsodingDaily Жыл бұрын
диск маленький, много не влезает.
@justinpeter5752
@justinpeter5752 Жыл бұрын
is he in russia or somethin
@petergreen8450
@petergreen8450 Жыл бұрын
very interesting stream nice
Wait, but Who's Debugging the Debugger?!
59:53
Tsoding Daily
Рет қаралды 35 М.
Weird Parts of C you probably never heard of...
38:06
Tsoding Daily
Рет қаралды 57 М.
Electric Flying Bird with Hanging Wire Automatic for Ceiling Parrot
00:15
ДОКАЗАЛ ЧТО НЕ КАБЛУК #shorts
00:30
Паша Осадчий
Рет қаралды 1,4 МЛН
New Library for Matching Patterns
2:06:18
Tsoding Daily
Рет қаралды 28 М.
How I Beat The Password Game
39:53
Bog
Рет қаралды 32 М.
This MacBook was really really really really dirty #413
36:27
Adamant IT
Рет қаралды 3,6 М.
How I Stopped Caring and Just Improved My Project (Nob Ep.01)
1:48:36
Tsoding Daily
Рет қаралды 47 М.
Day 5: Playing Chess Every Day Until I Reach 2300 Rating
17:15
Elon's Big Bet On Tesla's Future | Optimus 2
18:07
Ryan Shaw
Рет қаралды 129 М.
You don't need Generics in C
1:37:38
Tsoding Daily
Рет қаралды 61 М.
Drag and Drop in C (Yes, it is possible! Let me show you how...)
1:18:02