How to Implement an FIR Filter in C++ [DSP #15]

  Рет қаралды 13,052

WolfSound

WolfSound

Күн бұрын

✅ Check out the full article on TheWolfSound.com: thewolfsound.com/fir-filter-w...
➡️ and the associated code: github.com/JanWilczek/fir-simd
➡️ Convolution series: • Convolution Intuitivel...
➡️ 3 modes of convolution explained: • Convolution in Matlab ...
✅ Sign up for WolfSound's newsletter: thewolfsound.com/newsletter/
✅ Please subscribe to WolfSound to let the little Wolf 🐺 grow:
kzbin.info...
🎧 Listen to my music: thewolfofficial.com/
Hi, my name is Jan Wilczek and I am an audio programmer and a researcher. Welcome to WolfSound!
WolfSound's mission is to provide high-quality, informative, and entertaining videos, articles, and courses on how to process sound by exploring mathematics, applying algorithms, and creating code in various programming languages. Topics include sound synthesis, digital signal processing, programming languages for audio (C, C++, Python, Rust), and audio effects. I am also sharing tips on how to learn fast and effectively. Make sure to visit www.thewolfsound.com/.
WolfSound enables everybody to learn about audio programming!
ABOUT THE VIDEO
In this video, I show you how to implement a plain (unoptimized) FIR filter in C++.
Learn how to
💡 Rewrite the FIR filter convolution formula,
💡 Pad the signals with zeros correctly, and
💡 Implement it in C++.
In case of any doubt in understanding, please, refer to the article above or ask a question in the comments 🙂
Video edited by Vadzim Vezhnavets.
ABOUT ME
My name is Jan Wilczek. I am an audio programmer, a researcher in the field of music technology, and a musician. Through articles and videos from WolfSound, you will easily understand the main concepts of sound processing using software. My full story: • How I Got Started With...
FOLLOW WOLFSOUND ONLINE
✅ Blog: www.thewolfsound.com/
✅ LinkedIn: / jan-wilczek-audio-prog...
✅ Twitter: / wilczek_jan
✅ Facebook: / janwilczekwolfsound
✅ Instagram: / janwolfwilczek
✅ Pinterest: / jawitrle
TIME CODES
00:00 Introduction
00:22 What is an FIR filter?
00:53 Mathematical definition of convolution
01:33 Practical convolution formula
02:08 How to pad the input signal with zeros?
03:38 FIR filter implementation
06:41 FIR filtering test
07:34 Summary
#dsp #cpp

Пікірлер: 32
@WolfSoundAudio
@WolfSoundAudio 2 жыл бұрын
Have I helped you with this video? If yes, please, consider buying me a ☕ coffee at www.buymeacoffee.com/janwilczek Thanks! 🙂
@asthasingh7267
@asthasingh7267 3 ай бұрын
Thanks for putting this up! Great help😊
@MoXyiD
@MoXyiD Жыл бұрын
Good shit bro! I needed to get re-upped on my convolution and you provided GREAT easy to understand (from an engineers perspective) content.
@WolfSoundAudio
@WolfSoundAudio Жыл бұрын
That's great, I'm happy to hear that!
@velvetsound
@velvetsound 2 жыл бұрын
This was fantastic, thank you. 😀
@WolfSoundAudio
@WolfSoundAudio 2 жыл бұрын
Great to hear that, thanks!
@danmiller4091
@danmiller4091 2 жыл бұрын
Super helpful video thank you very much!!
@WolfSoundAudio
@WolfSoundAudio 2 жыл бұрын
Awesome to hear that!
@robc3863
@robc3863 Жыл бұрын
Interesting that you used the sound response of a room to somehow make the music match. I think this needs a more generalised explanation because most non DSP mathematicians won't have understood IMO :)
@alexeykononov5596
@alexeykononov5596 3 ай бұрын
very thorough explanation, thanks 👍 I wish you well in your marketing agenda (it is much more complex than FIN Filter in C++ I presume 🤣)
@nickst2797
@nickst2797 6 ай бұрын
Thanks! Can you do an IIR tutorial as well?
@arunaideepan293
@arunaideepan293 2 жыл бұрын
Useful 👍
@WolfSoundAudio
@WolfSoundAudio 2 жыл бұрын
Thanks, great to hear!
@isaiahclemons1860
@isaiahclemons1860 Жыл бұрын
If I wanted to create an FIR low pass filter at a specific frequency how could I change this code to implement a desired corner frequency?
@farhatibrahim4034
@farhatibrahim4034 2 жыл бұрын
Also it is a fundamental filter for Video coding ;)
@WolfSoundAudio
@WolfSoundAudio 2 жыл бұрын
Yes, of course! And I want to leave talking about image and video FIR filters to more knowledgeable people :)
@athuldas44
@athuldas44 9 ай бұрын
How are u implementing sound with the code please can I know this is not domain i am intrested please any one ???
@MatkatMusic
@MatkatMusic 2 жыл бұрын
Why not use std::vector instead of raw C-style arrays?
@WolfSoundAudio
@WolfSoundAudio 2 жыл бұрын
Hi, Matkat Music, thanks for the question. Since in the filtering function we don't do any memory management, std::vector would be an unnecessary detail. However, if you look into the source code I linked to, you will see that these raw array pointers are initialized with std::vector::data() so they use vectors under the hood :)
@vblings
@vblings 2 жыл бұрын
for up-to-date cpp, std::span would be better idea.
@bigmistqke
@bigmistqke 2 жыл бұрын
Damn, that's a pretty crazy result for such a simple filter. I am a bit puzzled how we get from the impulse response to the coefficient list (dsp noob here), but will look into your code to figure out those details.
@bigmistqke
@bigmistqke 2 жыл бұрын
So, after a bit of thinking, are the coefficients just the magnitudes of each sample of that audio wave? Because an impulse is only 1 sample, all the other sound we hear is a result of convolution, w decaying size over time. Ok, little eye opener over here.
@bigmistqke
@bigmistqke 2 жыл бұрын
It's so bizarre and extremely fascinating how delay, reverberation and filtering are all one and the same thing. Makes sense in one way, twists around my head in the other.
@danmiller4091
@danmiller4091 2 жыл бұрын
@@bigmistqke The coefficients are calculated by multiplying the ideal impulse response of the filter with a windowing function. The textbook DSP A practical Approach by E C. Ifeachor and B. W. Jerwis has a nice examples if you are interested.
@bigmistqke
@bigmistqke 2 жыл бұрын
@@danmiller4091 thanks for answering my question! I am glossing over it right now, this dsp-literature is quite dense lol. But if i understand it correctly, this multiplying the audio-file of the impulse response by the windowing function is because we are interested in the energy of the signal, right? Makes sense, as it turns the waveform into how the volume changes over time, and that's what the coefficients are. And then from this generated buffer we would take sample #0 and this would be a(0), sample #1 a(1), ..., sample #n a(n)? I assume this is what they describe in the book as the 'direct method'.
@WolfSoundAudio
@WolfSoundAudio 2 жыл бұрын
So the coefficients are just a reversed impulse response with some zero padding for the ease of implementation ;) If we want to use an impulse response of a room as a filter, we don't have to preprocess it :) Windowing is only used when we design the filter in the frequency domain. Thanks for your feedback; my videos are here exactly to make the DSP literature more approachable!
@sadewosat
@sadewosat 10 ай бұрын
Can you explain Hilbert transform in c++ too?
@WolfSoundAudio
@WolfSoundAudio 10 ай бұрын
Noted, will try! Thanks! 🙂
@przekladanki
@przekladanki 2 жыл бұрын
Nice look with this shirt 🙃
@WolfSoundAudio
@WolfSoundAudio 2 жыл бұрын
Thanks!
@heddshot87
@heddshot87 11 ай бұрын
6:58 I thought you were playing Nokia ringtone
Efficient FIR Filter with SIMD and Loop Vectorization [DSP #16]
11:53
FIR Filter Design and Software Implementation - Phil's Lab #17
30:35
Clowns abuse children#Short #Officer Rabbit #angel
00:51
兔子警官
Рет қаралды 57 МЛН
Heartwarming moment as priest rescues ceremony with kindness #shorts
00:33
Fabiosa Best Lifehacks
Рет қаралды 13 МЛН
Can You Draw A PERFECTLY Dotted Circle?
00:55
Stokes Twins
Рет қаралды 45 МЛН
تجربة أغرب توصيلة شحن ضد القطع تماما
00:56
صدام العزي
Рет қаралды 54 МЛН
Top 5 Languages For Audio Programming
15:46
WolfSound
Рет қаралды 7 М.
ASMR Programming - Spinning Cube - No Talking
20:45
Servet Gulnaroglu
Рет қаралды 3,7 МЛН
Lessons Learned from a Decade of Audio Programming
26:14
Don't use VSCode
35:31
PyCon South Africa
Рет қаралды 214 М.
What Are SIMD Instructions? (With a Code Example) [DSP #14]
22:20
The Simplest Digital Filter (STM32 Implementation) - Phil's Lab #92
23:31
#3 - Understanding Finite Impulse Response (FIR) Filters
12:17
Fulcrum Acoustic
Рет қаралды 75 М.
Introduction to FIR Filters
11:06
Aaron Parsons
Рет қаралды 237 М.
why do header files even exist?
10:53
Low Level Learning
Рет қаралды 377 М.
smart appliances! new gadgets, versatile utensils, tool items #shorts #gadget
0:10
Pretty Balloon Family
Рет қаралды 14 МЛН
Замутили ролики 😂
0:42
Pavlov_family_
Рет қаралды 3,3 МЛН
Este tobogán es mío 😡
0:46
Yoila y Teey
Рет қаралды 19 МЛН
Papai e Bebê sincronizados #maternidade
0:11
Lackto
Рет қаралды 10 МЛН