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

Thread: Tuner on 4.0 multiple inputs?

  1. #1
    Junior Member
    Join Date
    Oct 2019
    Posts
    4

    Tuner on 4.0 multiple inputs?

    Hi all, I just got my Teensy 4.0 board and had a project idea. I have a guitar with pickups for each individual string that I'd like to use to read the pitches played and convert each string to the corresponding midi note as the output. I know there is a tuner sketch which is meant for a single input, but could I do an analogRead that takes advantage of the 4.0s speed and, if not simultaneously, quickly switch which string I'm reading to get all 6 of them?

    Would it be possible to use 6 analog inputs on the Teensy 4.0 and output the midi notes?

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,680
    This depends on the meaning of "possible". Currently there isn't any software support for ADC sampling of more than 1 input on any board, and so far there's no ADC support at all for Teensy 4.0 in the audio library. So if "possible" means using the libraries available today, not so much.

    If "possible" means you'll dive into the very low level coding, this might be possible. Teensy 4.0 has a special ADC trigger control peripheral which might help. It's documented in chapter 66 of the reference manual, starting on page 3499.

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

    However, this sort of programming requires setting up DMA transfers. The details are quite complicated and troubleshooting is very difficult if it doesn't work. Not impossible, but also most definitely not a beginner level project!

    The easier and higher quality but more expensive path to 6 inputs would be the CS42448 chip with the TDM input. TDM does work on Teensy 4.0. I personally tested it with that CS42448 board, using jumper wires to connect Teensy 4.0's different pins to that board which was designed for Teensy 3.2.

  3. #3
    Junior Member
    Join Date
    Oct 2019
    Posts
    4
    Thanks, that's the two options I was considering, just wanted to see if there might be a different option I hadn't considered. I will experiment with using external ADCs for each audio channel on their own i2c address, then sending them to their own instance of the tuner module.

  4. #4
    If you can handle a little SMD soldering, I made a pretty compact breakout for the CS42448 codec with a use case like this in mind. The breakout is for the T3.2 (but would need only a few small changes for the T4), and does not include any analog input or output stages, just the pins of the codec broken out. It might be small enough to mount in the electronics cavity of a typical electric guitar. Depending on what types of pickups you have, you'd need to design an analog input stage (for which I'd suggest modifying the breakout), but from that point you would have 6 channels of reasonable quality audio, and the Teensy Audio library at your disposal.

    If you are new to this topic, you can find some (very good) information about multi-pickup guitars, micro-controllers, DSP and the like, have a look at the company Cycfi. In particular the owner Joel de Guzman who's an incredibly prolific developer/engineer, and works very much out in the open. His blog is a wealth of knowledge.

  5. #5

  6. #6
    Junior Member
    Join Date
    Oct 2019
    Posts
    4
    Maybe I can use his DSP library on the teensy and use my ADC breakout to get my 6 channels going.

  7. #7
    Quote Originally Posted by chrisleewoo View Post
    I will experiment with using external ADCs for each audio channel on their own i2c address, then sending them to their own instance of the tuner module.
    I'm not sure what your plans are, but I2C != I2S... Unless your external ADCs have, or are themselves microcontrollers with which you plan to do the pitch detection, the I2C protocol will have difficulty (timely) transporting the amount samples you would need to perform pitch detection on the Teensy for even one channel, let alone six.

    In order to detect sinusoidal components (ie. the fundamental frequency) of any periodic signal, you will need enough ADC sample data to accurately describe that signal. The Nyquist-Shannon sampling theorem dictates that you will need a sample rate 2x the highest frequency you want to accurately describe, (for example 44,100 samples per second can accurately describe a signal up to 22,5 kHz) having fewer samples will cause aliasing. There are a number of different DSP techniques to try and detect the fundamental frequency of a signal, but all of them require that signal first be accurately described in order to work.

    If you indeed meant I2S, as far as I am aware, the Teensy is limited to two stereo channels in / out unless you use TDM signalling, (hence the suggestion for the CS42448 codec).

Posting Permissions

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