Csound Csound-dev Csound-tekno Search About

[Csnd] measuring time difference of pulse between 2 channels

Date2012-06-17 13:59
Fromzappfinger
Subject[Csnd] measuring time difference of pulse between 2 channels
I am trying to measure the time difference of a sound pulse between the left
and right audio inputs.
2 mics are used, and I tap on one mic to get a pulse. That sound should
reach the other channel a bit later, depending on the distance (speed of
sound through air is known)

The basic idea is:

;channel 1
ain1 inch 1
ktrig	metro	kr/2		
kvol1	max_k	ain1, ktrig, 1
if kvol1>threshold
  gkTime1 timek
endif
;channel 2
ain2 inch 2
kvol2	max_k	ain2, ktrig, 1
if kvol2>threshold
  gkTime2 timek
  gkTimeDiff = abs(gkTime2 - gkTime1)
endif

If I am correct that this (or any) code is executed every 1/kr seconds?

Richard


--
View this message in context: http://csound.1045644.n5.nabble.com/measuring-time-difference-of-pulse-between-2-channels-tp5713820.html
Sent from the Csound - General mailing list archive at Nabble.com.

Date2012-06-17 15:47
Fromjpff@cs.bath.ac.uk
SubjectRe: [Csnd] measuring time difference of pulse between 2 channels
> If I am correct that this (or any) code is executed every 1/kr seconds?

Yes if running in realtime