Order of access to DSP signals important?


    Aug 13 2008 | 12:23 pm
    Hey all-
    I noticed the following. If I have a 2-input, 1-output MSP external,
    and I access the vector array inside the DSP loop like so:
    buf[r_indx] = *++in1;
    tmp = *++in2;
    [...]
    *++out = buf[w_indx];
    Everything is fine. But if I access the second input out of order like
    so:
    buf[r_indx] = *++in1;
    [...]
    *++out = buf[w_indx];
    tmp = *++in2;
    tmp seems to never take the values of the second input signal, it's
    always zero.
    Anyone else noticed this, or am I crazy/mistaken? Can anyone amplify on
    the situation?
    Thanks, Charles

    • Aug 13 2008 | 1:50 pm
      On 2008 Aug 13, at 7:23 AM, Charles Turner wrote:
      > Hey all-
      >
      > I noticed the following. If I have a 2-input, 1-output MSP external,
      > and I access the vector array inside the DSP loop like so:
      >
      > buf[r_indx] = *++in1;
      > tmp = *++in2;
      > [...]
      > *++out = buf[w_indx];
      >
      > Everything is fine. But if I access the second input out of order like
      > so:
      >
      > buf[r_indx] = *++in1;
      > [...]
      > *++out = buf[w_indx];
      > tmp = *++in2;
      >
      > tmp seems to never take the values of the second input signal, it's
      > always zero.
      >
      > Anyone else noticed this, or am I crazy/mistaken? Can anyone amplify
      > on
      > the situation?
      There is an optimization in MSP to share and re-use signal vectors,
      and it sounds like this is causing your trouble. Try setting the
      Z_NO_INPLACE flag to turn the optimization off. Something like this
      in your new method:
      x->x_ob.z_misc = Z_NO_INPLACE;
      best,
      Tim
    • Aug 13 2008 | 2:12 pm
      On Wed, 13 Aug 2008 08:50:42 -0500, Timothy Place wrote:
      > There is an optimization in MSP to share and re-use signal vectors,
      > and it sounds like this is causing your trouble. Try setting the
      > Z_NO_INPLACE flag to turn the optimization off. Something like this
      > in your new method:
      > x->x_ob.z_misc = Z_NO_INPLACE;
      Thanks for the info, Tim. The order isn't critical for me, so it was
      easily addressed. Did a few hours of head scratching before I figured
      out what I was doing wrong, though!
      Best, Charles