Greatest Possible Timing Precision

gavspav's icon

This is related to my motion tracking using piezos post(below) but is really a new topic.

I am attempting to track where a ping pong ball hits a table during a game using an array of microphones.

I need to ask if it is possible with a standard audio interface (in my case m-audio firewire audiophile).

I know that sound travels at 340m/s and I am estimating that it travels at 600m/s through the table.

I think that to detect the position of impact within 5cm I need to be able to access data from the microphones to within 1/12 of a millisecond.

I understand that it is possible to sync Max to an external clock or to change the length of (what it thinks is a) millisecond to get at the timing data.

I understand that I can sample audio at a frequency of 44,100.

But.....and this is the question

Is it possible to analyse the signals accurately at these sub-millisecond levels?

Anyone any thoughts?

Gav

Jean-Francois Charles's icon
Andrew Benson's icon

Hi Gavin,
My suspicion is that you are using max objects, when you actually need
the precision of MSP signal-based objects. I suggest using a signal
based timer, as demonstrated in the patch below. This will give you far
greater accuracy than using the timer object. Hope this helps get you
started.

Cheers,
Andrew B.

Max Patch
Copy patch and select New From Clipboard in Max.

gavspav's icon

I've been experimenting with MSP and I'm getting there but could really use a hand!

I now have a patch which detects the incoming signal (at 96000 hz)and outputs the time if the level goes above a threshold value.

The main problem is that either the count~ or the snapshot~ objects are jumping in steps of 512 (or whatever value I set the hardware buffer to).

I need to detect where the amplitude rises to within a sample or 2. 512 is not precise enough.

I've been playing around with recording the input into a named buffer. I can see the wave forms in each channel, the information is there but I don't know how to get it.

I have been trying to search through the buffer using count~ and index~ but getting a bit stuck.

Anyone know what I'm on about?

Gav

Max Patch
Copy patch and select New From Clipboard in Max.

Peter Castine's icon

On 2-Apr-2006, at 0:46, gavin wrote:

> The main problem is that either the count~ or the snapshot~ objects
> are jumping in steps of 512 (or whatever value I set the hardware
> buffer to).

Yeah. Max messages (ie, anything going through plain-vanilla patch
cords) are only triggered between signal vectors. You could set your
signal vector size to 2 samples (you can even set it to single-
samples by using a ;max message), but for what you want you would be
better off to do everything the MSP-domain.

Hope this gets you going in the right direction. Someone else may
feel inclined to try to amend your patch.

-- Peter

-------------- http://www.bek.no/~pcastine/Litter/ -------------
Peter Castine +--> Litter Power & Litter Bundle for Jitter

iCE: Sequencing, Recording & |home | chez nous|
Interface Building for |bei uns | i nostri|
Max/MSP Extremely cool http://www.castine.de
http://www.dspaudio.com/

Roman Thilenius's icon

> Is it possible to analyse the signals accurately at these sub-millisecond levels?

do the math ... 1/12th milisecond at 44.100 Hz
is humh ..possible, yet its all but precise.

any chance to repeat the experiment with a bigger ball
in a bigger room ? :)

Roman Thilenius's icon

Quote: gavspav wrote on Sat, 01 April 2006 15:46
----------------------------------------------------
> I've been experimenting with MSP and I'm getting there but could really use a hand!
>
> I now have a patch which detects the incoming signal (at 96000 hz)and outputs the time if the level goes above a threshold value.
>
>
> The main problem is that either the count~ or the snapshot~ objects are jumping in steps of 512 (or whatever value I set the hardware buffer to).
>
> I need to detect where the amplitude rises to within a sample or 2. 512 is not precise enough.
>
> I've been playing around with recording the input into a named buffer. I can see the wave forms in each channel, the information is there but I don't know how to get it.
>
> I have been trying to search through the buffer using count~ and index~ but getting a bit stuck.
>
> Anyone know what I'm on about?

havent been looking at the patch but maybe its simpler
than you thought.
there is, for example, the [>~] object to split signals
and so detect certain values.
or why not substract -0.9 from the input and then use
[zerox~] to find the most peaks of the ping pong sounds.

use signals only or you can forget it.

whats your aim, what do you want to do with the
"sequence" data?

gavspav's icon

Hello,

thanks for your suggestions.

