Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 13 of 13

Thread: Synth & Freq Measure T4

  1. #1
    Member
    Join Date
    Jan 2015
    Location
    Toms River, NJ USA
    Posts
    52

    Synth & Freq Measure T4

    I'm hoping someone can direct me to a solution...

    I want to accurately detect the frequency of an external VCO source (using something like Freq Measure library) and track some Teensy synth Waveform objects to it.

    In theory (my theory at least), it should be easy to take the frequency output of FreqMeasure and simply feed to to the Waveform object. It seems from my limited knowledge however, that the two processes are competing for CPU time and BOTH have critical time requirements.

    From what I've read, the T4 CPU only has one core, so I couldn't even wish for a CPU hardware level solution.

    One thought, was to use one of Teensy's (32 bit?) timer / counters as a phase accumulator to measure the period of the external frequency source, thus starting to count on an input zero crossing, and then stopping it again on the next. This "gating" could be handled by simple external circuitry. What I'd be left with is reading the counter / phase accumulator into a variable, passing that number to the Waveform frequency parameter, then resetting the counter. Yet, I'm not sure if that's possible with the Teensy.

    An alternative might be to have an external hardware CMOS counter / phase accumulator circuit, and then read it in parallel into the Teensy - but this seems wasteful of pins and external hardware - if I can do it in the CPU.

    FWIW, I'm NOT trying to track pitch of complex waveforms - just a simple square wave input.

    Guys - I'm open to ideas here.

    Thanks

  2. #2
    Junior Member
    Join Date
    Dec 2021
    Location
    South Germany
    Posts
    8
    have you checked and tried out the "notefreq" method in the Teensy Audio Library?
    https://www.pjrc.com/teensy/gui/inde...eNoteFrequency

  3. #3
    Member
    Join Date
    Jan 2015
    Location
    Toms River, NJ USA
    Posts
    52
    Quote Originally Posted by Recyclestudio View Post
    have you checked and tried out the "notefreq" method in the Teensy Audio Library?
    https://www.pjrc.com/teensy/gui/inde...eNoteFrequency
    Thanks for your reply.

    I did think of that, but since it makes heavy use of interrupts, it would interfere with all the audio synth stuff - which also uses interrupts - that I need to happen at the same time.

    I ordered some 16 bit counter chips to test my hardware version idea. That way, I can read the HW counter in the LOOP code section. Should be able to wire up something to test in a few days.

  4. #4
    Junior Member
    Join Date
    Dec 2021
    Location
    South Germany
    Posts
    8
    Would the FreqCount library work for you?

    https://www.pjrc.com/teensy/td_libs_FreqCount.html

  5. #5
    Member
    Join Date
    Jan 2015
    Location
    Toms River, NJ USA
    Posts
    52
    Wow, thanks again for your suggestion!

    That was actually the first thing I tried before trying NoteFrequency. Unfortunately, that also uses interrupts which completely messes up the audio stuff.

    The more I've thought about it, I really don't think there's going to be a good CPU based solution. The control signals that are required to start and stop the period counter (accumulator) can't be interrupt driven if you're using the audio engine.

    I'm more than happy to be proven wrong on this point however.

  6. #6
    Junior Member
    Join Date
    Dec 2021
    Location
    South Germany
    Posts
    8
    One crazy idea might be, us an adruino nano to measure the time with interrups and so on, and send the reesult via I2C when ready. An additional IO can send a ready signal, so the teensy can pick it up

  7. #7
    Senior Member
    Join Date
    Apr 2014
    Location
    -
    Posts
    9,756
    The Audio library has no problem with additional interrupts. Any Teensy 3.x or 4 is fast enough, and the 128 Samples buffer is large enough.
    Also, there is no requirement for a 2nd core.
    I think you are significantly underestimating an ARM Cortex.

  8. #8
    Member
    Join Date
    Jan 2015
    Location
    Toms River, NJ USA
    Posts
    52
    Frank & Recyclestudio,

    Thanks for the input. Maybe I gave up on my initial tests too soon. Now with your feedback, I'll spend some more time on this without hardware.

    It's always so great to have helpful folks around giving advice and suggestions! Most appreciated. :-)

  9. #9
    Member
    Join Date
    Jan 2015
    Location
    Toms River, NJ USA
    Posts
    52
    One concern...

    Are the timers in the FreqCount library used in the Audio library? Will they interfere at all?

  10. #10
    Senior Member
    Join Date
    Apr 2014
    Location
    -
    Posts
    9,756
    Maybe you think it's a speed problem, but it isn't... We don't know what you did exactly, so, it's hard to give a advice.
    Note, the Audio interrupt is the lowest priority one. There are already a whole bunch of other, higher priority interrupts (USB, Systick, etc etc) running, without any influence... the audio interrupt runs at a 2.9ms frequency. 2.9 ms is a very long time.

    The audio does not use any timers (as long you don't use the A/D (which is no good on the T4 anyway))

  11. #11
    Member
    Join Date
    Jan 2015
    Location
    Toms River, NJ USA
    Posts
    52
    Good info sir! I'll be giving it a try.

    But what's the concern with the A/D? I'll be needing to read a few pots in this app. Workarounds?

  12. #12
    Senior Member
    Join Date
    Apr 2014
    Location
    -
    Posts
    9,756
    Quote Originally Posted by dslocum View Post
    Good info sir! I'll be giving it a try.

    But what's the concern with the A/D? I'll be needing to read a few pots in this app. Workarounds?
    No concerns as long you don't use them as audio inputs.

  13. #13
    Member
    Join Date
    Jan 2015
    Location
    Toms River, NJ USA
    Posts
    52
    Ah, OK. NP then. This is strictly synth - not external audio processing. (whew!)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •