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

Thread: Audio adaptor and MUX

  1. #1
    Junior Member
    Join Date
    Mar 2016
    Location
    France
    Posts
    4

    Audio adaptor and MUX

    Hello! First of all, thank you for these awesome products.

    I would need a few advice and guidance.

    I need to multiplex 34 different signals to the input of the audio adaptor (I plan to use two of them in quad input). I need to switch the multiplexer on every new sample coming into the buffer. I tried to modify the size of the audioblock to 1 or 2 but it just seems to divide the sampling frequency. I suspect the DMAChannel library
    to be the one to adapt but it's just too technical for me(I'm learning coding mostly by myself...). I don't know either if an interrupt on every new sample or a 1 value buffer
    would be more efficient (I don't need the code to be compatible with the other audio objects for this project). Also, if the 128 samples buffer is kept, i would need to know exactly to which signal each sample corresponds.

    Could someone tell me about the feasibility of this, and if it is, how to proceed.

    Thank you in advance.

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    22,757
    Quote Originally Posted by sanchoThomas View Post
    Could someone tell me about the feasibility of this, and if it is, how to proceed.
    Even if you solve all other problems, please understand these audio ADCs use signal delta modulation and digital decimation filters. They are not traditional sampling converters, where each measurement is a single sample independent of all others. But let's ignore the oversampling nature of the ADC for now....

    You will probably need to build the MUX with a digital state machine circuit that clocks from the LRCLK signal. If you use the rising edge to clock the state machine, then it will change every 2 samples. Maybe 2 consecutive samples is enough to get a good measurement from the sigma-delta ADC? Or maybe you'll need to trigger every other rising edge?

    Anyway, if you build a digital circuit like a BCD counter, it could control the input to an analog mux (use 2 chips for more than 8, with the higher bit controlling the enable pins). Each time LRCLK has a rising edge, the counter increments, and the analog switches route a different signal.

    Then your software problem becomes an issue of discovering which samples were on which mux channels. Probably the simplest approach would be to connect the highest output bit from the counter to an interrupt pin on Teensy. But timing will be tricky, mostly because the sigma-delta modulator and decimation filter will add delay. But maybe with some fiddling, perhaps you'll manage to sort out which samples are which signals.

    As far as I know, nobody has tried this. At least noone has shared their experience & circuitry & code. If you do try, I hope you'll share what you learn. And hopefully this message helps you at least get started?

  3. #3
    Junior Member
    Join Date
    Mar 2016
    Location
    France
    Posts
    4
    Thank you for your very complete answer, it does sound tricky ... plus I forgot to mention the most peculiar part : the signals need to be sampled at different sample rates. So, as the adc of the adaptor is hardly accessible in my range of action and not especially suited for what I want to do, I was thinking of maby using a dedicated teensy 3.1/2 to the signal conversion and switching(in continuous conversion mode with an intervalTimer to trigger the conversion and switching), sending buffers to another one dedicated to signal processing (maybe with spi?). The analog mux could be dual-channel to allow concurrent conversion with the ADCs. Would that sound more reasonable?
    (By the way it's for a real time audio to midi converter for harp )

  4. #4
    Senior Member
    Join Date
    Jul 2014
    Posts
    2,766
    Quote Originally Posted by sanchoThomas View Post
    (By the way it's for a real time audio to midi converter for harp )
    If you care about audio quality (no noise introduced due to discontinuous sampling, i.e. phase jumps) stick with 4 channels per teensy + 2 audio boards. Analog multiplexing with proper sample and hold is a complete different undertaken and requires an ADC that can cope with the aggregated sampling rate. If you take the audiocard with 44.1 kHz and wanted to convert 8 channels per line input, your effective sampling rate goes down to at most 5.5 kHz with an audio bandwidth of 2.5 kHz. If that is good enough for a harp, you must decide.

  5. #5
    Junior Member
    Join Date
    Mar 2016
    Location
    France
    Posts
    4
    Actually the audio quality is not important for me, all I need is about 10 samples per period for each signals with a fairly constant sampling rate, even with a 50% distorsion.

  6. #6
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    22,757
    Are these audio signals? Are they known to be strictly limited to a lower bandwidth, without any possibility of higher audio frequencies?

    If you tell us more about what you're really trying to actually do with so many signals, maybe other ideas are possible?
    Last edited by PaulStoffregen; 03-12-2016 at 12:35 PM.

  7. #7
    Junior Member
    Join Date
    Mar 2016
    Location
    France
    Posts
    4
    Yes they are but the system doesn't output audio, each string of the harp has its own optical pickup in order to process each strings individualy, the nominal frequency of the strings vary from 65Hz to 1.8KHz. The frequency of each string can be raised to half of a tone above their nominal frequency with a lever.

    So everyone of the signals has a known narrow bandwidth emphasized by the low-res optical pickup. And as I want to make an audio to midi converter, I'm only interested in measuring the fondamental frequency of the signals so, in addition I'm adding a bandpass covering only the two notes the string can produce.

    And finally, the converter needs a bend function and from the measurements I did, 10 samples per period are sufficient for the pitch tracking algorithm (AMDF) to obtain a fairly stable and precise pitch measure(the sample rate is adapted to each strings to optimize the processing and minimize the latency).

    Everyone of these aspects have been tested and validated exept the most baffling one : how to get those 34 signals sampled "in real time" and in a way that I can process them individualy. I'll probably try the "teensy-dedicated" technic next week. If you find better alternatives, please let me know and thank you for the aswers.

    And sorry but I didn't understand the "Analog multiplexing with proper sample and hold" of WMXZ's answer.
    Last edited by sanchoThomas; 03-12-2016 at 01:49 PM.

Posting Permissions

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