12 Commits

Author SHA1 Message Date
35ec276979 add login timeout
print the API version to info string
2024-06-27 02:51:27 +01:00
744f0d64df print float values to 1 dp 2024-06-27 02:00:17 +01:00
760924def8 upd README 2024-06-27 01:18:25 +01:00
7b7d4fc2c7 add log trace messages to vmr.c 2024-06-27 01:18:17 +01:00
0b6e0800ce default log level to LOG_WARN
write message to stderr if -D flag out of range
2024-06-27 01:17:59 +01:00
4488a386b8 move includes into header guards 2024-06-27 01:17:09 +01:00
9863ca6dca remove EOF check 2024-06-26 20:17:33 +01:00
cd11b26ad8 add -D flag to help() output 2024-06-26 19:31:08 +01:00
71e06ac646 fix script files example 2024-06-26 19:03:21 +01:00
050a4d9e60 add link to api documentation 2024-06-26 18:37:52 +01:00
694a4dbc65 add ./ 2024-06-26 18:34:05 +01:00
3f8ed17176 reword 2024-06-26 18:30:47 +01:00
5 changed files with 60 additions and 22 deletions

View File

@@ -28,22 +28,26 @@ Where:
Examples: Examples:
Launch basic GUI, set debug level to INFO, Toggle Strip 0 Mute, then print its new value Launch basic GUI, set log level to INFO, Toggle Strip 0 Mute, then print its new value
`./vmrcli.exe -kbasic -D2 !strip[0].mute strip[0].mute` `./vmrcli.exe -kbasic -D2 !strip[0].mute strip[0].mute`
Launch banana GUI, set debug level to DEBUG, set Strip 0 label to podmic then print Strip 2 label Launch banana GUI, set log level to DEBUG, set Strip 0 label to podmic then print Strip 2 label
`vmrcli.exe -kbanana -D1 strip[0].label=podmic strip[2].label` `./vmrcli.exe -kbanana -D1 strip[0].label=podmic strip[2].label`
## `Script files` ## `Script files`
Scripts can be loaded from text files, for example: Scripts can be loaded from text files, for example in Powershell:
```powershell ```powershell
./vbantxt-cli -D1 $(Get-Content .\example_commands.txt) ./vmrcli.exe -D1 $(Get-Content .\example_commands.txt)
``` ```
## `Official Documentation`
- [Voicemeeter Remote C API](https://github.com/onyx-and-iris/Voicemeeter-SDK/blob/main/VoicemeeterRemoteAPI.pdf)
## `Special Thanks` ## `Special Thanks`
- [rxi](https://github.com/rxi) for writing the [log.c](https://github.com/rxi/log.c) package - [rxi](https://github.com/rxi) for writing the [log.c](https://github.com/rxi/log.c) package

View File

@@ -1,9 +1,9 @@
#include <windows.h>
#include "VoicemeeterRemote.h"
#ifndef __CDLL_H__ #ifndef __CDLL_H__
#define __CDLL_H__ #define __CDLL_H__
#include <windows.h>
#include "VoicemeeterRemote.h"
long initialize_dll_interfaces(T_VBVMR_INTERFACE *iVMR); long initialize_dll_interfaces(T_VBVMR_INTERFACE *iVMR);
#endif /*__CDLL_H__*/ #endif /*__CDLL_H__*/

View File

@@ -1,9 +1,9 @@
#include <stdbool.h>
#include "voicemeeterRemote.h"
#ifndef __VMR_H__ #ifndef __VMR_H__
#define __VMR_H__ #define __VMR_H__
#include <stdbool.h>
#include "voicemeeterRemote.h"
enum kind enum kind
{ {
BASIC = 1, BASIC = 1,

View File

@@ -1,17 +1,19 @@
#include <windows.h> #include <windows.h>
#include <stdio.h> #include <stdio.h>
#include <time.h>
#include "vmr.h" #include "vmr.h"
#include "log.h" #include "log.h"
long login(T_VBVMR_INTERFACE *iVMR, int kind) long login(T_VBVMR_INTERFACE *iVMR, int kind)
{ {
int rep; int rep;
long v;
rep = iVMR->VBVMR_Login(); rep = iVMR->VBVMR_Login();
Sleep(20); Sleep(20);
if (rep == 1) if (rep == 1)
{ {
rep = run_voicemeeter(iVMR, kind); run_voicemeeter(iVMR, kind);
switch (kind) switch (kind)
{ {
case BASIC: case BASIC:
@@ -28,11 +30,27 @@ long login(T_VBVMR_INTERFACE *iVMR, int kind)
break; break;
} }
Sleep(1200); time_t endwait;
int timeout = 2;
endwait = time(NULL) + timeout;
while (time(NULL) < endwait)
{
if ((rep = version(iVMR, &v)) == 0)
break;
Sleep(20);
}
} }
if (rep == 0) if (rep == 0)
{ {
log_info("Successfully logged into the Voicemeeter API"); version(iVMR, &v);
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);
clear_dirty(iVMR); clear_dirty(iVMR);
} }
return rep; return rep;
@@ -51,6 +69,7 @@ long logout(T_VBVMR_INTERFACE *iVMR)
long run_voicemeeter(T_VBVMR_INTERFACE *iVMR, int kind) long run_voicemeeter(T_VBVMR_INTERFACE *iVMR, int kind)
{ {
log_trace("VBVMR_RunVoicemeeter(%d)", kind);
return iVMR->VBVMR_RunVoicemeeter((long)kind); return iVMR->VBVMR_RunVoicemeeter((long)kind);
} }
@@ -61,36 +80,43 @@ long type(T_VBVMR_INTERFACE *iVMR, long *type)
long version(T_VBVMR_INTERFACE *iVMR, long *version) long version(T_VBVMR_INTERFACE *iVMR, long *version)
{ {
return iVMR->VBVMR_GetVoicemeeterType(version); log_trace("VBVMR_GetVoicemeeterType(<long> *v)");
return iVMR->VBVMR_GetVoicemeeterVersion(version);
} }
bool is_pdirty(T_VBVMR_INTERFACE *iVMR) bool is_pdirty(T_VBVMR_INTERFACE *iVMR)
{ {
log_trace("VBVMR_IsParametersDirty()");
return iVMR->VBVMR_IsParametersDirty() == 1; return iVMR->VBVMR_IsParametersDirty() == 1;
} }
long get_parameter_float(T_VBVMR_INTERFACE *iVMR, char *param, float *f) long get_parameter_float(T_VBVMR_INTERFACE *iVMR, char *param, float *f)
{ {
log_trace("VBVMR_GetParameterFloat(%s, <float> *f)", param, f);
return iVMR->VBVMR_GetParameterFloat(param, f); return iVMR->VBVMR_GetParameterFloat(param, f);
} }
long get_parameter_string(T_VBVMR_INTERFACE *iVMR, char *param, char *s) long get_parameter_string(T_VBVMR_INTERFACE *iVMR, char *param, char *s)
{ {
log_trace("VBVMR_GetParameterStringA(%s, <char> *s)", param, s);
return iVMR->VBVMR_GetParameterStringA(param, s); return iVMR->VBVMR_GetParameterStringA(param, s);
} }
long set_parameter_float(T_VBVMR_INTERFACE *iVMR, char *param, float val) long set_parameter_float(T_VBVMR_INTERFACE *iVMR, char *param, float val)
{ {
log_trace("VBVMR_SetParameterFloat(%s, %.2f)", param, val);
return iVMR->VBVMR_SetParameterFloat(param, val); return iVMR->VBVMR_SetParameterFloat(param, val);
} }
long set_parameter_string(T_VBVMR_INTERFACE *iVMR, char *param, char *s) long set_parameter_string(T_VBVMR_INTERFACE *iVMR, char *param, char *s)
{ {
log_trace("VBVMR_SetParameterStringA(%s, %s)", param, s);
return iVMR->VBVMR_SetParameterStringA(param, s); return iVMR->VBVMR_SetParameterStringA(param, s);
} }
long set_parameters(T_VBVMR_INTERFACE *iVMR, char *command) long set_parameters(T_VBVMR_INTERFACE *iVMR, char *command)
{ {
log_trace("VBVMR_SetParameters(%s)", command);
return iVMR->VBVMR_SetParameters(command); return iVMR->VBVMR_SetParameters(command);
} }

View File

@@ -42,10 +42,10 @@ int main(int argc, char *argv[])
if (argc == 1) if (argc == 1)
{ {
help(); help();
return EXIT_SUCCESS; exit(EXIT_SUCCESS);
} }
log_set_level(LOG_INFO); log_set_level(LOG_WARN);
while ((opt = getopt(argc, argv, "k:ihD:")) != -1) while ((opt = getopt(argc, argv, "k:ihD:")) != -1)
{ {
@@ -62,10 +62,18 @@ int main(int argc, char *argv[])
help(); help();
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
case 'D': case 'D':
if ((dvalue = atoi(optarg)) && dvalue >= LOG_TRACE && dvalue <= LOG_FATAL) dvalue = atoi(optarg);
if (dvalue >= LOG_TRACE && dvalue <= LOG_FATAL)
{ {
log_set_level(dvalue); log_set_level(dvalue);
} }
else
{
fputs(
"-D arg out of range, expected value from 0 up to 5\n"
"Log level will default to LOG_WARN (3).\n",
stderr);
}
break; break;
default: default:
abort(); abort();
@@ -104,7 +112,7 @@ int main(int argc, char *argv[])
void help() void help()
{ {
puts( puts(
"Usage: ./vmrcli.exe [-i] [-k] <api commands>\n" "Usage: ./vmrcli.exe [-i] [-k] [-D] <api commands>\n"
"Where: \n" "Where: \n"
"\ti: Enable interactive mode\n" "\ti: Enable interactive mode\n"
"\tk: The kind of Voicemeeter (basic, banana, potato)\n" "\tk: The kind of Voicemeeter (basic, banana, potato)\n"
@@ -177,7 +185,7 @@ void interactive(T_VBVMR_INTERFACE *vmr)
char command[MAX_LINE]; char command[MAX_LINE];
int i = 0; int i = 0;
while (!isspace(*p) && *p != EOF) while (!isspace(*p))
command[i++] = *p++; command[i++] = *p++;
command[i] = '\0'; command[i] = '\0';
p++; /* shift to next char */ p++; /* shift to next char */
@@ -218,13 +226,13 @@ void parse_command(T_VBVMR_INTERFACE *vmr, char *command)
switch (res.type) switch (res.type)
{ {
case FLOAT_T: case FLOAT_T:
printf("%.2f\n", res.val.f); printf("%.1f\n", res.val.f);
break; break;
case STRING_T: case STRING_T:
puts(res.val.s); puts(res.val.s);
break; break;
default: default:
fputs("Unknown result...", stderr); fputs("Unexpected result type", stderr);
break; break;
} }
} }