Change mux input based on last active input

My question is similar to this - https://ez.analog.com/dsp/sigmadsp/f/q-a/65902/auto-select-the-mux-input-with-signal-help

I have three inputs, A, B, and C. If any of the three inputs becomes active from being silent, a mux should switch to it.

In practice, this is what I am looking for: All inputs are silent. Audio input begins through A, the signal is detected, and a mux switches the input of the DSP to A. Input then appears on C, and the mux is switched to C. Input to A is paused for a few seconds, then played again, and the mux switches back to it. While both A and C are playing, audio appears on B, and the mux switches to input B.

To boil it down further because I have no idea if anything I am asking is making sense - I want a mux to switch to the input which has become active most recently. It does not matter if other inputs are active and have audio being input to them, if any input goes from nothing to something continuously for more than a few seconds, the mux should switch to that input. The end goal is a home theatre audio switch which automatically jumps to the most-recently-active audio source whenever anything starts playing on said source.

I've attached a screenshot of what I have so far but honestly I am completely stumped as to how to implement the switching/edge/latching logic.

I am extremely new to SigmaDSP programming and my board is still in the mail, please be gentle Slight smile  Thank you!!!! Slight smile

Parents
  • 0
    •  Super User 
    on Jul 24, 2021 11:43 PM

         Hello Audrey,

         It looks like you've already got some of the programming figured out, and it is possible to build the desired selection logic.  However, I'm a bit concerned about the available audio inputs..  Here's why:  The 10-pin Input block shown suggests that the board you're waiting on is based upon the ADAU1701 DSP.  With its two built-in A/D converters, this chip accepts one stereo analog input which then appears at pins 0 and 1 on the Input block.   The other Input block pins have no converters, thus cannot receive analog inputs on their own.  If your board includes A/D converter ("codec") chips for the other inputs, you can have additional analog inputs.  Otherwise your board can only accept one stereo analog input.

         The other Input block pins can accept I2S digital streaming inputs, yet this gets complicated if those are provided by external equipment.  The ADAU1701 is not the best chip for this since it lacks ASRCs ("asynchronous sample rate converters") to synchronize the digital audio samples from these inputs.

         If you provide a link to your board's Web page I'd be happy to determine if it's suitable for a three stereo input application.

         Best regards,

         Bob

  • Hi Bob,

    Thank you for your reply! The input block usage there was completely arbitrary, and was for illustration purposes only. I should have made that clearer. I am using a JAB5 and APM2 from Wondom. I intend to use the one analog input and a number of i2s inputs and switch between them based on activity. The JAB5 is the best board I can find in this small-ish form factor and with integrated amplifiers - if you know of one with a higher end chip with ASRCs please let me know as I have been looking for one, and am trying to figure out how to handle high sample rate inputs.

    I have made some progress! Here is my latching system, based on three pulsed inputs. This works perfectly as tested with switches. When "A Pulse", "B Pulse" or "C Pulse" is pulsed for a short amount of time, the LUT outputs 0,1,2 respectively, which is then fed to a mux for switching.



    What I am now stuck on is the actual creation of the pulses. Based on an earlier response from you to another question here https://ez.analog.com/dsp/sigmadsp/f/q-a/66376/generate-a-single-pulse-with-adau1761-and-sigma-studio/252568 i have designed this! Unfortunately it does not work, and I am not sure why.



    I would love input as to how to fix my pulse generator, but if you think there is a significantly better way to handle this switching, please let me know :)

    Here is my test program for any ADAU1701 board, it uses no inputs or outputs, just internal audio for testing. Thanks Slight smile

    mux plz work.zip


  • 0
    •  Super User 
    on Jul 25, 2021 11:38 AM in reply to IAmAudrey

         Hi Audrey,

         Your input select logic is quite efficient!  And only two errors needed fixing to make it work.  Both are shown below:

    Inputs 2 and 3 were flopped so that each opened the other's input, allowing only Input 1 to work.  And the Zero Comparators needed to be set for 5.23 number format to match the timer outputs -- to allow the subtraction to work.

         Best regards,

         Bob

Reply
  • 0
    •  Super User 
    on Jul 25, 2021 11:38 AM in reply to IAmAudrey

         Hi Audrey,

         Your input select logic is quite efficient!  And only two errors needed fixing to make it work.  Both are shown below:

    Inputs 2 and 3 were flopped so that each opened the other's input, allowing only Input 1 to work.  And the Zero Comparators needed to be set for 5.23 number format to match the timer outputs -- to allow the subtraction to work.

         Best regards,

         Bob

Children
  • Ahhh, number formats! I'm still having a hard time wrapping my brain around what exactly uses what format, and why, and what the different formats actually are.

    Do you know if there is a more efficient/elegant/clean way to do what I have done with the lookup table and oneshot rise resets? It seems to work fine, but also seems a little bit hacky to me. I'm only using bits 1,2,3 (values 1,2,4), but need to have entries for value 3 as well as I can't remove entries in the LUT. Is using the oneshot rise resets to output their "1" in different bit positions ok / a good way to do it?

  • 0
    •  Super User 
    on Jul 25, 2021 2:45 PM in reply to IAmAudrey

         Hi Audrey,

         If it works, it's a good way.  The "one-shot rise" blocks are really latches -- they latch the input pulse ON until reset.   Since your desired function is to keep a given channel ON until another channel goes live, their use makes sense here.  You could replace the lookup table and MUX with individual Slew Volume Controls for each channel (and then setting all the One Shots to 5.23 format).  I tried this and it works, but unfortunately I cannot presently attach the project or even provide a readable screenshot.  This is a known forum bug which the EZ folks swatted back in March but I just ran into it again today -- please see this post for a description:

    https://ez.analog.com/how-to-use-engineerzone/f/q-a/547703/limited-menu-showing-up-again

         Best regards,

         Bob

  • Hey Bob,

    Your slew volume control idea solves another issue, clean switching between channels. "Index selectable slewing mux" seems to only exist in a mono format, so this might be the way to do it. Thanks Slight smile The only issue with this (which may not be an issue at all) is about audio quality - do i lose anything by using a set of slew volume controls into a signal adder instead of a straight mux? We hear "digital volume control is bad" all the time, but at full volume after the slew is complete, is the data identical through both options?

    Everything else seems to be working now! I am very grateful for your input, thank you so much!

    Audrey

  • 0
    •  Super User 
    on Jul 25, 2021 6:41 PM in reply to IAmAudrey

         Hi Audrey,

            No worries, in this application the Volume Controls are running between fully off (zero input) and unity gain (1.0 in 5.23 format input).  Thus they're acting like a Slew Mux, and will not affect the audio quality.  Glad to be of help.  You'll find all kinds of neat things you can do with SigmaDSP.

         Best regards,

         Bob