Go Down

Topic: Issues differentiating left and right sound signals from audio jack (Read 405 times) previous topic - next topic

Thomasta3

Hi,

I'm trying to create a proof of concept vibration headset "for the deaf" (mainly for videogames where spatial awareness from sound cues is important) for a University electronics project. I've attached a circuit diagram, (which will later have an output to vibration motors to vibrate when left or right sound is detected). I also would like to preface this with the fact that I'm not an electronics student, and I'm doing an electronics class as an elective. So I apologise for my inevitable ignorance. Essentially I am trying to get my arduino to read whether the audio is playing from the left or from the right. Using the set up I have, I was playing youtube videos which separate left and right audio (speaker tests).


I was really excited to see that I was getting the offset I needed (in order to read the negative voltages from the audio signal). I do get a reading from both my left and right inputs, but the issue is that both these readings only come from when left sound is playing (see attached). Reading my left port, will get the jumps when there is left sound playing, and the flat line when right sound is playing. This is also what happens when I read from my right port as well. I would have expected something like the peaks to happen when right sound is playing, and the flatline when left sound is playing. This is an issue because both ports simultaneously get some feedback when there's left sound playing, and both flatline on right sound. If there's no sound at all, it's a flatline as well, so I can't think of a way to determine whether right or left sound is playing.


Is there something I've done wrong? Or is there something I'm missing that will connect all the dots? I'd appreciate any input! I've tried some problem solving with perhaps using the same ground or voltage supply for both sides is causing what I'm seeing. So I tried to connect the right input with a 9V battery instead of using the arduino power supply, but I see similar results. Perhaps it has to do with my ground configuration? I connected all 3 grounds to separate ground pins on my arduino, but perhaps they're all connecting to the same ground on the board and are therefore connected? I'm not sure.

FantomT

Circuit seems correct. But the spatial recognition is more complex task, than you may think. Humans differentiate direction to sound sources based on a phase, and it's quite unusual if signal presents in one channel only. Left and right channels very alike each other, it's phase what makes them different. Arduino could calculate phase via cross-correlation, but I'm in doubt if you could find any on-line examples on the subject.

Grumpy_Mike

Quote
I'd appreciate any input! I've tried some problem solving with perhaps using the same ground or voltage supply for both sides is causing what I'm seeing.
No it is not a problem. You need all the grounds to be connected to the same point and there is no reason to have separate positive supplies. In fact connecting 9V with one could damage your Arduino.

What is hanging off those inputs? That is what is the full schematic of the system?

It would help a lot if you posted your code so we could try and explain your results, but as FantomT rightly points out this problem is not quite as easy as you think.

Thomasta3

Thank you for the replies so far guys.

In fact connecting 9V with one could damage your Arduino.
I thought this could be the case so I just gave it a quick try and disconnected it when it didn't have the results I wanted

What is hanging off those inputs? That is what is the full schematic of the system?
The circuit diagram I uploaded paints the hole picture at the moment, at least I believe it does anyway. What do you mean by hanging off those inputs? For the moment I have the audiojack connecting to a terminal block (https://core-electronics.com.au/3-5mm-1-8-4-pole-trrs-audio-jack-terminal-block.html). Ground to ground, with the left and right channels go to a breadboard where they follow the schematic I made, connecting to the analog pins from the voltage divider.

It would help a lot if you posted your code
Code: [Select]

void setup() {
  Serial.begin(9600);

}


void loop() {
  float right = analogRead(A0);
  float left = analogRead(A1);

  Serial.println(right);

  delay(30);      // I've changed the delay around, longer delays to try read the values from my serial monitor, but when I'm just plotting I keep it low.
}




Thanks again for your help.

Grumpy_Mike

Quote
The circuit diagram I uploaded paints the hole picture at the moment, at least I believe it does anyway.
Sorry it doesn't. All that "schematic is two voltage dividers and a capacitor. Nothing else. No Arduino.
No audio input.
Nothing.

The code is even more odd. Why use a float variable for an integer quantity? You are just reading the instainious signal, that is just going to be a random looking value centred arround about 512. It will go up and down arround this value. It will be impossible to tell what is the loudest channel with that software.

Quote
do get a reading from both my left and right inputs, but the issue is that both these readings only come from when left sound is playing
This looks like you have not connected the audio inputs like you think you have. You will need to post both a schematic and a photograph to make much progress.

Thomasta3

#5
Oct 22, 2018, 04:50 am Last Edit: Oct 22, 2018, 04:54 am by Thomasta3 Reason: Adding photos
Sorry it doesn't. All that "schematic is two voltage dividers and a capacitor.
I have attached some arduino diagrams using a program I have not used before, so I wasn't sure how to make some of the connections exactly how they are in my circuit (pictures provided as well). There are two versions, one with easier to follow colouring, and one with the same colours as my real-circuit. The values of resistors and capacitors are as they are in my original diagram. Thank you for your patience.


The code is even more odd. Why use a float variable for an integer quantity?
I was experimenting with applying some maths to see how I could manipulate the waves I was detecting. I put it into a float out of habit for doing calculations, but you're right it wasn't needed. I forgot to put it back to an integer when I simplified my code again for the post.

Grumpy_Mike

Thanks for the diagrams and photographs. I can't spot anything obvious where you have gone wrong.
Things to try
Connect both inputs to the same channel of the audio output. Do they both still read?

Try connecting your ground to the other pin on the audio jack connector. You currently have the ground symbol connected try the one next to it instead.

Once you are reading the two channels then replace the input circuitry with an envelope detector on each channel.

Thomasta3

Sorry for the late reply, I've been meaning to update the thread but I hadn't found the time. With the deadline drawing near for the project, I decided I would go with my back up plan of using analogue sound sensors instead of parsing the audio jack's signals. So far this method has worked perfectly, but I would like to return to the audio jack method eventually, when there isn't a deadline. I'll update the thread when, and if I get around to doing this, with my progress and results.

Thank you once again for your help and time.

Go Up