 
   //Set output volume
   myTympan.volume_dB(outputVolume_dB);                   // headphone amplifier.  -63.6 to +24 dB in 0.5dB steps.
-  aicShield.volume_dB(outputVolume_dB);
+  earpieceShield.volume_dB(outputVolume_dB);
   myTympan.print("Output Volume: "); myTympan.print(outputVolume_dB); myTympan.println("dB");
 }
 

// Functional Test for Tympan Earpieces and Shield
//
// Created: Eric Yuan, Open Audio, Jan 2020
//
// This example code is in the public domain.
//
// Hardware: 
//  Assumes that you're using a Tympan RevD with an Earpiece Shield
//    and two Tympan earpieces (each with a front and back PDM micrphone) 
//    connected through the earpiece audio ports (which uses the USB-B Mini connector).
//
//  Mixing:
//  The front and back mic for each earpiece will be mixed into a single channel.
//  The output will be routed to both the Tympan AIC (i2s_out[0,1]) and the 
//  Shield AIC (i2s_out[2,3]), which can be heard using the earpiece receivers 
//  or a headphone plugged into the 3.5mm audio jacks on either the Tympan or Shield

#include <Tympan_Library.h>
#include "State.h"                          //For enums
#include "SerialManager.h"                  //For processing serial communication

//set the sample rate and block size
const float sample_rate_Hz    = 44100.0f;  //Allowed values: 8000, 11025, 16000, 22050, 24000, 32000, 44100, 44118, or 48000 Hz
const int audio_block_samples = 128;     //do not make bigger than AUDIO_BLOCK_SAMPLES from AudioStream.h (which is 128)
AudioSettings_F32 audio_settings(sample_rate_Hz, audio_block_samples);

//setup the  Tympan using the default settings
Tympan                        myTympan(TympanRev::E, audio_settings); //choose TympanRev::D or TympanRev::E
EarpieceShield                aicShield(TympanRev::E, AICShieldRev::A);  //choose TympanRev::D or TympanRev::E

// Define audio objects
AudioInputI2SQuad_F32         i2s_in(audio_settings);         //Digital audio *from* the Tympan AIC.
AudioMixer4_F32               inputMixerL(audio_settings);    //For mixing (or not) the two mics in the left earpiece
AudioMixer4_F32               inputMixerR(audio_settings);    //For mixing (or not) the two mics in the left earpiece
AudioOutputI2SQuad_F32        i2s_out(audio_settings);        //Digital audio *to* the Tympan AIC.  Always list last to minimize latency
AudioSDWriter_F32             audioSDWriter(audio_settings);  //this is stereo by default

//Connect the front and rear mics (from each earpiece) to input mixers
AudioConnection_F32           patchcord1(i2s_in, 1, inputMixerL, 0);  //Left-Front Mic
AudioConnection_F32           patchcord2(i2s_in, 0, inputMixerL, 1);  //Left-Rear Mic
AudioConnection_F32           patchcord3(i2s_in, 3, inputMixerR, 0);  //Right-Front Mic
AudioConnection_F32           patchcord4(i2s_in, 2, inputMixerR, 1);  //Right-Rear Mic

//Connect the input mixers to both the Tympan and Shield audio outputs
//NOTE: The left and right RIC is correct, but the headphone jacks have the left and right swapped.  
AudioConnection_F32           patchcord11(inputMixerL, 0, i2s_out, 1); //Tympan AIC, left output
AudioConnection_F32           patchcord12(inputMixerR, 0, i2s_out, 0); //Tympan AIC, right output
AudioConnection_F32           patchcord13(inputMixerL, 0, i2s_out, 3); //Shield AIC, left output
AudioConnection_F32           patchcord14(inputMixerR, 0, i2s_out, 2); //Shield AIC, right output

//Connect the input mixer to the SD card
AudioConnection_F32           patchcord21(inputMixerL, 0, audioSDWriter, 0);   //connect Raw audio to queue (to enable SD writing)
AudioConnection_F32           patchcord22(inputMixerL, 1, audioSDWriter, 1);  //connect Raw audio to queue (to enable SD writing)
AudioConnection_F32           patchcord23(inputMixerR, 0, audioSDWriter, 2);   //connect Raw audio to queue (to enable SD writing)
AudioConnection_F32           patchcord24(inputMixerR, 1, audioSDWriter, 3);  //connect Raw audio to queue (to enable SD writing)

//control display and serial interaction
SerialManager                 serialManager;

String overall_name = String("Hear-Thru for Functional test of Tympan + Shield + Earpieces with PDM Mics");

  {
    //Enable Digital Mic (enable analog inputs)
    myTympan.enableDigitalMicInputs(true);
    earpieceShield.enableDigitalMicInputs(true);
  }
  else
  {
    //Disable Digital Mic (enable analog inputs)
    myTympan.enableDigitalMicInputs(false);
    earpieceShield.enableDigitalMicInputs(false);
  }
    
  //Set input gain in dB
