Hi,
I would highly appreciate some assistance in grasping how signals are processed in DSP objects.
Working on the following template, I will demonstrate variations in the <PROCESS BLOCK>. As results do not appear as the way I expect, there must be something I am not understanding correctly.
========== Template ==========
t_int *foobar_tilde_perform(t_int *w) { t_sample *in = (t_sample *)(w[1]); t_sample *out = (t_sample *)(w[2]); int n = (int)(w[3]);
<PROCESS BLOCK>
return (w+4); }
===================== == PROCESS BLOCK.1 == =====================
while (n--) { *out++ = *in++; }
Remarks: Simple THRU... works as expected.
===================== == PROCESS BLOCK.2 == =====================
while (n--) { // *out++ = *in++; }
Remarks: Action is commented out but signal goes through.. Why?
===================== == PROCESS BLOCK.3 == =====================
while (n--) { *out++ = *in++ * -1; }
Remarks: Inverse signal, as expected
===================== == PROCESS BLOCK.4 == =====================
n--; *out++ = 0; while (n--) { *out++ = *in++; }
Remarks: Expecting first sample of the block to be zero and others delayed by 1 sample. Instead, I get an constant output of zero.
I hope what I am missing is something obvious to those with insight.
Thanks.
-- David Shimamoto
Hi David,
Am 14.06.2008 um 03:08 schrieb PSPunch:
===================== == PROCESS BLOCK.2 == =====================
while (n--) { // *out++ = *in++; }
Remarks: Action is commented out but signal goes through.. Why?
that's because in and out can point to the same memory... signal vectors are reused in PD for cache-friendlyness.
===================== == PROCESS BLOCK.4 == =====================
n--; *out++ = 0; while (n--) { *out++ = *in++; }
Remarks: Expecting first sample of the block to be zero and others delayed by 1 sample. Instead, I get an constant output of zero.
As above... you have to be aware that when you are writing to the output, you change the input. Either cache the input or use a different algorithm (in this case start from the end)
gr~~~