-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256
On 2014-08-19 22:09, Alexandros Drymonitis wrote:
Here's my perform routine: t_int *vanDerPol_perform(t_int *w) { // Copy the object pointer t_vanDerPol *x = (t_vanDerPol *) (w[1]);
// Copy signal vector pointers t_float *frequency = (t_float *) (w[2]); t_float *factor = (t_float*) (w[3]); t_float *excitor_freq = (t_float*) (w[4]); t_float *excitor_amp = (t_float*) (w[5]); t_float *output = (t_float *) (w[6]);
the scalar type for signals is really *t_sample*. you should NOT use *t_float* for these kind of things (though in practice they two might always be the same). if you are following a tutorial that suggests to use t_float, then report a bug to the author of the tutorial.
// Copy the signal vector size t_int n = w[7];
// Dereference components from the object structure float twopi = x->x_twopi;
now that looks very much like a constant, which you don't need to modify per-object...
// excitor code si = *excitor_freq++ * si_factor; phase_local = phase / step; drive_sine = cos(phase_local * twopi) * *excitor_amp++;
i guess you are copying the CSound code here. however, i really think it would be much better to use an "external" excitor, that is: instead of having an input for the frequency and another input for the amplitude of the internal sine oscillator, you might want to have a single input for an in-patch sine-oscillator.
so your patch would look like: | [osc~ 666] | [*~ 0.42] | [vanderpol~] |
(it might make sense to make the excitor input the first one, so you can use it
this has two huge advantages: #1 Pd's oscillator is known to work; if it ever breaks, it will be fixed immediately. thus you don't need to re-code existing functionality, possibly introducing bugs.
#2 you might want to use another exciter waveform, and get results unheard of. without any additional coding effort! for free!!
// van der Pol code c = 2 - 2 * cos(*frequency++ * twopi / sr);
again, it might be better to use an external signal to drive this oscillator.
aa = (-c) * ax + *factor++ * (1 - ax * ax) * av; av += aa; ax = ax
- av + drive_sine; *output++ = av;
hmm. you are resetting "av" and "ax" to 0 for each DSP-block. most likely this is not what you want, as the srtucture looks like a feedback filter (IIR), so you need to store ax&av between DSP-blocks.
fgmsdar IOhannes