API Call to see if Voicemeeter is running

How to use Voicemeeter Remote API and control Voicemeeter Audio Engine
Post Reply
sjc-or
Posts: 25
Joined: Sun Sep 06, 2020 11:17 pm

API Call to see if Voicemeeter is running

Post by sjc-or »

Hi,
I'm using AutoHokey with Voicemeeter Remote API. Is there a call I can make to see if Voicemeeter is running.

RIght now, if I call VBVMR_IsParametersDirty while Voicemeeter Is not running, it returns -2. Is this the best way to tell if it is running? I want to catch the case where Voicemeeter is no longer running (because the user or some other process may have shut it down after I started my application) and either alert the user to restart voicemeeter or just restart it myself within the script.
sjc-or
Posts: 25
Joined: Sun Sep 06, 2020 11:17 pm

Re: API Call to see if Voicemeeter is running

Post by sjc-or »

I think I solved it. Below is what I did for now.
Commented is the original

/* Original
IsParametersDirty(){
return DllCall(VBVMR.VM_DLL . "\VBVMR_IsParametersDirty")
}
*/
; Modified 2020-10-02
IsParametersDirty(){
a:= DllCall(VBVMR.VM_DLL . "\VBVMR_IsParametersDirty")
if ( a < 0 )
{
msgbox Voicemeeter is down, please restart then then press OK
return 1
}
return a
}
Vincent Burel
Site Admin
Posts: 1354
Joined: Sun Jan 17, 2010 12:01 pm

Re: API Call to see if Voicemeeter is running

Post by Vincent Burel »

the best example is in the vmr_matrix.c example (in SDK):

Code: Select all

case WM_TIMER:
      if (wparam == MYTIMERID)
      {
            //check if voicemeeter type has changed
            lpapp->vbvmr_error=iVMR.VBVMR_IsParametersDirty();
            if (lpapp->vbvmr_error >= 0)
            {
                  if (lpapp->vbvmr_connect == 0)
                  {
                        DetectVoicemeeterType(lpapp, hw);
                  }
            }
            else 
            {
                  if (lpapp->vbvmr_connect != 0)
                  {
                        //Voicemeeter has been shut down
                        lpapp->vbvmr_connect	=0;
                        lpapp->vbvmr_nbbus		=0;
                        InvalidateRect(hw,NULL,TRUE);
                  }
            }
      }
      break;
The function "DetectVoicemeeterType" will set the vbvmr_connect according the Voicemeeter version for example:

Code: Select all

void DetectVoicemeeterType(LPT_APP_CONTEXT lpapp, HWND hw)
{
      long rep,vmType;

      lpapp->vbvmr_nbbus		=0;
      lpapp->vbvmr_pBUSName	=NULL;

      rep=iVMR.VBVMR_GetVoicemeeterType(&vmType);
      if (rep == 0) 
      {
            if (lpapp->vbvmr_connect != vmType)
            {
                  lpapp->vbvmr_connect =vmType;
                  switch(vmType)
                  {
                        case 1://Voicemeeter
                              lpapp->vbvmr_nbbus		=2;
                              lpapp->vbvmr_pBUSName	=G_szBUSNameList_v1;
                              break;
                        case 2://Voicemeeter Banana
                              lpapp->vbvmr_nbbus		=5;
                              lpapp->vbvmr_pBUSName	=G_szBUSNameList_v2;
                              break;
                        case 3://Voicemeeter 8
                              lpapp->vbvmr_nbbus		=8;
                              lpapp->vbvmr_pBUSName	=G_szBUSNameList_v3;
                              break;
                   }
                   InvalidateRect(hw,NULL,TRUE);
              }
       }
 }
sjc-or
Posts: 25
Joined: Sun Sep 06, 2020 11:17 pm

Re: API Call to see if Voicemeeter is running

Post by sjc-or »

Thanks, Vincent!
Post Reply