Help with freq detection... Bug in spike~ ?


    Nov 05 2010 | 6:05 am
    Hi,
    I'm using [spike~] to calculate the frequency of a signal that's essentially a pulse train. Using [train~] as test input, I discovered that [spike~] starts outputting faulty values when the period drops below 3ms, and seriously messes up when the period is less than 1ms. The compressed test patch I'm using to test [spike~] is included below.
    It looks like [spike~] wasn't intended to detect periods below a certain threshold.
    Can anyone suggest another approach to detect frequency of a pulse train signal that ranges from 6 to 5000 Hz?
    Thank you,
    Ray

    • Nov 05 2010 | 11:50 am
      seems like [spike~] calculates the intervals only between signal vectors, as opposed to [zerox~] which calculates the zerocrossings within _one_ signal vector.
      Try setting the signal vector size to 1 sample and see if you can sufficient accurate readings with [spike~]...
    • Nov 05 2010 | 3:13 pm
      mudang, thank you! I'm new to msp and never would have guessed this.
      setting vector size to 1 works for periods less than 1ms, but I still am getting errors coming from [spike~]:
      [train~] = 0.2ms
      [spike~] = one of following 3 values at random (?)
      0.204082
      0.181406
      0.000000
      I think I can do some averaging to get a constant number, but the 0.0 output is weird.
      Thanks again!
      Ray
    • Nov 05 2010 | 3:32 pm
      p.s.
      DSP Status
      [x] Scheduler in Overdrive
      [x] in Audio Interrupt
      got rid of 0.0 errors but then my computer froze :)