When EVENT_INIT_POSTCONNECT is fired, all components in the system have been created, and the Base Sample Rate has been negotiated. It is now available (and non-zero) through time->baseSampleRate. At this point, you may want to precalculate temporal parameters that are dependent on this rate. Note that if you do this in an earlier event, you will get a duff result because the Base Sample Rate is not yet decided. Therefore, EVENT_INIT_POSTCONNECT will be important to you if you have such parameters to precalculate.

Generally, you should assume that all timing information (everything in ComponentTime) is only valid from this event onwards. Therefore, it is strongly recommended that you do all your timing calculations in this event. In current systems, ComponentTime::sampleRate will in fact be valid right from the outset, but if there is demand, a future implementation may violate this assumption. Therefore, best practice is to stick to this approach.


C++ Source Code (against 1199)
... DOUBLE BaseSamplePeriod; DOUBLE ProcessSamplePeriod; DOUBLE lambda; ... case EVENT_INIT_POSTCONNECT: { ... // calculate base sample period in seconds BaseSamplePeriod = sampleRateToPeriod(time->baseSampleRate); // this is what is done in sampleRateToPeriod() BaseSamplePeriod = ((DOUBLE)time->baseSampleRate.den) / ((DOUBLE)time->baseSampleRate.num); // calculate process sample period in seconds ProcessSamplePeriod = sampleRateToPeriod(time->sampleRate); // another way to get the same thing ProcessSamplePeriod = time->samplePeriod * BaseSamplePeriod; // pre-calculate decay constant to apply at // run-time (i.e. once every ProcessSamplePeriod) lambda = exp(-ProcessSamplePeriod / tau); ... } case EVENT_RUN_SERVICE: { ... // you can get the current service time in seconds // by converting the Base Clock time to the Execution // Clock time DOUBLE timeInSeconds = time->now * BaseSamplePeriod; // and you can decay a dynamic state using the // pre-calculated decay constant myState *= lambda; ... }