# Playing/Recording acoustic signal in matlab to tell difference between 2 sounds

I will be using one central node/latop to play a tone and will have a second node/laptop to record and read the sound and be able to say this node is on the left or right. So trying to figure out the best way to distinguish between the two tones. I want to have a tone set for left and one set for the right. I want the sound to have 400 Samples at 44100 for 10ms between 18-22freq just outside the human hearing range so that the sound is not annoying etc. I want the sound to be different slightly but be able to tell the diff between them for the system to say the node that recorded and processed the sound is on the left of right. How would I go about doing this in matlab because I don't dont really code in this language much and only time I did was for image processing just doing this so I can graduate.

• jojek- I want have a sound set so say the node recording reads it and says yes this node is on the left and have a sound for the right doing the same but how would I go about making it so that it plays that right way from a 2d array. May 13 '14 at 20:11
• From my understanding of the question, the left/right might not refer to the spatial position of sound but just to two symbols that have to be transmitted? What kind of speaker and recording equipment will you use for that? Low-quality audio equipment is just not optimized for applications outside of the human hearing range - that would be a waste of engineering resources! May 13 '14 at 20:20

I understand that you want to tell if your second laptop is placed on the left or right (or maybe on the axis) of main node?

I suggest you then to play the two-tone stereo signal, i.e.: $15\;kHz$ from the left, and $16\;kHz$ from the right speaker at the same time. Assuming that you are going to use sampling frequency of $f_s=41000 \; \text{Hz}$ and taking the average distance between two speakers in a laptop to be $25\;cm$, you can calculate that the maximum delay between two signals, if the second node is on the right, will be approximately: $\dfrac{0.25}{343}=0.7289\;msec$. This corresponds to $32$ samples at a given sampling frequency. It is therefore a hard task, but still possible. Then after finding the delay between two signals, from its sign you are able to tell which speaker is further away, ergo you are on the opposite side.

In MATLAB you just need to generate proper signals, given sampling frequency and play them back/record with: MATLAB - Record and Play Audio.

Few problems can arise:

• You want to use very high frequencies, and this can be problematic as laptop speakers are usually low-grade gear and they possibly might have some problems- same goes to microphone. Also remember to turn any hardware noise cancellation, spatial enhancements, etc.
• Detection of you signal onset could be problematic as the resolution of DFT will be to low. You can also use some kind of correlation detection, but this is a problem for later on.
• I have to find the left or right answer differently than that because the article my professor gave me he wants me to try it different. So is possible I can use the the fact that one is being played at 15hz and 16hz...is there anyway to have the signal to read and decide which is which saying 15 is the left and 16 is the right. If that makes any sense. May 14 '14 at 5:18
• @Asau7610: Well - instead of explaining it in your own words, maybe link to the article, state the purpose, or even add the picture? Because it's like you are copying and pasting same text. Secondly, if you want to transmit 15/16 Hz (not kHz) with laptop speakers, then good luck. No way to play and record ultrasound with such gear. Also distinguishing between them will be very hard. Not mentioning the fact that you originally proposed: 18-22freq(Hz?) at 10ms, which makes it impossible to emit at least one period of this infrasound. Regarding sounds, you can even use sweeps for that purpose.
– jojek
May 14 '14 at 6:19