Could gen~ be used to calculate the time difference of arrival of a sound? eg four microphones – calculate the time difference of a sound to arrive at each one.
I haven’t looked into gen (maybe this could get me started) but would I be right in thinking that being able to work at a sample resolution would give the accuracy required?
If so any tips to set me on my way?
Yes, with gen~ you can work at the sample resolution directly. Take a look at the gen~.zerox and gen~.chopper examples for examples of measuring time differences in samples.
One issue will be determining what constitutes the onset of the sound. If you are working in a studio environment, that may be as simple as detecting when the (absolute or squared) amplitude of a signal goes over a threshold. A low-pass filter (running average) may be desirable to eliminate random differences in the input signals; a [mix] + [history] pair makes a simple running average filter (there’s an example of this at the bottom of the gen~.karplus_strong example).
You want to output a sample value 1 just as it goes over the threshold, and 0 for every other sample clock before and after, so take the threshold detection signal and pass it through [delta] -> [> 0].
Once you have onset detection per input signal, simply use it to capture the current value of a sample counter at that time. A [+= 1] object works as a sample counter. Capturing the value can be done with the [? ] operator.
Let us know how you get on!
C74 RSS Feed | © Copyright Cycling '74