Using the post processor functions for the audio output USB

I am using the Teensy 3.2 and the audio adaptor board. I wanted to know if the Post Processor functions of the SGTL500 affect the USB audio output because I record the data in my computer from the USB and from the headphone output and the filters didn't seem to do something to the usb output. That's why I wanted to know if I need to add something else to my code or what can I do to get the filtlers work via the USB output. Also I wanted to know if there are functions like muteHeadphone() for the USB.

My code of implementation is the following:
Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>

AudioInputI2S            audioInput;           //xy=200,69
AudioOutputI2S           audioOutput;           //xy=365,94
AudioOutputUSB           usb1;
//Connection to headphone output
AudioConnection          patchCord1(audioInput, 0, audioOutput, 0);
AudioConnection          patchCord2(audioInput, 0, audioOutput, 1);
//Connection to usb output
AudioConnection          patchCord3(audioInput, 0, usb1, 0);
AudioConnection          patchCord4(audioInput, 0, usb1, 1);
//Controller definition
AudioControlSGTL5000     sgtl5000_1;     //xy=302,184

const uint32_t Q_UNIT = 524288;
const int F_S = 44100;
const int myInput = AUDIO_INPUT_LINEIN;
float vol = 0.5;
int filterParams[5];

void setup() {
  // Audio connections require memory to work.  For more
  // detailed information, see the MemoryAndCpuUsage example
  AudioMemory(12);
  Serial.begin(115200);
  // Enable the audio shield, select input, and enable output
  sgtl5000_1.enable();
  sgtl5000_1.inputSelect(myInput);
  sgtl5000_1.eqSelect(1);
  sgtl5000_1.audioPostProcessorEnable();
  sgtl5000_1.eqFilterCount(7);
  //sgtl5000_1.autoVolumeControl(2, 1, 0, -5, 0.5, 0.5);
}

void flat() {
  sgtl5000_1.enhanceBassDisable();
}

void setFilter(int f_number, int type, float f_c, float dbGain, float Q) {
  calcBiquad(type, f_c, dbGain, Q, Q_UNIT, F_S, filterParams);
  sgtl5000_1.eqFilter(f_number, filterParams);
}

void loop() {
  sgtl5000_1.volume(vol);
  
  if (Serial.available() > 0) {
    String data = Serial.readStringUntil('\n');

    if (data == "filt1") {
      Serial.println("FILTER 1");
      myInput = AUDIO_INPUT_LINEIN;
      //Select Filter Number: (0 - 6)
      int filter_num = 0;
      int filter1 = filter_num;
      //filter type: (0 -- Low Pass, 1 -- High Pass, 2--Bandpass, 3 -- Notch, 4 -- Parametric, 5--Low Shelf, 6 -- High Shelf);
      int type = 2;
      //filter variables
      float freq = 110;
      float dbGain = 5;
      float Q = 0.351;
      setFilter(filter1, type, freq, dbGain, Q);
    }
    else if (data == "filt2") {
      Serial.println("FILTER 2");
      //Select Filter Number: (0 - 6)
      int filter_num = 0;
      int filter1 = filter_num;
      //filter type: (0 -- Low Pass, 1 -- High Pass, 2--Bandpass, 3 -- Notch, 4 -- Parametric, 5--Low Shelf, 6 -- High Shelf);
      int type = 2;
      //filter variables
      float freq = 300;
      float dbGain = 5;
      float Q = 0.559;
      setFilter(filter1, type, freq, dbGain, Q);
    }
    else if (data == 'P') {
      vol = 0.5;
      
      Serial.println("Select from presets(0 -- Rock, 1 -- Classical)");
      while (!Serial.available()) {}
      char choice = Serial.read();
      int var = (int)choice - 48;
      switch (var) {
        case 0:
          Serial.println("Rock Equalizer");
          setFilter(0, FILTER_HIPASS, 90, 2.0, 1.0);
          setFilter(1, FILTER_PARAEQ, 155, 2.5, 2.0);
          setFilter(2, FILTER_PARAEQ, 600, 5.0, 0.2);
          setFilter(3, FILTER_PARAEQ, 1000, 4.0, 0.5);
          setFilter(4, FILTER_PARAEQ, 4000, 4.6, 0.8);
          setFilter(5, FILTER_NOTCH, 7000, 4.5, 0.4);
          setFilter(6, FILTER_HISHELF, 10000, 4.0, 16.0);
          sgtl5000_1.eqFilterCount(7);
          break;
        case 1:
          Serial.println("Classical Equalizer");
          setFilter(0, FILTER_HIPASS, 80, 4.0, 1.0);
          setFilter(1, FILTER_PARAEQ, 120, 2.0, 1.0);
          setFilter(2, FILTER_NOTCH, 3600, 2.5, 0.2);
          setFilter(3, FILTER_PARAEQ, 3000, 7.4, 0.2);
          setFilter(4, FILTER_PARAEQ, 80, 0, 1.0);
          setFilter(5, FILTER_PARAEQ, 500, 0, 1.0);
          setFilter(6, FILTER_PARAEQ, 9000, 2.2, 9.0);
          sgtl5000_1.eqFilterCount(7);

          break;
        default:
          Serial.println("Invalid Selection");
          break;
      }
    }
    else {
      Serial.println("Comando inválido");
    }
  }
}

Thank you for your help :)
 
The filters in the SGTL5000 are only going to affect the audio coming from the chip. I suggest adding a filter in your audio chain and using that instead. One filter gives you up to four passband functions.
 
Back
Top