<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Aug 20, 2014 at 10:30 AM, IOhannes m zmoelnig <span dir="ltr"><<a href="mailto:zmoelnig@iem.at" target="_blank">zmoelnig@iem.at</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">-----BEGIN PGP SIGNED MESSAGE-----<br>
Hash: SHA256<br>
<div class=""><br>
On 2014-08-19 22:09, Alexandros Drymonitis wrote:<br>
><br>
> Here's my perform routine: t_int *vanDerPol_perform(t_int *w) { //<br>
> Copy the object pointer t_vanDerPol *x = (t_vanDerPol *) (w[1]);<br>
><br>
> // Copy signal vector pointers t_float *frequency = (t_float *)<br>
> (w[2]); t_float *factor = (t_float*) (w[3]); t_float *excitor_freq<br>
> = (t_float*) (w[4]); t_float *excitor_amp = (t_float*) (w[5]);<br>
> t_float *output = (t_float *) (w[6]);<br>
<br>
</div>the scalar type for signals is really *t_sample*.<br>
you should NOT use *t_float* for these kind of things (though in<br>
practice they two might always be the same).<br>
if you are following a tutorial that suggests to use t_float, then<br>
report a bug to the author of the tutorial.<br></blockquote><div>OK, changed it. <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class=""><br>
><br>
> // Copy the signal vector size t_int n = w[7];<br>
><br>
> // Dereference components from the object structure float twopi =<br>
> x->x_twopi;<br>
<br>
</div>now that looks very much like a constant, which you don't need to<br>
modify per-object...<br></blockquote><div>I'm setting its value in the new instance routine by multiplying atan(1.0) by 8, instead of writing it as a macro.<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div class=""><br>
> // excitor code si = *excitor_freq++ * si_factor; phase_local =<br>
> phase / step; drive_sine = cos(phase_local * twopi) *<br>
> *excitor_amp++;<br>
<br>
</div>i guess you are copying the CSound code here.<br>
however,  i really think it would be much better to use an "external"<br>
excitor, that is: instead of having an input for the frequency and<br>
another input for the amplitude of the internal sine oscillator, you<br>
might want to have a single input for an in-patch sine-oscillator.<br>
<br>
so your patch would look like:<br>
|<br>
[osc~ 666]<br>
|<br>
[*~ 0.42]<br>
|<br>
[vanderpol~]<br>
|<br>
<br>
(it might make sense to make the excitor input the first one, so you<br>
can use it<br>
<br>
this has two huge advantages:<br>
#1 Pd's oscillator is known to work; if it ever breaks, it will be<br>
fixed immediately.<br>
thus you don't need to re-code existing functionality, possibly<br>
introducing bugs.<br>
<br>
#2 you might want to use another exciter waveform, and get results<br>
unheard of.<br>
without any additional coding effort! for free!!<br></blockquote><div>Did that as well. <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class=""><br>
><br>
> // van der Pol code c = 2 - 2 * cos(*frequency++ * twopi / sr);<br>
<br>
</div>again, it might be better to use an external signal to drive this<br>
oscillator.<br></blockquote><div>How? Can you provide a patch example? Or should I just translate this in an abstraction? <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div class=""><br>
<br>
> aa = (-c) * ax + *factor++ * (1 - ax * ax) * av; av += aa; ax = ax<br>
> + av + drive_sine; *output++ = av;<br>
<br>
</div>hmm.<br>
you are resetting "av" and "ax" to 0 for each DSP-block.<br>
most likely this is not what you want, as the srtucture looks like a<br>
feedback filter (IIR), so you need to store ax&av between DSP-blocks.<br></blockquote>Fixed that too and the result is indeed much better. I don't think though that this implementation is good. The output doesn't really look like the example one finds online.<br>
</div><div class="gmail_quote">I've attached the .c file if anyone wants to take a look.<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<br>
<br>
fgmsdar<br>
IOhannes<br>
<br>
-----BEGIN PGP SIGNATURE-----<br>
Version: GnuPG v1<br>
<br>
iQIbBAEBCAAGBQJT9E58AAoJELZQGcR/ejb4BOIP+PL3nuKFhAMbv3uJDOn6QElf<br>
ykV7IpVJ9eWfO8dYUguT/afrUjKbEytWoq0rgC5mKPvKXvWK3OZaIxgQh6D2uqEr<br>
/ar1DyCu0daZh8V5ic2PC3QMdF/3eumRyLKyZJ4iWURhSsIrnamwVNONSc00wKPa<br>
ck3jQx05Z7v9vgCBFiXpgj1SuyihJSpgCPNU5DYpRmwmvGNt3BgyJv9xKjQFhLvO<br>
un3bSjeStijmRftz9g2SwoXQkLrHU2ieHvqBlE4iSj+V9dalxx4SIvH5Bzn74u+X<br>
MQMS/ndF8YIvlmnP91F0GXKuVNS8YqbgJsNY+69JEbgLvcZzsCTUUv1MDKyxQrMy<br>
7jr/JGslJcj/DlG9P2xWJ2OeuT7uCv6uhYgGTW2VXYC266hmBQ8BVezl9BmW9PFU<br>
yD9UeBie94sNV7R38G48FVdb9hztFVel58hJG3jJjDpVir5zRYITfcv2DMf1xbNb<br>
rsrwbkNxxeCY8euhZiaTe03qgOkTYXigwJgfl3D7gY3fPGRd/NFw45sKk7VmmTd1<br>
LLn8DEDOCAUMGG+Nbl/sACy+iJSEy/MmsaNVe0t58W6sYYSmRm37xYm4MtIdwGRP<br>
N+PdS3gpUwFPKgzQA+1FMdByh78M9KZu9eqIUoCKxvrU43QFmqT4+wehZx2yNF3/<br>
NhVFjIZx8D6+719+VKA=<br>
=mfTs<br>
-----END PGP SIGNATURE-----<br>
<br>
_______________________________________________<br>
Pd-dev mailing list<br>
<a href="mailto:Pd-dev@lists.iem.at">Pd-dev@lists.iem.at</a><br>
<a href="http://lists.puredata.info/listinfo/pd-dev" target="_blank">http://lists.puredata.info/listinfo/pd-dev</a><br>
</blockquote></div><br></div></div>