<div dir="ltr">well, here&#39;s an attempt to make bp out of [fexpr~]<div><br></div><div>and... it did not work</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2014-04-10 22:07 GMT-03:00 Alexandre Torres Porres <span dir="ltr">&lt;<a href="mailto:porres@gmail.com" target="_blank">porres@gmail.com</a>&gt;</span>:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">hey, the code I sent only calculates the coeficients, but I left out an important part which is <div><br>
</div><div><p class="MsoNormal"><span style="font-size:11pt;font-family:&#39;Menlo Regular&#39;">t_sample output =</span> *in++ + coef1 * last + coef2 * prev<span style="font-size:11pt;font-family:&#39;Menlo Regular&#39;">;</span></p>

<p class="MsoNormal"><span style="font-size:11pt;font-family:&#39;Menlo Regular&#39;">        *out++ = gain * output;</span></p><p class="MsoNormal"><span style="font-size:11pt;font-family:&#39;Menlo Regular&#39;">        prev = last;</span></p>

<p class="MsoNormal"><span style="font-size:11pt;font-family:&#39;Menlo Regular&#39;">        last = output;</span></p><p class="MsoNormal"><span style="font-size:11pt;font-family:&#39;Menlo Regular&#39;"><br>
</span></p><p class="MsoNormal"><span style="font-size:11pt;font-family:&#39;Menlo Regular&#39;">This shows how the filter is done with those coefficients</span></p><p class="MsoNormal"><span style="font-size:11pt;font-family:&#39;Menlo Regular&#39;"><br>

</span></p><p class="MsoNormal"><span style="font-size:11pt;font-family:&#39;Menlo Regular&#39;">It&#39;s easy to implement this with [fexpr~], it goes something like:</span></p><p class="MsoNormal"><span style="font-size:11pt;font-family:&#39;Menlo Regular&#39;"><br>

</span></p><p class="MsoNormal"><font color="#000000" face="Menlo Regular"><span style="font-size:14.666666984558105px">[fexpr~ $x + (coef1 * $x1[-1]) + (coef2 * $x1[-2])]</span></font><br></p><p class="MsoNormal"><span style="font-size:11pt;font-family:&#39;Menlo Regular&#39;"><br>

</span></p><p class="MsoNormal"><span style="font-size:11pt;font-family:&#39;Menlo Regular&#39;">It&#39;s seems this formula can also be achieved done with biquad, which receives a list where the first two elements are the same coefficients.</span></p>

<p class="MsoNormal"><span style="font-size:11pt;font-family:&#39;Menlo Regular&#39;"><br></span></p><p class="MsoNormal"><span style="font-size:11pt;font-family:&#39;Menlo Regular&#39;">But it still doesn&#39;t seem it is as simple as that. Maybe there&#39;s also something regarding the gain of the filter or something. </span></p>

<p class="MsoNormal"><span style="font-size:11pt;font-family:&#39;Menlo Regular&#39;"><br></span></p><p class="MsoNormal"><span style="font-size:11pt;font-family:&#39;Menlo Regular&#39;">Hope the wizards can help me solve this </span></p>

<p class="MsoNormal"><span style="font-size:11pt;font-family:&#39;Menlo Regular&#39;"><br></span></p><p class="MsoNormal"><span style="font-size:11pt;font-family:&#39;Menlo Regular&#39;">Cheers</span></p>
<p class="MsoNormal"><br></p><p class="MsoNormal"><span style="font-size:11pt;font-family:&#39;Menlo Regular&#39;"><br></span></p><p class="MsoNormal"><span style="font-size:11pt;font-family:&#39;Menlo Regular&#39;"><br>

</span></p></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2014-04-09 14:20 GMT-03:00 Alexandre Torres Porres <span dir="ltr">&lt;<a href="mailto:porres@gmail.com" target="_blank">porres@gmail.com</a>&gt;</span>:<div>
<div class="h5"><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><p><span></span></p><div><span style="font-size:12.727272033691406px;color:rgb(80,0,80);font-family:arial,sans-serif">&quot;</span><span style="font-size:12.727272033691406px;color:rgb(80,0,80);font-family:sans-serif">I&#39;d start with a look at the [bp~] source to see if you can extract some hints about how the filter is implemented.&quot;<br>


</span><br></div>Anyway, this is what I got from the code. But I wasn&#39;t successful to extract biquad coefficients from it. I still assume it can be done. It says it&#39;s a 2-pole bandpass filter, so I understand you can get to it with biquad, cause biquad is 2-pole and 2-zero. It&#39;s just a matter to get rid of the zeros somehow. I was able to leave them with a vlue of 0, but didn&#39;t seem to do the job.<p>

