Using delay with microphone input does not work

Status
Not open for further replies.
I am connecting the left channel from my microphone to the left input of my headphone.
I am also connecting the left channel from my microphone to the right channel of my headphone via a delay.
When I run the code I don't hear anything in the left and right channels of my headphones when I speak into the microphone.
Why don't I hear anything when I speak into the microphone?

The code is as follows:

#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>

AudioInputI2S mic;
AudioEffectDelay delay1;
AudioOutputI2S headphone;
AudioConnection patchCord1(mic, 0, headphone, 0); // Left ear
AudioConnection patchCord2(mic, 0, delay1, 0);
AudioConnection patchCord3(delay1, 0, headphone, 1); // Right ear
AudioControlSGTL5000 sgtl5000_1;

void setup() {
Serial.begin(9600);
AudioMemory(160);
sgtl5000_1.enable();
sgtl5000_1.volume(0.5);
sgtl5000_1.inputSelect(AUDIO_INPUT_MIC);
sgtl5000_1.micGain(50);
delay1.delay(0, 100);
delay(1000);
}

void loop() {
// do nothing
}


If I replace the delay with a mixer everything works as expected (see code below). So I know my hardware is setup/connected properly.

#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>

AudioInputI2S mic;
AudioMixer4 mixer1;
AudioOutputI2S headphone;
AudioConnection patchCord1(mic, 0, headphone, 0); // Left ear
AudioConnection patchCord2(mic, 0, mixer1, 0);
AudioConnection patchCord3(mixer1, 0, headphone, 1); // Right ear
AudioControlSGTL5000 sgtl5000_1;

void setup() {
Serial.begin(9600);
AudioMemory(160);
sgtl5000_1.enable();
sgtl5000_1.volume(0.5);
sgtl5000_1.inputSelect(AUDIO_INPUT_MIC);
sgtl5000_1.micGain(50);
mixer1.gain(0, 0.9);
delay(1000);
}

void loop() {
// do nothing
}
 
I am connecting the left channel from my microphone to the left input of my headphone.
I am also connecting the left channel from my microphone to the right channel of my headphone via a delay.
When I run the code I don't hear anything in the left and right channels of my headphones when I speak into the microphone.
Why don't I hear anything when I speak into the microphone?

The code is as follows:

#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>

AudioInputI2S mic;
AudioEffectDelay delay1;
AudioOutputI2S headphone;
AudioConnection patchCord1(mic, 0, headphone, 0); // Left ear
AudioConnection patchCord2(mic, 0, delay1, 0);
AudioConnection patchCord3(delay1, 0, headphone, 1); // Right ear
AudioControlSGTL5000 sgtl5000_1;

void setup() {
Serial.begin(9600);
AudioMemory(160);
sgtl5000_1.enable();
sgtl5000_1.volume(0.5);
sgtl5000_1.inputSelect(AUDIO_INPUT_MIC);
sgtl5000_1.micGain(50);
delay1.delay(0, 100);
delay(1000);
}

void loop() {
// do nothing
}

try to insert after
setting delay to 100 ms
Code:
 for(int ii=1; ii<8; ii++) delay1.disable(ii);

also
for testing, try to put the delay to 0ms. it should pass through
 
WMXZ - thanks for replying so quickly.

Unfortunately none of your suggestions worked.

Some things that I have noticed that my shed some light onto my problem is as follows:

1) I am using a Teensy 3.6. When I use the code that has delay1 replaced by mixer1 the LED on the Teensy board stays on while the program is running. However, when I use the code that has delay1 the LED does not come on at all.

2) Code with the delay function works if the input to the delay function is not from my microphone (e.g. the input is from an AudioEffectEnvelope).

3) When I try the example in the audio board Tutorial entitled Part_2_05_Simple_Delay (see code below), the Teensy LED stays on while the program is running, but no sound makes it to the headphone.

// Advanced Microcontroller-based Audio Workshop
//
// http://www.pjrc.com/store/audio_tutorial_kit.html
// https://hackaday.io/project/8292-microcontroller-audio-workshop-had-supercon-2015
//
// Part 2-5: Simple Delay


///////////////////////////////////
// copy the Design Tool code here
///////////////////////////////////
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>

// GUItool: begin automatically generated code
AudioInputI2S i2s2;
AudioEffectDelay delay1;
AudioMixer4 mixer1;
AudioMixer4 mixer2;
AudioMixer4 mixer3;
AudioOutputI2S i2s1;
AudioConnection patchCord1(i2s2, 1, delay1, 0);
AudioConnection patchCord2(i2s2, 1, mixer3, 0);
AudioConnection patchCord3(delay1, 0, mixer1, 0);
AudioConnection patchCord4(delay1, 1, mixer1, 1);
AudioConnection patchCord5(delay1, 2, mixer1, 2);
AudioConnection patchCord6(delay1, 3, mixer1, 3);
AudioConnection patchCord7(delay1, 4, mixer2, 0);
AudioConnection patchCord8(delay1, 5, mixer2, 1);
AudioConnection patchCord9(delay1, 6, mixer2, 2);
AudioConnection patchCord10(delay1, 7, mixer2, 3);
AudioConnection patchCord11(mixer1, 0, mixer3, 1);
AudioConnection patchCord12(mixer2, 0, mixer3, 2);
AudioConnection patchCord13(mixer3, 0, i2s1, 0);
AudioConnection patchCord14(mixer3, 0, i2s1, 1);
AudioControlSGTL5000 sgtl5000_1;
// GUItool: end automatically generated code

