mirror of
https://github.com/onyx-and-iris/vmrcli.git
synced 2026-04-07 17:33:33 +00:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4b64ae95fd | |||
| f8d2f80cbf | |||
| 4b79b7f849 | |||
| 3ec98ea391 | |||
| faad5bc2c8 | |||
| cc0ec73ef4 | |||
| c45df11286 | |||
| a383aaa36b |
24
README.md
24
README.md
@@ -13,28 +13,31 @@
|
||||
## `Use`
|
||||
|
||||
```powershell
|
||||
./vmrcli.exe [-h] [-i] [-k] [-D] <api commands>
|
||||
./vmrcli.exe [-h] [-i] [-k] [-D] [-v] [-m] [-s] <api commands>
|
||||
```
|
||||
|
||||
Where:
|
||||
|
||||
- `h`: Prints the help dialogue.
|
||||
- `h`: Prints the help message.
|
||||
- `i`: Enable interactive mode. If set, any api commands passed on the command line will be ignored.
|
||||
- `k`: The kind of Voicemeeter (basic, banana or potato). Use this to launch the GUI.
|
||||
- `D`: Set log level 0=TRACE, 1=DEBUG, 2=INFO, 3=WARN, 4=ERROR, 5=FATAL
|
||||
- `v`: Enable extra console output (toggle, set messages)
|
||||
- `m`: Launch the MacroButtons application
|
||||
- `s`: Launch the StreamerView application
|
||||
|
||||
## `API Commands`
|
||||
|
||||
- Commands starting with `!` will be toggled, use it with boolean parameters.
|
||||
- Commands containing `=` will set a value.
|
||||
- Commands containing `=` will set a value. (use `+=` and `-=` to increment/decrement)
|
||||
- All other commands with get a value.
|
||||
|
||||
Examples:
|
||||
|
||||
Launch basic GUI, set log level to INFO, Toggle Strip 0 Mute, then print its new value
|
||||
Launch basic GUI, set log level to INFO, Toggle Strip 0 Mute, print its new value, then decrease Bus 0 Gain by 3.8
|
||||
|
||||
```powershell
|
||||
./vmrcli.exe -kbasic -D2 !strip[0].mute strip[0].mute
|
||||
./vmrcli.exe -kbasic -D2 !strip[0].mute strip[0].mute bus[0].gain-=3.8
|
||||
```
|
||||
|
||||
Launch banana GUI, set log level to DEBUG, set Strip 0 label to podmic then print Strip 2 label
|
||||
@@ -74,14 +77,19 @@ Multiple API commands can be in a single line but they should be space separated
|
||||
|
||||
Run the included `makefile` with [GNU Make](https://www.gnu.org/software/make/).
|
||||
|
||||
By default the log.c module is built with coloured logging enabled. To disable this you can override the `LOG_USE_COLOR` variable, for example:
|
||||
The binary in [Releases][releases] is compiled with coloured logging enabled. To disable this you can override the `LOG_USE_COLOR` variable, for example:
|
||||
|
||||
`make LOG_USE_COLOR=no`
|
||||
|
||||
## `Official Documentation`
|
||||
|
||||
- [Voicemeeter Remote C API](https://github.com/onyx-and-iris/Voicemeeter-SDK/blob/main/VoicemeeterRemoteAPI.pdf)
|
||||
- [Voicemeeter Remote C API][remoteapi-docs]
|
||||
|
||||
## `Special Thanks`
|
||||
|
||||
- [rxi](https://github.com/rxi) for writing the [log.c](https://github.com/rxi/log.c) package
|
||||
- [rxi][rxi-user] for writing the [log.c][log-c] package
|
||||
|
||||
[releases]: https://github.com/onyx-and-iris/vmrcli/releases
|
||||
[remoteapi-docs]: https://github.com/onyx-and-iris/Voicemeeter-SDK/blob/main/VoicemeeterRemoteAPI.pdf
|
||||
[rxi-user]: https://github.com/rxi
|
||||
[log-c]: https://github.com/rxi/log.c
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
strip[0].mute !strip[0].mute strip[0].mute strip[0].gain strip[0].label=podmic strip[0].label
|
||||
strip[1].mute=1 strip[1].mute
|
||||
bus[0].label bus[0].gain=-8.3
|
||||
strip[1].mute=1 strip[1].mute strip[1].limit-=8
|
||||
strip[2].gain-=5 strip[2].comp+=4.8
|
||||
bus[0].label
|
||||
bus[1].gain-=5.8
|
||||
@@ -12,6 +12,8 @@ enum kind
|
||||
BASICX64,
|
||||
BANANAX64,
|
||||
POTATOX64,
|
||||
MACROBUTTONS = 11,
|
||||
STREAMERVIEW
|
||||
};
|
||||
|
||||
long login(T_VBVMR_INTERFACE *vmr, int kind);
|
||||
|
||||
13
src/util.c
13
src/util.c
@@ -3,6 +3,11 @@
|
||||
#include "vmr.h"
|
||||
#include "util.h"
|
||||
|
||||
/**
|
||||
* @brief Removes the last part of a path
|
||||
*
|
||||
* @param szPath
|
||||
*/
|
||||
void remove_name_in_path(char *szPath)
|
||||
{
|
||||
char *p = szPath;
|
||||
@@ -57,6 +62,14 @@ int replace_multiple_space_with_one(char *s, size_t len)
|
||||
return j;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param s Pointer to a character buffer
|
||||
* @param kind The kind of Voicemeeter.
|
||||
* @param n maximum number of characters to be written to the buffer
|
||||
* @return char* The kind of Voicemeeter as a string
|
||||
*/
|
||||
char *kind_as_string(char *s, enum kind kind, int n)
|
||||
{
|
||||
char *kinds[] = {
|
||||
|
||||
34
src/vmr.c
34
src/vmr.c
@@ -8,6 +8,15 @@
|
||||
#define VERSION_STR_LEN 128
|
||||
#define KIND_STR_LEN 64
|
||||
|
||||
/**
|
||||
* @brief Logs into the API.
|
||||
* Tests for valid connection for up to 2 seconds.
|
||||
* If successful initializes the dirty parameters.
|
||||
*
|
||||
* @param vmr
|
||||
* @param kind
|
||||
* @return long
|
||||
*/
|
||||
long login(T_VBVMR_INTERFACE *vmr, int kind)
|
||||
{
|
||||
int rep;
|
||||
@@ -21,30 +30,37 @@ long login(T_VBVMR_INTERFACE *vmr, int kind)
|
||||
log_info(
|
||||
"Launching Voicemeeter %s GUI",
|
||||
kind_as_string(kind_s, kind, KIND_STR_LEN));
|
||||
}
|
||||
|
||||
time_t endwait;
|
||||
int timeout = 2;
|
||||
|
||||
endwait = time(NULL) + timeout;
|
||||
time_t start = time(NULL);
|
||||
do
|
||||
{
|
||||
if ((rep = version(vmr, &v)) == 0)
|
||||
break;
|
||||
Sleep(50);
|
||||
} while (time(NULL) < endwait);
|
||||
}
|
||||
if (rep == 0)
|
||||
{
|
||||
version(vmr, &v);
|
||||
char version_s[VERSION_STR_LEN];
|
||||
log_info(
|
||||
"Successfully logged into the Voicemeeter API v%s",
|
||||
version_as_string(version_s, v, VERSION_STR_LEN));
|
||||
break;
|
||||
}
|
||||
Sleep(50);
|
||||
} while (time(NULL) < start + timeout);
|
||||
|
||||
if (rep == 0)
|
||||
{
|
||||
clear_dirty(vmr);
|
||||
}
|
||||
return rep;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Logs out of the API giving a short wait to allow a
|
||||
* final instruction to complete.
|
||||
*
|
||||
* @param vmr The API interface as a struct
|
||||
* @return long VBVMR_Logout return value
|
||||
*/
|
||||
long logout(T_VBVMR_INTERFACE *vmr)
|
||||
{
|
||||
int rep;
|
||||
|
||||
93
src/vmrcli.c
93
src/vmrcli.c
@@ -9,12 +9,21 @@
|
||||
|
||||
#define MAX_LINE 512
|
||||
|
||||
/**
|
||||
* @brief An enum used to define the kind of value
|
||||
* a 'get' call returns.
|
||||
*
|
||||
*/
|
||||
enum
|
||||
{
|
||||
FLOAT_T,
|
||||
STRING_T,
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief A struct holding the result of a get call.
|
||||
*
|
||||
*/
|
||||
struct result
|
||||
{
|
||||
int type;
|
||||
@@ -38,6 +47,8 @@ bool vflag = false;
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
bool iflag = false;
|
||||
bool mflag = false;
|
||||
bool sflag = false;
|
||||
int opt;
|
||||
char *kvalue = "";
|
||||
int dvalue;
|
||||
@@ -51,20 +62,26 @@ int main(int argc, char *argv[])
|
||||
|
||||
log_set_level(LOG_WARN);
|
||||
|
||||
while ((opt = getopt(argc, argv, "k:ihD:v")) != -1)
|
||||
while ((opt = getopt(argc, argv, "hk:msiD:v")) != -1)
|
||||
{
|
||||
switch (opt)
|
||||
{
|
||||
case 'i':
|
||||
iflag = true;
|
||||
break;
|
||||
case 'h':
|
||||
help();
|
||||
exit(EXIT_SUCCESS);
|
||||
case 'k':
|
||||
kvalue = optarg;
|
||||
kind = set_kind(kvalue);
|
||||
break;
|
||||
case 'h':
|
||||
help();
|
||||
exit(EXIT_SUCCESS);
|
||||
case 'm':
|
||||
mflag = true;
|
||||
break;
|
||||
case 's':
|
||||
sflag = true;
|
||||
break;
|
||||
case 'i':
|
||||
iflag = true;
|
||||
break;
|
||||
case 'D':
|
||||
dvalue = atoi(optarg);
|
||||
if (dvalue >= LOG_TRACE && dvalue <= LOG_FATAL)
|
||||
@@ -95,6 +112,18 @@ int main(int argc, char *argv[])
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (mflag)
|
||||
{
|
||||
log_info("MacroButtons app launched");
|
||||
run_voicemeeter(vmr, MACROBUTTONS);
|
||||
}
|
||||
|
||||
if (sflag)
|
||||
{
|
||||
log_info("StreamerView app launched");
|
||||
run_voicemeeter(vmr, STREAMERVIEW);
|
||||
}
|
||||
|
||||
if (iflag)
|
||||
{
|
||||
puts("Interactive mode enabled. Enter 'Q' to exit.");
|
||||
@@ -116,19 +145,21 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief prints the help dialogue
|
||||
* @brief prints the help message
|
||||
*
|
||||
*/
|
||||
void help()
|
||||
{
|
||||
puts(
|
||||
"Usage: ./vmrcli.exe [-h] [-i] [-k] [-D] [-v] <api commands>\n"
|
||||
"Usage: ./vmrcli.exe [-h] [-i] [-k] [-D] [-v] [-m] [-s] <api commands>\n"
|
||||
"Where: \n"
|
||||
"\th: Prints the help dialogue\n"
|
||||
"\th: Prints the help message\n"
|
||||
"\ti: Enable interactive mode\n"
|
||||
"\tk: The kind of Voicemeeter (basic, banana, potato)\n"
|
||||
"\tD: Set log level 0=TRACE, 1=DEBUG, 2=INFO, 3=WARN, 4=ERROR, 5=FATAL"
|
||||
"\tv: Enable extra console output (toggle, set messages)\n");
|
||||
"\tD: Set log level 0=TRACE, 1=DEBUG, 2=INFO, 3=WARN, 4=ERROR, 5=FATAL\n"
|
||||
"\tv: Enable extra console output (toggle, set messages)\n"
|
||||
"\tm: Launch the MacroButtons application\n"
|
||||
"\tm: Launch the StreamerView application");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -167,6 +198,14 @@ enum kind set_kind(char *kval)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Defines the DLL interface as a struct.
|
||||
* Logs into the API.
|
||||
*
|
||||
* @param vmr The API interface as a struct
|
||||
* @param kind
|
||||
* @return int
|
||||
*/
|
||||
int init_voicemeeter(T_VBVMR_INTERFACE *vmr, int kind)
|
||||
{
|
||||
int rep = initialize_dll_interfaces(vmr);
|
||||
@@ -193,6 +232,13 @@ int init_voicemeeter(T_VBVMR_INTERFACE *vmr, int kind)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Continuously read lines from stdin.
|
||||
* Break if 'Q' is entered on the interactive prompt.
|
||||
* Each line is passed to parse_input()
|
||||
*
|
||||
* @param vmr The API interface as a struct
|
||||
*/
|
||||
void interactive(T_VBVMR_INTERFACE *vmr)
|
||||
{
|
||||
char input[MAX_LINE];
|
||||
@@ -213,6 +259,14 @@ void interactive(T_VBVMR_INTERFACE *vmr)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Walks through each line split by a space delimiter.
|
||||
* Each token is passed to parse_command()
|
||||
*
|
||||
* @param vmr The API interface as a struct
|
||||
* @param input Each input line, from stdin or CLI args
|
||||
* @param len The length of the input line
|
||||
*/
|
||||
void parse_input(T_VBVMR_INTERFACE *vmr, char *input, int len)
|
||||
{
|
||||
char *token;
|
||||
@@ -226,6 +280,14 @@ void parse_input(T_VBVMR_INTERFACE *vmr, char *input, int len)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Execute each command according to type.
|
||||
* See command type definitions in:
|
||||
* https://github.com/onyx-and-iris/vmrcli?tab=readme-ov-file#api-commands
|
||||
*
|
||||
* @param vmr The API interface as a struct
|
||||
* @param command Each token from the input line as its own command string
|
||||
*/
|
||||
void parse_command(T_VBVMR_INTERFACE *vmr, char *command)
|
||||
{
|
||||
log_debug("Parsing %s", command);
|
||||
@@ -279,6 +341,13 @@ void parse_command(T_VBVMR_INTERFACE *vmr, char *command)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param vmr The API interface as a struct
|
||||
* @param command A parsed 'get' command as a string
|
||||
* @param res A struct holding the result of the API call.
|
||||
*/
|
||||
void get(T_VBVMR_INTERFACE *vmr, char *command, struct result *res)
|
||||
{
|
||||
clear_dirty(vmr);
|
||||
|
||||
Reference in New Issue
Block a user