Affichage des articles dont le libellé est Init function with GetSampleRate(). Afficher tous les articles
Affichage des articles dont le libellé est Init function with GetSampleRate(). Afficher tous les articles

mercredi 28 septembre 2016

Init function with GetSampleRate()

Where VST functions like GetSampleRate(), GetSamplesPerBeat() are available for all hosts?

I see this function is not available on Reset() or OnParamChange() to all hosts. Cubase for example return real value of this function only in ProcessDoubleReplacing(). To solve this problem I build a Init() function like this:

Code:

//in IPLUG_CTOR

sbeat=0.;


void Init() {
///// here can safe access GetSampleRate() or GetSamplesPerBeat
        srate = GetSampleRate();
        sbeat = 4*GetSamplesPerBeat();
}
Reset() {
        TRACE;
        IMutexLock lock(this);

        if (sbeat<1.) {
                this->Init();
        }
}
OnParamChange() {
        TRACE;
        IMutexLock lock(this);

        if (sbeat<1.) {
                this->Init();
        }
}
ProcessDoubleReplacing() {
        TRACE;
        IMutexLock lock(this);

        if (sbeat<1.) {
                this->Init();
        }
}

There is no other solution ? What do you use to get safe values of this functions for all hosts?


Init function with GetSampleRate()