Hey All,
I am been searching the forums and did not see this issue discussed relating to my project. Maybe I missed it, but your help would be appreciated.
My project is to remove ambient noise from a mic input, so that the output is *nearly* voice only. I have two mics, one that is for my voice and one is for background noise. I am using a custom preamp board to bring the sound into Line-in Left and Right on the Audio Shield from the mics. I have a Teensy 4.0 performing the math to subtract the ambient noise mic (Line-in Left) from the voice mic (Line-in Right) and my output is through the headphone jack on the Audio Shield. See block diagram below for set up. Also picture below for actual board setup. Code is also below.
My issue:
I cannot seem to get Line-in Left (background noise) to subtract from Line-in Right (voice + background noise) to produce my voice only output.
What I have verified:
#2 tells me that what I am trying to do is possible. So that is encouraging.
What I am having trouble with:
I would appreciate any direction or help in this manner to solve issue #3. I will do the homework to figure this out, just need to know where to look.
Thanks.
Block diagram
Actual board setup
I am been searching the forums and did not see this issue discussed relating to my project. Maybe I missed it, but your help would be appreciated.
My project is to remove ambient noise from a mic input, so that the output is *nearly* voice only. I have two mics, one that is for my voice and one is for background noise. I am using a custom preamp board to bring the sound into Line-in Left and Right on the Audio Shield from the mics. I have a Teensy 4.0 performing the math to subtract the ambient noise mic (Line-in Left) from the voice mic (Line-in Right) and my output is through the headphone jack on the Audio Shield. See block diagram below for set up. Also picture below for actual board setup. Code is also below.
My issue:
I cannot seem to get Line-in Left (background noise) to subtract from Line-in Right (voice + background noise) to produce my voice only output.
What I have verified:
- I verified receiving sound through both mics independently to my headphones using Audio Shield and Teensy.
- I verified reducing output to zero volume (verified by rms1) via subtraction if: (1) I use just one channel (e.g. ch0 of i2s1) as the source to both inputs to Mixer 1 (0 and 1).
#2 tells me that what I am trying to do is possible. So that is encouraging.
What I am having trouble with:
- See above - Pass
- See above - Pass
- Using the same sound through both mics to reduce output to zero volume via subtraction - Fail
- Using one mic for voice + background sound and the other for background sound to output voice only via subtraction
- Testing outside in real world
I would appreciate any direction or help in this manner to solve issue #3. I will do the homework to figure this out, just need to know where to look.
Thanks.
Block diagram
Actual board setup
Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
// GUItool: begin automatically generated code
AudioInputI2S i2s1;
AudioAmplifier amp1;
AudioMixer4 mixer1;
AudioOutputI2S i2s2;
AudioAnalyzeRMS rms1;
AudioAnalyzePeak peak1;
AudioConnection patchCord1(i2s1, 0, amp1, 0);
//AudioConnection patchCord2(i2s1, 0, mixer1, 1); //same Channel, test cancelation
AudioConnection patchCord2(i2s1, 1, mixer1, 1); //Two channels
AudioConnection patchCord3(amp1, 0, mixer1, 0);
AudioConnection patchCord4(mixer1, 0, i2s2, 0);
AudioConnection patchCord5(mixer1, 0, i2s2, 1);
AudioConnection patchCord6(mixer1, rms1);
AudioConnection patchCord7(mixer1, peak1);
AudioControlSGTL5000 sgtl5000_1;
// GUItool: end automatically generated code
void setup() {
// Audio connections require memory to work. For more
// detailed information, see the MemoryAndCpuUsage example
AudioMemory(15);
Serial.begin(9600);
// Enable the audio shield, select input, and enable output
sgtl5000_1.enable();
sgtl5000_1.inputSelect(AUDIO_INPUT_LINEIN);
sgtl5000_1.volume(0.5);
//Amplify channel 0
amp1.gain(-0.5);
//Mixer setting
mixer1.gain(0, 0.5);
mixer1.gain(1, 0.5);
}
elapsedMillis volmsec=0;
String amp_text;
float amp_value;
float rms_amp;
float peak_amp;
void loop() {
// Adjust amp of background noise coming in
// Keyboard input for amp value
// Run every 50 msecs
if (volmsec > 50)
{
if (Serial.available())
{
amp_text = Serial.readStringUntil('\n');
Serial.print(amp_text + " ");
amp_value = amp_text.toFloat();
Serial.println(-amp_value);
amp1.gain(-amp_value);
}
// Result - verify cancelation of sound
rms_amp = rms1.read() * 30.0;
Serial.print(rms_amp);
Serial.print(" ");
peak_amp = peak1.read() * 30.0;
Serial.println(peak_amp);
volmsec = 0;
}
}
Last edited: