[PD] measuring distance between speaker and microphon

Miikka Tikander miikka.tikander at hut.fi
Tue Feb 20 12:09:01 CET 2007


Hi Roman,

With the method I mentioned, the key thing is using high frequencies.  
In addition to make the whole thing practically inaudible, it's also  
perhaps the only way to avoid interference from reflections and  
background noise. If you want or need to use lower frequency range  
then you should try, e.g., correlation techniques.

As for the external, I think you should be able implemented it with  
pure Pd as well. I actually tried to make a Pd-version of it but I  
never really got it working (to be honest, I'm really clumsy with Pd)  
and I just ended up implementing it in C.

Here's a short description what the external does for the received  
signal:

1) high-pass the signal with the same cut-off frequency as used for  
the sent impulse (~ 16-17kHz)
2) rectify the signal
3) low-pass filter the signal below ca. 4 kHz
4) find the maximum (for more accuracy use interpolation)

The original idea came from my professor Matti Karjalainen. So the  
credits goes to him :)   I attached a demo patch that shows how the  
signals look like in the first three steps (it requires iem-libraries).

I just compiled a linux version of the external but I first have to  
get audio working in my linux-box so I can test it before I'll send  
it. And sure, I can send the source and the make file I used, as well.


Cheers,
Miikka


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signaalit_positiossa.pd
Type: application/octet-stream
Size: 4027 bytes
Desc: not available
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20070220/d40c6f93/attachment.obj>
-------------- next part --------------




On Feb 19, 2007, at 5:46 PM, Roman Haefeli wrote:

> hi mikka
>
> thank you very much for all that detailed information and sorry for my
> late reply. i didn't have too much time and i really wanted to have a
> closer look at this before answering.
>
> i am on linux, so i couldn't test your external. but from what you
> describe in your mail, it follows a similar approach i tried as well,
> the only difference is that yours obviously works, whereas i've had  
> bad
> luck yet with my tests ;-). maybe i am wrong, but i believe that the
> method you describe could be implemented in plain pd without using
> externals (this is at least what i hope).
>
> am i right in thinking that the analysis part of your external also  
> high
> pass filters the incoming signal from the mic and the measures the  
> time,
> until a certain amplitude of the signal is triggered? i have many
> problems implement this nicely. the main problem is i think is, that i
> maybe should do the trigger mechanism adaptively, so that it works on
> changing levels. how is that done in your external?
>
> if you don't mind, it would be nice to have the source code of your
> external, so that i could at least try to compile it, though i am  
> not a
> programmer myself and maybe i fail without a ready-made makefile. but
> it's sure worth a try.
>
> thank you again for sharing all that information about this topic.
>
> best
> roman
>
>
> On Wed, 2007-02-14 at 16:51 +0200, Miikka Tikander wrote:
>> Hi,
>>
>> I made some externals for binaural acoustic positioning for my work
>> some time ago and it also included some externals for acoustic
>> distance measurements. I was supposed to polish them up to be
>> published on my website but  I never got that far... Anyway, here's
>> one  simple patch with one of the distance measurement externals.
>>
>> The external is an OSX version but I know I have a linux version
>> somewhere as well. If needed I can try to find it and send it as
>> well, or maybe I'll send the source so people can compile it
>> themselves if interested. It should be compilable WIN and Linux as  
>> well.
>>
>>
>> As there's no documentation in the patch, here's a brief
>> documentation for the patch and the external.
>>
>> The DIST_HP~ external sends high-passed (> 17 kHz) impulses from the
>> loudspeaker and then measures the fly-time of these impulses to two
>> microphones (here input channels 1 and 2). The slider on the upper
>> right hand corner (Impuse interval) sets the time interval (in 64
>> sample blocks) of the impulses, that is, how often the distance is
>> measured.
>>
>> The last two outlets of the DIST_HP gives out the distance of the
>> microphones to the loudspeaker in meters. I put a mean and a median
>> filter on there as well to smooth the data but you may use whatever
>> is appropriate. The distance is computed in sample accuracy.
>>
>> The 'free_distance_in_meters'  -outlet transforms the impulse time
>> interval to a physical distance. This, in principal, should be
>> greater than the longest microphone-loudspeaker distance you will  
>> use.
>>
>> The calibration is done by using the calibration_latency  -number on
>> the left. Place a microphone to a known distance from the loudspeaker
>> and then tune the calibration_latency so that the measured distance
>> is correct. Increasing the latency  increases the measured distance.
>> The measured distance cycles from 0 to the free_distance_in_meters.
>> So, when increase the calibration_latency and the measured distance
>> reaches the free_distance_in_meters it will go back to zero and
>> continue from there.
>>
>> The volume slider sets the output volume of the impulses. Note, that
>> the impulses are high passed above 17 kHz so actually not everybody
>> will here them! Be cautious with the volume. The whole idea of using
>> higher frequency range was to make the impulses inaudible, and to
>> avoid interference from room reflection and from other sounds as
>> well. I have a version which uses full band impulses as well, but
>> then the reflections start to worsen things..
>>
>> You must use 44,1 kHz sampling frequency.
>>
>>
>>
>> Hope, it works and is usable. Once I get little extra time, I'll try
>> to get the rest of the stuff organized and documented so I can
>> publish them here as well. Any feedback or criticism is always  
>> welcome.
>>
>>
>> -miikka
>>
>>
>>
>>
>>
>>
>>
>> On Feb 14, 2007, at 2:18 PM, Roman Haefeli wrote:
>>
>>> hi all
>>>
>>> i'd like to create a patch, that measures the distance between the
>>> speaker and the microphone. my first problem is, that i don't know
>>> which
>>> kind of signal would be suitable for that purpose. the simplest  
>>> is to
>>> use a dirac impulse. but on the receiver-side it's hard to separate
>>> unwanted artefacts from the impulse itself. also it would be nice,
>>> if it
>>> would be possible to detect the signal reliably at different
>>> amplitudes,
>>> since the amplitude heavily changes when moving the mic closer to  
>>> and
>>> farer from the speaker. i am looking for a method, that allows  
>>> higher
>>> precision than the usual block-size (which introduces a grid of
>>> ~0.5m @
>>> 44100Hz, which is not very accurate). also should it be possible to
>>> detect the signal correctly, when there was reverberation added  
>>> from a
>>> room. i know, there are ultrasonic-bases devices to measure a  
>>> distance
>>> to a wall, but i don't have clue how they work, but it makes me  
>>> hope,
>>> that something similar is possible with pd. any hints are much
>>> appreciated.
>>>
>>> roman
>>>
>>>
>>>
>>>
>>> 	
>>> 		
>>> ___________________________________________________________
>>> Der fr?he Vogel f?ngt den Wurm. Hier gelangen Sie zum neuen Yahoo!
>>> Mail: http://mail.yahoo.de
>>>
>>>
>>> _______________________________________________
>>> PD-list at iem.at mailing list
>>> UNSUBSCRIBE and account-management -> http://lists.puredata.info/
>>> listinfo/pd-list
>>
>
>
> 		
> ___________________________________________________________
> Telefonate ohne weitere Kosten vom PC zum PC: http:// 
> messenger.yahoo.de
>
>
> _______________________________________________
> PD-list at iem.at mailing list
> UNSUBSCRIBE and account-management -> http://lists.puredata.info/ 
> listinfo/pd-list



-------------------------------
Miikka Tikander
050-543 4491





More information about the Pd-list mailing list