Peter when you say Max messages are the ones with the plain/vanilla
patch cords do these signify messages from MSP to Max?

Also I am trying to keep it in the MSP domain but am I right in thinking that:

MSP threads running at signal rate operate once every time a chunk of sound is brought in which for me at the mo is 512 samples (My hardware buffer is set to 512 samples)

But within the objects there are operations going on at the sample rate i.e 96000 hz

If MSP processes the data in chunks, then how can I find out information relating to individual samples? The only way I have found to do it so far is by using an onject like peak~ which seems to force me to use max objects.

I wish to pinpoint when events happen to within a sample but it is not imperative that I process the data immediately. I am thinking that as long as I record the events I have a few ms to detect when they actually occur, so I could possibly use max objects as well.

Thanks,

Gavin

projects's icon

Hi Gavin,

If you haven't already, you may wish to investigate a network that
uses the sah~ object in conjunction with snapshot~ and edge~. Even
with these objects it can be problematic to isolate exactly the data
you want from a signal stream; some work has been done in this area
and a future version of Max may include a more precise tool to move
from the signal to event world.

Ben

Matthew Aidekman's icon

> some work has been done in this area
> and a future version of Max may include a more precise tool to move
> from the signal to event world.

One of the reasons I love cycling so frickin much is that you guys
are transparent. I don't want to get off on a leftist rant here(take
that dennis miller), but when we ask you things, you respond
honestly and openly. It was a passing comment but its not to be
taken lightly. I don't see this happening in many places. and its
worth an extra couple bucks and should be an example.

got that choir?!
-matt

gavspav's icon

Hi Ben,

when you say some work has been done in this area, is there any links where I might be able to learn about this stuff.

I have experimented with sah~, edge~, snapshot~. I'm a bit in the dark though to be honest.

Gav

Stefan Tiedje's icon

Ben Nevile wrote:
> a future version of Max may include a more precise tool to move
> from the signal to event world.

To measure sample accurate timing I'd use mxj~ to do the timing and then
pull the result out to the event world.

Thats probably the way to go. Counting samples in Java shouldn't be too
hard even for a Java newbie. All the documentation and the examples are
there.

That means (as mostly) already the recent version of Max could do it...

Stefan

--

[][] [][][] [][] [][][]
[][][][][][][][][][][][][][][]

Stefan Tiedje
Klanggestalter
Electronic Composition
&
Improvisation

/~~~~~
\ /|() ()|
))))) )| | |( \
/// _/)/ )))))
___/ ///

-------------------------x----
--_____-----------|-----------
--(_|_ ----|-----|-----()----
-- _|_)----|-----()-----------
----------()------------x-----

14, Av. Pr. Franklin Roosevelt,
94320 Thiais, France
Phone at CCMIX +33-1-57 42 91 09

gavspav's icon

Thanks for the tip.

I'm back on the case now after a short break.
Looking at the Javascript documentation now.

Stefan wrote: Counting samples in Java shouldn't be too
hard even for a Java newbie. All the documentation and the examples are there.

Stefan, are you referring to the javascript documentation within the MaxMSP folders or something else?

Gavin

Stefan Tiedje's icon

gavin wrote:
> Stefan wrote: Counting samples in Java shouldn't be too hard even for
> a Java newbie. All the documentation and the examples are there.
>
> Stefan, are you referring to the javascript documentation within the
> MaxMSP folders or something else?

Don't mix Javascript with Java, I am reffering to Java and the mxj~
object. You should get started with the mxj~ helpfile and the
WritingMaxExternalsInJava.pdf especially page 43, dealing with mxj~ and
audio.

Stefan

--

[][] [][][] [][] [][][]
[][][][][][][][][][][][][][][]

Stefan Tiedje
Klanggestalter
Electronic Composition
&
Improvisation

/~~~~~
\ /|() ()|
))))) )| | |( \
/// _/)/ )))))
___/ ///

-------------------------x----
--_____-----------|-----------
--(_|_ ----|-----|-----()----
-- _|_)----|-----()-----------
----------()------------x-----

14, Av. Pr. Franklin Roosevelt,
94320 Thiais, France
Phone at CCMIX +33-1-57 42 91 09

gavspav's icon

Oops my mistake!
Ok thanks I'll get stuck in,

Gav