Correct usage of "VBVMR_IsParametersDirty" question

How to use Voicemeeter Remote API and control Voicemeeter Audio Engine
Post Reply
Atg
Posts: 32
Joined: Sat Oct 19, 2019 11:30 am

Correct usage of "VBVMR_IsParametersDirty" question

Post by Atg »

I little confused about VBVMR_IsParametersDirty function. This is what I figured out that kinda works for me like expected

Code: Select all

void WaitForUpdate()
{
    while (!iVMR.VBVMR_IsParametersDirty())
    {
        Sleep(10);
    }
}

int IsRecording()
{
    float val;
    WaitForUpdate();
    iVMR.VBVMR_GetParameterFloat("recorder.record", &val);
    return val;
}
Is it ok to call VBVMR_IsParametersDirty in loop like this? And call WaitForUpdate() before any GetParameter function and after any SetParameter ?
Vincent Burel
Site Admin
Posts: 2005
Joined: Sun Jan 17, 2010 12:01 pm

Re: Correct usage of "VBVMR_IsParametersDirty" question

Post by Vincent Burel »

no, you may call iVMR.VBVMR_IsParametersDirty periodically (20 to 50 times per second) - typically in WM_TIMER event.
and refresh display if returning a value different from ZERO

Code: Select all

fDisplayParam=iVMR.VBVMR_IsParametersDirty();
if (fDisplayParam!= 0) 
{
   dc=GetDC(hw);
   DrawCurrentValues(lpapp, hw, dc);
   ReleaseDC(hw,dc);
}
you can call iVMR.VBVMR_GetParameterFloat when you want and consider it is updated.
see example in source code example vmr_client.c in Voicemeeter Remote SDK
Atg
Posts: 32
Joined: Sat Oct 19, 2019 11:30 am

Re: Correct usage of "VBVMR_IsParametersDirty" question

Post by Atg »

Ok. But without "WaitForUpdate()" I get very unreliable results, for example iVMR.VBVMR_GetParameterFloat("recorder.record", &val); was returning (putting in "val" variable) 0 on first program launch and 1 on second (recorder was enabled). Also if I write something like this: Login() -> SetParameter() -> Logout();. Then SetParameter() will not change anything unless I use that loop before Logout(). For example that program https://www.dropbox.com/s/ltxfvzxenxfqt ... c%2Fmain.c was not able to change parameter without that loop at lines 46-49 or just without any Sleep function.
Vincent Burel
Site Admin
Posts: 2005
Joined: Sun Jan 17, 2010 12:01 pm

Re: Correct usage of "VBVMR_IsParametersDirty" question

Post by Vincent Burel »

ok, if you are not in a Windows Event Handling Context,
you may just call iVMR.VBVMR_IsParametersDirty without sleep()
and call after iVMR.VBVMR_GetParameterFloat("recorder.record", &val);
Post Reply