gen~ timing issue

Paul Brauner's icon

Hey Folks,

Im new to the gen~ environment and currently trying to create a sequencer with a buffer and gen~ and I am running into a problem I cant seem to figure out. After having created a buffer, specified its sample size and distributed values of 1 ("events") evenly across it, I get uneven (some 209ms others 290ms) impulses reading it with gen~.

Once when I opened the patch, the impulses were even until I opened the gen~. I was unable to reproduce this though, now I always get uneven values.

I´ve tried the same patch on a different computer, where it seemed to work. Does my problem reproduce on your computer?

Im wondering if it is a CPU related issue but generally, im puzzled.

My initial thought was that using gen~ for sequencing will give me more precision than ticks for example, but maybe its too computation heavy?

Any help/hint is very appreciated.

heres the patcher:

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

Graham Wakefield's icon

It's nothing about CPU load, that gen~ patch is very small and cheap. The gen~ patch is also perfectly accurate in timing, there's no issue there.

The variation you are seeing is because you are using [edge~] which translates events from the audio signal realm, where everything is sample-accurate, into events in the message-passing domain of the Max scheduler, in which things can operate at a lower temporal resolution. The inaccuracy of this transfer also depends on the current audio vector size.

You can turn on Scheduler in audio interrupt (in the Options / Audio Status) and/or change the Max scheduler resolution (see Preferences / Scheduler) but it will never be as accurate as audio-based timing. If you really need microsecond accuracy, keep everything within audio signals, not Max scheduler messages.

If the goal is to output MIDI, then there's no way around it -- MIDI is always in the scheduler realm, not audio realm, so there's always some temporal price to pay.

Iain Duncan's icon

If you running with audio in interrupt and you haven't accidentally moved things somehow from the scheduler thread to the low priority UI thread, you should get some jitter from moving from audio to event land, but it should not be anywhere near as high as 80ms difference. You should only see one signal vector of jitter, which at a vector size of 64 samples at 44.1khz SR is only 1.5 ms. (This assumes Audio in Interrupt is selected)

So sounds to me like you might have accidentally run events into a low priority thread thread or you have something else playing havoc with things.

Paul Brauner's icon

Thanks a lot for the answers, it was the vector size.