I received a question: can the Tympan record one audio stream from the on-board mics while recording a second audio stream from an external mic (via the pink jack)? The answer is yes!
If you’re impatient, jump to the next post in this forum thread. It gives the answer. The rest of this post here is a bunch of discussion as I figured out the answer.
THE INPUTS ARE CONFIGURABLE
The Tympan can digitize two analog audio streams (typically thought of as “left” and “right”). There are many different signals connected to the digitizer’s inputs, but it can only digitize two of them at any given time. Some choices include the signals from the on-board microphones, the signals from the pink mic jack, or the audio from the Bluetooth module. We have the freedom to tell the Tympan which signals to use as inputs to its digitizers.
Normally, as in the Tympan_Library’s example 01-Basic/BasicGain, you can see that we use
myTympan.inputSelect() to choose the source of the audio input:
myTympan.inputSelect(TYMPAN_INPUT_ON_BOARD_MIC); // use the on board microphones //myTympan.inputSelect(TYMPAN_INPUT_JACK_AS_MIC); // use the microphone jack - defaults to mic bias 2.5V //myTympan.inputSelect(TYMPAN_INPUT_JACK_AS_LINEIN); // use the microphone jack - defaults to mic bias OFF
These three cases were predefined by me as I felt that they were the most common cases that people would want to invoke. But, these aren’t the only choices.
OTHER BUILT-IN CHOICES
To look for more pre-defined input options, I have to dig into the Tympan_Library code. I see that the
Tympan class inherits from
AudioControlAIC3206. This class is defined in control_aic3206.h. I see that I have five predefined options for setting what input you want:
#define TYMPAN_INPUT_LINE_IN (AudioControlAIC3206::IN1) //uses IN1, on female Arduino-style headers (shared with BT Audio) #define TYMPAN_INPUT_BT_AUDIO (AudioControlAIC3206::IN1) //uses IN1, for Bluetooth Audio (ahred with LINE_IN) #define TYMPAN_INPUT_ON_BOARD_MIC (AudioControlAIC3206::IN2) //uses IN2, for analog signals from microphones on PCB #define TYMPAN_INPUT_JACK_AS_LINEIN (AudioControlAIC3206::IN3) //uses IN3, for analog signals from mic jack, no mic bias #define TYMPAN_INPUT_JACK_AS_MIC (AudioControlAIC3206::IN3_wBIAS) //uses IN3, for analog signals from mic jack, with mic bias
Sadly, none of these represent the mix of inputs that I was asked about. We want one input to be from ON_BOARD_MIC (which is apparently
AudioControlAIC3206::IN2) and we want the other input to be from JACK_AS_MIC (which is apparently AudioControlAIC3206::IN3_wBIAS). Since there is no predefined method for doing this, we’ll have to go one level deeper.
MAKING OUR OWN CONFIGURATION
Looking in control_aic3206.cpp, I scroll down to
inputSelect(int n) so that I can see what deep-down methods I would invoke to mix-and-match the inputs that I want. Specifically, I looked at the case for the JACK_AS_MIC (
IN3_wBIAS) and altered the line for the right input so that it looked like the right input for ON_BOARD_MIC (
IN2). Finally, I had to prepend
myTympan to each method call because we’ll be making the calls from outside the class.
ATTEMPT AT SOLUTION
Here’s the code to paste into the setup() routine of your program…insert it in place of your existing call to
inputSelect() (Edit: it turns out that it doesn’t work when used in setup(). It’s good code; it just doesn’t work there.):
//Configure the audio inputs to have the left be a mic connected via the pink jack and the right be one of the on-board mics myTympan.aic_goToPage(TYMPAN_MICPGA_PAGE); myTympan.aic_writeRegister(TYMPAN_MICPGA_LEFT_POSITIVE_REG, TYMPAN_MIC_ROUTING_POSITIVE_IN3 & TYMPAN_MIC_ROUTING_RESISTANCE_DEFAULT); //Use the left-input of the pink jack myTympan.aic_writeRegister(TYMPAN_MICPGA_LEFT_NEGATIVE_REG, TYMPAN_MIC_ROUTING_NEGATIVE_CM_TO_CM1L & TYMPAN_MIC_ROUTING_RESISTANCE_DEFAULT); myTympan.aic_writeRegister(TYMPAN_MICPGA_RIGHT_POSITIVE_REG, TYMPAN_MIC_ROUTING_POSITIVE_IN2 & TYMPAN_MIC_ROUTING_RESISTANCE_DEFAULT); //Use the right on-board mic myTympan.aic_writeRegister(TYMPAN_MICPGA_RIGHT_NEGATIVE_REG, TYMPAN_MIC_ROUTING_NEGATIVE_CM_TO_CM1L & TYMPAN_MIC_ROUTING_RESISTANCE_DEFAULT); myTympan.setMicBias(TYMPAN_DEFAULT_MIC_BIAS); //enable the mic BIAS on the pink jack
Hopefully this works!
(EDIT: It turns out that, while the code above works, it does NOT work when called from your main *.ino program as I had suggested. It only works when called from within the Tympan class. That’s because these new lines code invoke certain items like
TYMPAN_MICPGA_PAGE which are only accessible from within the class. So, see the follow up post for the solution that does work. The information below is still helpful documentation and it is how I ended up changing the internal code.)