void setup() {
Serial.begin(9600);
AudioMemory(160);
sgtl5000_1.enable();
sgtl5000_1.volume(0.6);
sgtl5000_1.inputSelect(AUDIO_INPUT_MIC);
sgtl5000_1.micGain(60);
mixer1.gain(0, 0.2);
mixer1.gain(1, 0.2);
mixer1.gain(2, 0.2);
mixer1.gain(3, 0.2);
mixer2.gain(0, 0.2);
mixer2.gain(1, 0.2);
mixer2.gain(2, 0.2);
mixer2.gain(3, 0.2);
mixer3.gain(0, 0.0); // default = do not listen to direct signal
mixer3.gain(1, 1.0); // ch1 is output of mixer1
mixer3.gain(2, 1.0); // ch2 is output of mixer2
delay1.delay(0, 400);
delay1.delay(1, 400);
delay1.delay(2, 400);
delay1.delay(3, 400);
delay1.delay(4, 400);
delay1.delay(5, 400);
delay1.delay(6, 400);
delay1.delay(7, 400);
delay(1000);
}

void loop() {
// do nothing
}
 
the version of Part_2_05_Simple_Delay in your post differs slightly from the original example. what happens if you set
sgtl5000_1.micGain(36);
are you using the mic provided by PJRC for the audio adapator?
 
the version of Part_2_05_Simple_Delay in your post differs slightly from the original example. what happens if you set
sgtl5000_1.micGain(36);
are you using the mic provided by PJRC for the audio adapator?

Manitou,

Setting the micGain to 36 did not fix the problem. Also, the mic that I am using is not the one provided by PJRC. The mic I am using is an Inland
Pro Series Microphone that I got at Frys many years ago. It is advertised to be compatible with any PC sound card. I assume that it is an Electret Mic since it works
with the sound card when I run the following code:

#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>

AudioInputI2S i2s1;
AudioOutputI2S i2s2;
AudioConnection patchCord1(i2s1, 0, i2s2, 0); // Left ear
AudioConnection patchCord2(i2s1, 0, i2s2, 1); // Right ear
AudioControlSGTL5000 sgtl5000_1;

void setup() {
Serial.begin(9600);
AudioMemory(8);
sgtl5000_1.enable();
sgtl5000_1.volume(0.5);
sgtl5000_1.inputSelect(AUDIO_INPUT_MIC);
sgtl5000_1.micGain(50);
delay(1000);
}

void loop() {
// do nothing
}
 
I solved the problem by eliminating the "Serial.begin(9600)" statement in the setup subroutine (see code below).

Now everything works as expected with the delay.

Thanks for helping.

#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>

AudioInputI2S mic;
AudioEffectDelay delay1;
AudioOutputI2S headphone;
AudioConnection patchCord1(mic, 0, headphone, 0); // Left ear
AudioConnection patchCord2(mic, 0, delay1, 0);
AudioConnection patchCord3(delay1, 0, headphone, 1); // Right ear
AudioControlSGTL5000 sgtl5000_1;

void setup() {
Serial.begin(9600); //THIS STATEMENT NEEDS TO BE ELIMINATED FOR THE SYSTEM TO WORK
AudioMemory(160);
sgtl5000_1.enable();
sgtl5000_1.volume(0.5);
sgtl5000_1.inputSelect(AUDIO_INPUT_MIC);
sgtl5000_1.micGain(50);
delay1.delay(0, 100);
delay(1000);
}

void loop() {
// do nothing
}
 
I solved the problem by eliminating the "Serial.begin(9600)" statement in the setup subroutine (see code below).

Now everything works as expected with the delay.

Thanks for helping.

Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>

AudioInputI2S mic;
AudioEffectDelay delay1;
AudioOutputI2S headphone;
AudioConnection patchCord1(mic, 0, headphone, 0); // Left ear
AudioConnection patchCord2(mic, 0, delay1, 0);
AudioConnection patchCord3(delay1, 0, headphone, 1); // Right ear
AudioControlSGTL5000 sgtl5000_1;

void setup() {
Serial.begin(9600);   //THIS STATEMENT NEEDS TO BE ELIMINATED FOR THE SYSTEM TO WORK
AudioMemory(160);
sgtl5000_1.enable();
sgtl5000_1.volume(0.5);
sgtl5000_1.inputSelect(AUDIO_INPUT_MIC);
sgtl5000_1.micGain(50);
delay1.delay(0, 100);
delay(1000);
}

void loop() {
// do nothing
}

This may mean you have compiled without Serial set in menu, right?
 
OK, I updated the Arduino IDE from 1.8.3 to 1.8.5, and updated Teensyduino to version 1.40.

This fixed the problem with the Serial.begin statement. So now I can use Serial.begin with the delay effect.

Upgrading to version 1.40 also fixed the noise/artifact problem that I was having in the headphone channel that was receiving input from the delay effect. Prior to the upgrade I would hear a distinct intermittent buzz with a regular period that was superimposed on a continuous white noise. Now the Teensy 3.6/Audio Board is performing/behaving as expected.

Thanks for your help!

Rich
 
Status
Not open for further replies.
Back
Top