tag:blogger.com,1999:blog-7225698277211840079.post1363206035109245967..comments2019-07-16T05:24:40.934-07:00Comments on bjorg: Basic Audio EQsBjorn Rochehttp://www.blogger.com/profile/17072425815152893296noreply@blogger.comBlogger21125tag:blogger.com,1999:blog-7225698277211840079.post-14300527215601806222019-05-29T08:23:23.551-07:002019-05-29T08:23:23.551-07:00Attenuate, yes, but you might need to use another ...Attenuate, yes, but you might need to use another technique (like a higher order filter) if you need to really reduce the high frequency content. You may want too try asking your question on a site like stack overflow.Bjorn Rochehttps://www.blogger.com/profile/17072425815152893296noreply@blogger.comtag:blogger.com,1999:blog-7225698277211840079.post-31757330948077782832017-11-30T00:22:54.963-08:002017-11-30T00:22:54.963-08:00Hey Bjorn, thanks for the post. Would it be possib...Hey Bjorn, thanks for the post. Would it be possible to implement a low-pass filter using this technique? specifically, I need to attenuate/remove/filter signals over 5Khz in a buffer of 2048 time-domain audio PCM samples with a sampling rate of 44.1Khz. Unknownhttps://www.blogger.com/profile/10438343443692698855noreply@blogger.comtag:blogger.com,1999:blog-7225698277211840079.post-22680346799000851402014-01-04T10:20:12.680-08:002014-01-04T10:20:12.680-08:00There are several solutions:
- Use two filters an...There are several solutions:<br /><br />- Use two filters and cross-fade them. You might think that you would loose the &quot;bending&quot; effect you get from tweaking the parameters directly, but if you choose your time interval correctly, that won&#39;t happen. Considering all the problems you could have with this technique (phase issues between the two crossfading filters, trying to figure out the optimal time interval, etc) it always seems to work remarkably well and it&#39;s what I recommend for most applications.<br />- There are alternatives to direct form I which have different stability characteristics. This is too complex for this post, but you can look up things like lattice filters and latter-latice filters. The interpolated values won&#39;t necessarily result in a filter that&#39;s between the values you are interpolating, but at least it will be stable, so as long as you interpolate frequently, this works well. I believe this is what most high-end digital audio equipment does.<br />- Interpolate the high-level parameters like frequency and bandwidth and recalculate the filter coefficients at each sample. This should work because, at each sample, the filter is guaranteed to be stable, but I&#39;m not positive it will remain stable because that logic doesn&#39;t take into account the recursively stored values. My intuition tells me this is the correct way to mimic analog filter behaviour, and should be stable at least within certain bounds. I have experimented with this technique and it seems to work, for whatever that&#39;s worth. At the end of the day, though, this is a huge amount of computation to do while varying parameters and not worth it for most applications.<br /><br />There are probably other techniques I&#39;m either unaware of forgetting right now. When in doubt, use the cross-fading technique.Bjorn Rochehttps://www.blogger.com/profile/17072425815152893296noreply@blogger.comtag:blogger.com,1999:blog-7225698277211840079.post-27298437898546750812014-01-02T20:47:29.503-08:002014-01-02T20:47:29.503-08:00Fantastically helpful, thank you! I am particularl...Fantastically helpful, thank you! I am particularly interested in (and amused by) your comments on the folly of trying to sweep a filter by interpolating between coefficient values. So how _does_ one sweep a biquad or other digital filter smoothly, without unleashing the numerical fury of hell?Julia Truchsesshttps://www.blogger.com/profile/14926321410262884545noreply@blogger.comtag:blogger.com,1999:blog-7225698277211840079.post-61357969626856500552013-11-11T16:12:25.525-08:002013-11-11T16:12:25.525-08:00Ok, I will try that, thanksOk, I will try that, thanksAvetis Petrosyanhttps://www.blogger.com/profile/10297267794467797042noreply@blogger.comtag:blogger.com,1999:blog-7225698277211840079.post-25204553439806412722013-11-11T13:21:13.122-08:002013-11-11T13:21:13.122-08:00I&#39;m afraid that my blogs comment section isn&#...I&#39;m afraid that my blogs comment section isn&#39;t really the right place for technical QA. I suggest you try posting your question on dsp.stackexchange.com or stackoverflow.com. If you tag it audio, I often see and, time permitting, answer those questions.Bjorn Rochehttps://www.blogger.com/profile/17072425815152893296noreply@blogger.comtag:blogger.com,1999:blog-7225698277211840079.post-6973784960624497262013-11-11T00:06:27.901-08:002013-11-11T00:06:27.901-08:00Great write up, makes the audio cookbook easier to...Great write up, makes the audio cookbook easier to understand!<br /><br />Background info: I&#39;ve modified the rtl-sdr open source code to tune to a VOR station (transmits heading, typically used for aircraft). I tune to 113.1 MHz which is the nearby VOR station. Inside that 113.1 MHz frequency, there are 3 signals; <br />1 - Morse Code at 1020Hz<br />2 - Reference Signal (9960Hz +- 480Hz) (FM this signal, inside this there is another 30Hz signal)<br />3 - Variable Signal (30Hz) <br /><br />I&#39;m trying to isolate these signals. Now when I tune to the station (113.1MHz) and perform amplitude modulation, I can hear the Morse code signal from the speaker with lots of noise in the background. I followed your guide along with the audio cookbook to write a BPF function (pasted below) to isolate the Morse code signal (1020Hz) to hear only the morse code with very little to no noise in the background. However, I just about hear nothing, it&#39;s like someone just really lowered the volume almost to mute. I&#39;m starting with this because if I can actually hear the morse code signal, then that proves that the BPF works and now I can use that function to isolate the other two signals.<br /><br />The values I used to compute a0 to b2: I also did normalize the a0 to b2 values.<br />1. Sample Rate: 24KHz<br />2. Center Freq: 1020Hz<br />3. BW (in octaves): 1 (don&#39;t really understand this)<br />4. gain: 1 (assuming 1 should be ok but again not really sure)<br /><br />BPF Function:<br />int band_pass_fir(struct morse *_m, int16_t *_signal, int _len)<br />{<br /> // _m-&gt;signal (int16 array) is my desired output<br /> // _signal (int16 array) contains the actual amplitude modulated data received from the signal<br /> // _len is the length of _signal<br /> <br /> int i = 2;<br /><br /> const float b0 = 0.1205498139,<br /> b1 = 0,<br /> b2 = -0.1205498139,<br /> a1 = -1.7626236142,<br /> a2 = 0.8273910712;<br /><br /> while (i &lt; _len)<br /> {<br /> _m-&gt;signal[i] = (int16_t)(b0 * _signal[i]) +<br /> (int16_t)(b1 * _signal[i-1]) +<br /> (int16_t)(b2 * _signal[i-2]) -<br /> (int16_t)(a1 * _m-&gt;signal[i-1]) -<br /> (int16_t)(a2 * _m-&gt;signal[i-2]);<br /><br /> _m-&gt;signal[i-2] = _m-&gt;signal[i-1];<br /> _m-&gt;signal[i-1] = _m-&gt;signal[i];<br /><br /> i++;<br /> }<br />}<br /><br />Questions:<br />1. To isolate this 1020Hz signal, is it safe to assume I need a BPF? or do I need some other type of filter?<br />2. Assuming whatever type of filter I need to isolate the 1020Hz would be the same type of filter I would need to isolate the 30Hz signal (variable signal) ? Is that correct?<br />3. Do you see if I&#39;m doing anything wrong with my above method?<br /><br />If there is something I didn&#39;t mention or something that&#39;s unclear, please ask and I will respond quickly.<br />Thank you in advance and Any help would be GREATLY APPRECIATED!Avetis Petrosyanhttps://www.blogger.com/profile/10297267794467797042noreply@blogger.comtag:blogger.com,1999:blog-7225698277211840079.post-12061054569101795392013-08-27T21:01:08.247-07:002013-08-27T21:01:08.247-07:00For audio signals, you typically use your ears to ...For audio signals, you typically use your ears to determine if there is enough separation between your source and your noise. If your ears are not trained enough, you just try it and see. For example, you might adjust the low-pass filter&#39;s center frequency while listening to the results. If that doesn&#39;t work, the best solution depends on nature of the noise and the signal. One class of methods is called &quot;broadband noise reduction&quot;. There are also some voice specific techniques. I&#39;m not familiar with this area, but I think they are based (at least loosely) on Weiner filters. At the end of the day, of course, there&#39;s only so much you can do to eliminate unwanted sounds.Bjorn Rochehttps://www.blogger.com/profile/17072425815152893296noreply@blogger.comtag:blogger.com,1999:blog-7225698277211840079.post-40244189847623085892013-08-27T14:51:07.658-07:002013-08-27T14:51:07.658-07:00How will i know if the background noise is high fr...How will i know if the background noise is high frequency or not,,, and if a simple EQ doesn&#39;t work what would i need to use?Eman abojaradehhttps://www.blogger.com/profile/01806078820032004061noreply@blogger.comtag:blogger.com,1999:blog-7225698277211840079.post-6221659921053351642013-08-27T10:53:21.396-07:002013-08-27T10:53:21.396-07:00Well, it depends. Loosely speaking, using a lowpas...Well, it depends. Loosely speaking, using a lowpass filter assumes that most of what you want to keep is of lower frequency than most of what you want to get rid of. If that&#39;s the case, then yes, this is a good starting point. This kind of technique is often used, for example, to remove hiss from old movies. If there is significant overlap between the frequencies, then simple EQ won&#39;t do the job.Bjorn Rochehttps://www.blogger.com/profile/17072425815152893296noreply@blogger.comtag:blogger.com,1999:blog-7225698277211840079.post-18589759618231488742013-08-27T10:29:18.769-07:002013-08-27T10:29:18.769-07:00thank you so much for this blog , it was very help...thank you so much for this blog , it was very helpful... but i was wondering, I&#39;m working on doing a filter which removes back ground noise, which i think means im gonna be needing a low- pass filter,,, soo should i implement what you have in this blog?? (like make the Psuedo code into a real code in java)<br />like am i in the right direction???Eman abojaradehhttps://www.blogger.com/profile/01806078820032004061noreply@blogger.comtag:blogger.com,1999:blog-7225698277211840079.post-76406184689997994162013-06-13T08:22:27.297-07:002013-06-13T08:22:27.297-07:00Some analog (and digital) EQs are &quot;constant Q...Some analog (and digital) EQs are &quot;constant Q&quot;, but most are not. This is most relevant in graphic equalizers. Rane has a nice document here: http://www.rane.com/note101.htmlBjorn Rochehttps://www.blogger.com/profile/17072425815152893296noreply@blogger.comtag:blogger.com,1999:blog-7225698277211840079.post-73762624836027379992013-06-13T07:49:11.973-07:002013-06-13T07:49:11.973-07:00Note that RBJ&#39;s EQ filters are not constant-Q ...Note that RBJ&#39;s EQ filters are not constant-Q filters like the ones used in analog audio EQs. See https://gist.github.com/endolith/5455375#file-biquad_cookbook-py-L338 for a modification to make it constant QAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-7225698277211840079.post-79304066184795612332013-06-04T05:21:34.718-07:002013-06-04T05:21:34.718-07:00This comment has been removed by the author.Blog testhttps://www.blogger.com/profile/05272516655161567247noreply@blogger.comtag:blogger.com,1999:blog-7225698277211840079.post-39585930596462105092012-12-06T06:24:22.895-08:002012-12-06T06:24:22.895-08:00bjorn, very kind, very informative, thanks.
bjorn, very kind, very informative, thanks.<br />hellohttps://www.blogger.com/profile/13078300404459054082noreply@blogger.comtag:blogger.com,1999:blog-7225698277211840079.post-76799946772965234932012-12-01T09:39:40.714-08:002012-12-01T09:39:40.714-08:00I was being somewhat hyperbolic with the goal of s...I was being somewhat hyperbolic with the goal of steering people towards something that will be the right decision most of the time, even if they heard otherwise from someone. But you ask a fair question, of course.<br /><br />Both DF I and DF II can be implemented with 5 multiplies and 4 adds (for a standard biquad) so by simple measure of computational complexity they are equally efficient. However, DF II requires only 2 memory locations as opposed to 4 for DF I, so it is more space efficient. This is why some people call it &quot;canonical&quot; since it&#39;s the minimum number of memories. However, it is not as stable, and does not have as good error propagation properties. If you are so pressed for memory that you are worried about those two memory locations, you are probably on very limited hardware. In this case, you need to start thinking seriously about what kind of memory locations you have. Some hardware (and here I am not an expert) does not have enough overflow for example. So, even in the case of extremely limited hardware DF I might be the better choice. Hardware designers often use exotic implementations with more multiplies and adds to minimize these kinds of problems, but DF I is a good start.<br /><br />As to odd-order filters: yes, it is common to use first and second order filters in series, as well as third and second.Bjorn Rochehttps://www.blogger.com/profile/17072425815152893296noreply@blogger.comtag:blogger.com,1999:blog-7225698277211840079.post-36986981592723870932012-12-01T08:49:10.402-08:002012-12-01T08:49:10.402-08:00hi bjorn. thanks so much for this.
you say:
&quot...hi bjorn. thanks so much for this.<br /><br />you say:<br />&quot;&quot;Direct form II&quot; has some admirers, but those people are either suffering from graduate-school-induced trauma or actually have some very good reason for doing what they are doing that in all likelihood does not apply to you.&quot;<br /><br />...i probably naively thought that the direct form II, or more importantly &#39;transposed&#39; direct form II, was simply a more efficient (less calculations) version of the direct form I, and therefore good for &quot;we can often simply take several second order filters and place them in series to simulate the effect of a single higher order filter&quot;<br /><br />why am i so wrong? any help for this simpleton would be greatly appreciated.<br /><br />and if you are feeling generous: rather than simply &#39;repeating&#39; 2nd order filters to create a cascade to a higher order filter, what optimisations could be made in this technique? also, i never understand how to go about making odd-numbered ordered filters in this stacking technique; do we use first order filters?<br />hellohttps://www.blogger.com/profile/13078300404459054082noreply@blogger.comtag:blogger.com,1999:blog-7225698277211840079.post-83902998739798390922012-11-18T09:44:24.861-08:002012-11-18T09:44:24.861-08:00Thanks for your comment. I may revisit this after ...Thanks for your comment. I may revisit this after giving it some more thought, but I think the best short answer is &quot;probably not the way you want.&quot; Second order filters give you a huge amount of flexibility you just can&#39;t get from a first order filter, which is why they are such a workhorse.Bjornhttps://www.blogger.com/profile/04592952162780898505noreply@blogger.comtag:blogger.com,1999:blog-7225698277211840079.post-70212682988055679072012-11-18T09:32:04.246-08:002012-11-18T09:32:04.246-08:00Hey Bjorn!
Like you said, &quot;even more control...Hey Bjorn!<br /><br />Like you said, &quot;even more control than a second order filter offers, we can often simply take several second order filters and place them in series to simulate the effect of a single higher order filter.&quot;<br /><br />Is it also possible to put 2 (or more) first order filters to simulate a 2nd order filter ?<br /><br />thanks,<br />shashankShashank Kumarhttps://www.blogger.com/profile/10287168170933391798noreply@blogger.comtag:blogger.com,1999:blog-7225698277211840079.post-21992440932922410472012-09-27T12:53:35.983-07:002012-09-27T12:53:35.983-07:00Thanks Distante. I have not noticed the issue with...Thanks Distante. I have not noticed the issue with the Xonami mailing list, but I&#39;ll be sure to look into it.Bjorn Rochehttps://www.blogger.com/profile/17072425815152893296noreply@blogger.comtag:blogger.com,1999:blog-7225698277211840079.post-37934294762466882492012-08-31T16:44:33.069-07:002012-08-31T16:44:33.069-07:00Great material! I&#39;m a (late) student of audio ...Great material! I&#39;m a (late) student of audio and sound techniques in the last semester or my career (I hope :P ) and Instead of do a recording for my final project I choose to try to do a audio soft for ear training, because of this, I got stuck with the design and code of the filter for the eq.<br /><br />I find your blog Trying to have a better understand the RBJ cookbook, and this post! In the day of my B-day! haha cool! and thanks!<br /><br />Ps: The mailing list of xonami is working ok BUT even when the fields were correctly filled, the page says that an error occurred (either way the verification email for the list arrive ok) distantehttps://www.blogger.com/profile/11450711494725110594noreply@blogger.com