</p>
<p><span><br></span></p><p><span>thanks </span></p><p><span><br></span></p><p><span>static</span> t_float sigbp_qcos(t_float f)</p>
<p>{</p>
<p>    <span>if</span> (f &gt;= -(<span>0.5f</span>*<span>3.14159f</span>) &amp;&amp; f &lt;= <span>0.5f</span>*<span>3.14159f</span>)</p>
<p>    {</p>
<p>        t_float g = f*f;</p>
<p>        <span>return</span> (((g*g*g * (-<span>1.0f</span>/<span>720.0f</span>) + g*g*(<span>1.0f</span>/<span>24.0f</span>)) - g*<span>0.5</span>) + <span>1</span>);</p>

<p>    }</p>
<p><span>    </span>else<span> </span>return<span> (</span><span>0</span><span>);</span></p>
<p>}</p>
<p><br></p>
<p><span>static</span> <span>void</span> sigbp_docoef(t_sigbp *x, t_floatarg f, t_floatarg q)</p>
<p>{</p>
<p>    t_float r, oneminusr, omega;</p>
<p>    <span>if</span> (f &lt; <span>0.001</span>) f = <span>10</span>;</p>
<p>    <span>if</span> (q &lt; <span>0</span>) q = <span>0</span>;</p>
<p>    x-&gt;x_freq = f;</p>
<p>    x-&gt;x_q = q;</p>
<p>    omega = f * (<span>2.0f</span> * <span>3.14159f</span>) / x-&gt;x_sr;</p>
<p>    <span>if</span> (q &lt; <span>0.001</span>) oneminusr = <span>1.0f</span>;</p>
<p>    <span>else</span> oneminusr = omega/q;</p>
<p>    <span>if</span> (oneminusr &gt; <span>1.0f</span>) oneminusr = <span>1.0f</span>;</p>
<p>    r = <span>1.0f</span> - oneminusr;</p>
<p>    x-&gt;x_ctl-&gt;c_coef1 = <span>2.0f</span> * sigbp_qcos(omega) * r;</p>
<p>    x-&gt;x_ctl-&gt;c_coef2 = - r * r;</p>
<p>    x-&gt;x_ctl-&gt;c_gain = <span>2</span> * oneminusr * (oneminusr + r * omega);</p>
<p><span>    </span>/* post(&quot;r %f, omega %f, coef1 %f, coef2 %f&quot;,</p>
<p>        r, omega, x-&gt;x_ctl-&gt;c_coef1, x-&gt;x_ctl-&gt;c_coef2); */</p>
<p>}</p></div><div class="gmail_extra"><br><br><div class="gmail_quote">2014-04-08 22:21 GMT-03:00 Alexandre Torres Porres <span dir="ltr">&lt;<a href="mailto:porres@gmail.com" target="_blank">porres@gmail.com</a>&gt;</span>:<div>

<div><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>&quot;<span style="font-family:sans-serif;font-size:12.727272033691406px">I&#39;d start with a look at the [bp~] source to see if you can extract some hints about how the filter is implemented.&quot;</span><div>



<span style="font-family:sans-serif;font-size:12.727272033691406px"><br></span></div></div><div><span style="font-family:sans-serif;font-size:12.727272033691406px">Done that, way out of my head. What I can deal with is wether I can get to it with biquad coefficients.</span></div>



<div><span style="font-family:sans-serif;font-size:12.727272033691406px"><br></span></div><div><span style="font-family:sans-serif;font-size:12.727272033691406px">thanks</span></div><div><span style="font-family:sans-serif;font-size:12.727272033691406px"><br>



</span></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2014-04-08 21:28 GMT-03:00 Bill Gribble <span dir="ltr">&lt;<a href="mailto:grib@billgribble.com" target="_blank">grib@billgribble.com</a>&gt;</span>:<div>


<div><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">



<div>
<div style="font-family:sans-serif">
<p>The quick and dirty way is just to feed the filter white noise and plot
the output signal&#39;s spectrum.   Guaranteed to show the actual
performance of the filter, and not somebody&#39;s idea of how it ought to be
working.</p>
<p>If you need a theoretical curve, I&#39;d start with a look at the [bp~]
source to see if you can extract some hints about how the filter is
implemented.  It may be quite easy to figure out the poles and zeros
if the code is clear and/or documented.</p>
<p>Good luck! <br><span><font color="#888888">
Bill Gribble<br>
</font></span></p>
</div>
</div>

</blockquote></div></div></div><br></div>
</blockquote></div></div></div><br></div>
</blockquote></div></div></div><br></div>
</blockquote></div><br></div>