2024-06-25 04:34:28 +01:00
|
|
|
#include <windows.h>
|
|
|
|
#include <stdio.h>
|
2024-06-27 02:51:27 +01:00
|
|
|
#include <time.h>
|
2024-06-25 04:34:28 +01:00
|
|
|
#include "vmr.h"
|
2024-06-26 16:44:28 +01:00
|
|
|
#include "log.h"
|
2024-06-25 04:34:28 +01:00
|
|
|
|
2024-06-27 10:06:22 +01:00
|
|
|
long login(T_VBVMR_INTERFACE *vmr, int kind)
|
2024-06-25 04:34:28 +01:00
|
|
|
{
|
|
|
|
int rep;
|
2024-06-27 02:51:27 +01:00
|
|
|
long v;
|
2024-06-25 04:34:28 +01:00
|
|
|
|
2024-06-27 10:06:22 +01:00
|
|
|
rep = vmr->VBVMR_Login();
|
2024-06-25 04:34:28 +01:00
|
|
|
if (rep == 1)
|
|
|
|
{
|
2024-06-27 10:06:22 +01:00
|
|
|
run_voicemeeter(vmr, kind);
|
2024-06-25 16:46:35 +01:00
|
|
|
switch (kind)
|
|
|
|
{
|
|
|
|
case BASIC:
|
2024-06-26 16:44:28 +01:00
|
|
|
log_info("Launching Voicemeeter Basic GUI");
|
2024-06-25 16:46:35 +01:00
|
|
|
break;
|
|
|
|
case BANANA:
|
2024-06-26 16:44:28 +01:00
|
|
|
log_info("Launching Voicemeeter Banana GUI");
|
2024-06-25 16:46:35 +01:00
|
|
|
break;
|
|
|
|
case POTATO:
|
2024-06-26 16:44:28 +01:00
|
|
|
log_info("Launching Voicemeeter Potato GUI");
|
2024-06-25 16:46:35 +01:00
|
|
|
break;
|
|
|
|
case POTATOX64:
|
2024-06-26 16:44:28 +01:00
|
|
|
log_info("Launching Voicemeeter Potato x64 GUI");
|
2024-06-25 16:46:35 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2024-06-27 02:51:27 +01:00
|
|
|
time_t endwait;
|
|
|
|
int timeout = 2;
|
|
|
|
|
|
|
|
endwait = time(NULL) + timeout;
|
2024-06-27 03:31:26 +01:00
|
|
|
do
|
2024-06-27 02:51:27 +01:00
|
|
|
{
|
2024-06-27 10:06:22 +01:00
|
|
|
if ((rep = version(vmr, &v)) == 0)
|
2024-06-27 02:51:27 +01:00
|
|
|
break;
|
2024-06-27 03:39:52 +01:00
|
|
|
Sleep(50);
|
2024-06-27 03:31:26 +01:00
|
|
|
} while (time(NULL) < endwait);
|
2024-06-25 04:34:28 +01:00
|
|
|
}
|
2024-06-25 16:46:35 +01:00
|
|
|
if (rep == 0)
|
|
|
|
{
|
2024-06-27 10:06:22 +01:00
|
|
|
version(vmr, &v);
|
2024-06-27 02:51:27 +01:00
|
|
|
long v1 = (v & 0xFF000000) >> 24,
|
|
|
|
v2 = (v & 0x00FF0000) >> 16,
|
|
|
|
v3 = (v & 0x0000FF00) >> 8,
|
|
|
|
v4 = (v & 0x000000FF);
|
|
|
|
char version_s[128];
|
|
|
|
sprintf(version_s, "%i.%i.%i.%i", (int)v1, (int)v2, (int)v3, (int)v4);
|
|
|
|
log_info("Successfully logged into the Voicemeeter API v%s", version_s);
|
2024-06-27 10:06:22 +01:00
|
|
|
clear_dirty(vmr);
|
2024-06-25 16:46:35 +01:00
|
|
|
}
|
2024-06-25 04:34:28 +01:00
|
|
|
return rep;
|
|
|
|
}
|
|
|
|
|
2024-06-27 10:06:22 +01:00
|
|
|
long logout(T_VBVMR_INTERFACE *vmr)
|
2024-06-25 04:34:28 +01:00
|
|
|
{
|
2024-06-26 16:44:28 +01:00
|
|
|
int rep;
|
|
|
|
|
2024-06-25 04:34:28 +01:00
|
|
|
Sleep(20); /* give time for last command */
|
2024-06-27 10:06:22 +01:00
|
|
|
rep = vmr->VBVMR_Logout();
|
2024-06-26 16:44:28 +01:00
|
|
|
if (rep == 0)
|
|
|
|
log_info("Successfully logged out of the Voicemeeter API");
|
|
|
|
return rep;
|
2024-06-25 04:34:28 +01:00
|
|
|
}
|
|
|
|
|
2024-06-27 10:06:22 +01:00
|
|
|
long run_voicemeeter(T_VBVMR_INTERFACE *vmr, int kind)
|
2024-06-25 04:34:28 +01:00
|
|
|
{
|
2024-06-27 01:18:17 +01:00
|
|
|
log_trace("VBVMR_RunVoicemeeter(%d)", kind);
|
2024-06-27 10:06:22 +01:00
|
|
|
return vmr->VBVMR_RunVoicemeeter((long)kind);
|
2024-06-25 04:34:28 +01:00
|
|
|
}
|
|
|
|
|
2024-06-27 10:06:22 +01:00
|
|
|
long type(T_VBVMR_INTERFACE *vmr, long *type)
|
2024-06-25 04:34:28 +01:00
|
|
|
{
|
2024-06-27 03:23:48 +01:00
|
|
|
log_trace("VBVMR_GetVoicemeeterType(<long> *t)");
|
2024-06-27 10:06:22 +01:00
|
|
|
return vmr->VBVMR_GetVoicemeeterType(type);
|
2024-06-25 04:34:28 +01:00
|
|
|
}
|
|
|
|
|
2024-06-27 10:06:22 +01:00
|
|
|
long version(T_VBVMR_INTERFACE *vmr, long *version)
|
2024-06-25 04:34:28 +01:00
|
|
|
{
|
2024-06-27 03:23:48 +01:00
|
|
|
log_trace("VBVMR_GetVoicemeeterVersion(<long> *v)");
|
2024-06-27 10:06:22 +01:00
|
|
|
return vmr->VBVMR_GetVoicemeeterVersion(version);
|
2024-06-25 04:34:28 +01:00
|
|
|
}
|
|
|
|
|
2024-06-27 10:06:22 +01:00
|
|
|
bool is_pdirty(T_VBVMR_INTERFACE *vmr)
|
2024-06-25 04:34:28 +01:00
|
|
|
{
|
2024-06-27 02:51:27 +01:00
|
|
|
log_trace("VBVMR_IsParametersDirty()");
|
2024-06-27 10:06:22 +01:00
|
|
|
return vmr->VBVMR_IsParametersDirty() == 1;
|
2024-06-25 04:34:28 +01:00
|
|
|
}
|
|
|
|
|
2024-06-27 10:06:22 +01:00
|
|
|
long get_parameter_float(T_VBVMR_INTERFACE *vmr, char *param, float *f)
|
2024-06-25 23:32:32 +01:00
|
|
|
{
|
2024-06-27 02:51:27 +01:00
|
|
|
log_trace("VBVMR_GetParameterFloat(%s, <float> *f)", param, f);
|
2024-06-27 10:06:22 +01:00
|
|
|
return vmr->VBVMR_GetParameterFloat(param, f);
|
2024-06-25 23:32:32 +01:00
|
|
|
}
|
|
|
|
|
2024-06-27 23:26:46 +01:00
|
|
|
long get_parameter_string(T_VBVMR_INTERFACE *vmr, char *param, unsigned short *s)
|
2024-06-25 23:32:32 +01:00
|
|
|
{
|
2024-06-27 23:26:46 +01:00
|
|
|
log_trace("VBVMR_GetParameterStringW(%s, <unsigned short> *s)", param, s);
|
|
|
|
return vmr->VBVMR_GetParameterStringW(param, s);
|
2024-06-25 23:32:32 +01:00
|
|
|
}
|
|
|
|
|
2024-06-27 10:06:22 +01:00
|
|
|
long set_parameter_float(T_VBVMR_INTERFACE *vmr, char *param, float val)
|
2024-06-25 23:32:32 +01:00
|
|
|
{
|
2024-06-27 03:23:48 +01:00
|
|
|
log_trace("VBVMR_SetParameterFloat(%s, %.1f)", param, val);
|
2024-06-27 10:06:22 +01:00
|
|
|
return vmr->VBVMR_SetParameterFloat(param, val);
|
2024-06-25 23:32:32 +01:00
|
|
|
}
|
|
|
|
|
2024-06-27 10:06:22 +01:00
|
|
|
long set_parameter_string(T_VBVMR_INTERFACE *vmr, char *param, char *s)
|
2024-06-25 23:32:32 +01:00
|
|
|
{
|
2024-06-27 01:18:17 +01:00
|
|
|
log_trace("VBVMR_SetParameterStringA(%s, %s)", param, s);
|
2024-06-27 10:06:22 +01:00
|
|
|
return vmr->VBVMR_SetParameterStringA(param, s);
|
2024-06-25 23:32:32 +01:00
|
|
|
}
|
|
|
|
|
2024-06-27 10:06:22 +01:00
|
|
|
long set_parameters(T_VBVMR_INTERFACE *vmr, char *command)
|
2024-06-25 04:34:28 +01:00
|
|
|
{
|
2024-06-27 01:18:17 +01:00
|
|
|
log_trace("VBVMR_SetParameters(%s)", command);
|
2024-06-27 10:06:22 +01:00
|
|
|
return vmr->VBVMR_SetParameters(command);
|
2024-06-25 04:34:28 +01:00
|
|
|
}
|
|
|
|
|
2024-06-27 10:06:22 +01:00
|
|
|
bool is_mdirty(T_VBVMR_INTERFACE *vmr)
|
2024-06-25 04:34:28 +01:00
|
|
|
{
|
2024-06-27 10:06:22 +01:00
|
|
|
return vmr->VBVMR_MacroButton_IsDirty() == 1;
|
2024-06-25 04:34:28 +01:00
|
|
|
}
|
|
|
|
|
2024-06-27 10:06:22 +01:00
|
|
|
long macrobutton_getstatus(T_VBVMR_INTERFACE *vmr, long n, float *val, long mode)
|
2024-06-25 04:34:28 +01:00
|
|
|
{
|
2024-06-27 10:06:22 +01:00
|
|
|
return vmr->VBVMR_MacroButton_GetStatus(n, val, mode);
|
2024-06-25 04:34:28 +01:00
|
|
|
}
|
|
|
|
|
2024-06-27 10:06:22 +01:00
|
|
|
long macrobutton_setstatus(T_VBVMR_INTERFACE *vmr, long n, float val, long mode)
|
2024-06-25 04:34:28 +01:00
|
|
|
{
|
2024-06-27 10:06:22 +01:00
|
|
|
return vmr->VBVMR_MacroButton_SetStatus(n, val, mode);
|
2024-06-25 04:34:28 +01:00
|
|
|
}
|
|
|
|
|
2024-06-27 10:06:22 +01:00
|
|
|
void clear_dirty(T_VBVMR_INTERFACE *vmr)
|
2024-06-25 04:34:28 +01:00
|
|
|
{
|
|
|
|
Sleep(30);
|
2024-06-27 10:06:22 +01:00
|
|
|
while (is_pdirty(vmr))
|
2024-06-25 04:34:28 +01:00
|
|
|
Sleep(1);
|
|
|
|
}
|