Problem with counting samples

Deftoner's icon

Hi!

I want to count the elapsed samples from the start of an audio signal until a defined threshold is exceeded. The Threshold recognising works fine, but i have a problem with the counter.
I use the [count~] object in combination with the [snapshot~] object, because i want the result displayed in a message.

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

So here is what i did:

(The bangs and the stop messages are triggered by the threshold patch)

Why doesnt that work? Is there another way to do this?

pdelges's icon
Max Patch
Copy patch and select New From Clipboard in Max.

It doesn't work because number~ doesn't work the way you expect it.
This may help you:

Deftoner's icon

Thank You!
That was easier than expected :)

Deftoner's icon

Thanks to Patrick, i could solve my problem, but now i have another one:

I finished the patcher and it does, what it should but way too inaccurate!
The variation of the meassured predelay is around 600 samples! I was hoping i could reach an accuracy of maybe +-5 samples. Is this utopian in Max, or am i doing something wrong again?

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

Here is my patch:

First i used an sfplay object to play the audio file, so i thought the problem would be the slow hard drive and implemented a buffer.
It didnt help at all...

Any ideas?

pdelges's icon

If you need sample accurate measures, you need to stay in the MSP domain (even the time needed for a Max message like stop will take a lot of samples!). I don't have Max5 at hand now, so I can't check your patch.

p