mirror of
https://github.com/onyx-and-iris/vmrcli.git
synced 2026-04-07 17:33:33 +00:00
Compare commits
4 Commits
v0.3.0
...
faad5bc2c8
| Author | SHA1 | Date | |
|---|---|---|---|
| faad5bc2c8 | |||
| cc0ec73ef4 | |||
| c45df11286 | |||
| a383aaa36b |
16
README.md
16
README.md
@@ -13,15 +13,16 @@
|
|||||||
## `Use`
|
## `Use`
|
||||||
|
|
||||||
```powershell
|
```powershell
|
||||||
./vmrcli.exe [-h] [-i] [-k] [-D] <api commands>
|
./vmrcli.exe [-h] [-i] [-k] [-D] [-v] <api commands>
|
||||||
```
|
```
|
||||||
|
|
||||||
Where:
|
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.
|
- `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.
|
- `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
|
- `D`: Set log level 0=TRACE, 1=DEBUG, 2=INFO, 3=WARN, 4=ERROR, 5=FATAL
|
||||||
|
- `v`: Enable extra console output (toggle, set messages)
|
||||||
|
|
||||||
## `API Commands`
|
## `API Commands`
|
||||||
|
|
||||||
@@ -74,14 +75,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/).
|
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`
|
`make LOG_USE_COLOR=no`
|
||||||
|
|
||||||
## `Official Documentation`
|
## `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`
|
## `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
|
||||||
|
|||||||
13
src/util.c
13
src/util.c
@@ -3,6 +3,11 @@
|
|||||||
#include "vmr.h"
|
#include "vmr.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Removes the last part of a path
|
||||||
|
*
|
||||||
|
* @param szPath
|
||||||
|
*/
|
||||||
void remove_name_in_path(char *szPath)
|
void remove_name_in_path(char *szPath)
|
||||||
{
|
{
|
||||||
char *p = szPath;
|
char *p = szPath;
|
||||||
@@ -57,6 +62,14 @@ int replace_multiple_space_with_one(char *s, size_t len)
|
|||||||
return j;
|
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 *kind_as_string(char *s, enum kind kind, int n)
|
||||||
{
|
{
|
||||||
char *kinds[] = {
|
char *kinds[] = {
|
||||||
|
|||||||
16
src/vmr.c
16
src/vmr.c
@@ -8,6 +8,15 @@
|
|||||||
#define VERSION_STR_LEN 128
|
#define VERSION_STR_LEN 128
|
||||||
#define KIND_STR_LEN 64
|
#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)
|
long login(T_VBVMR_INTERFACE *vmr, int kind)
|
||||||
{
|
{
|
||||||
int rep;
|
int rep;
|
||||||
@@ -45,6 +54,13 @@ long login(T_VBVMR_INTERFACE *vmr, int kind)
|
|||||||
return rep;
|
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)
|
long logout(T_VBVMR_INTERFACE *vmr)
|
||||||
{
|
{
|
||||||
int rep;
|
int rep;
|
||||||
|
|||||||
55
src/vmrcli.c
55
src/vmrcli.c
@@ -9,12 +9,21 @@
|
|||||||
|
|
||||||
#define MAX_LINE 512
|
#define MAX_LINE 512
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief An enum used to define the kind of value
|
||||||
|
* a 'get' call returns.
|
||||||
|
*
|
||||||
|
*/
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
FLOAT_T,
|
FLOAT_T,
|
||||||
STRING_T,
|
STRING_T,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief A struct holding the result of a get call.
|
||||||
|
*
|
||||||
|
*/
|
||||||
struct result
|
struct result
|
||||||
{
|
{
|
||||||
int type;
|
int type;
|
||||||
@@ -116,7 +125,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief prints the help dialogue
|
* @brief prints the help message
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void help()
|
void help()
|
||||||
@@ -124,11 +133,11 @@ void help()
|
|||||||
puts(
|
puts(
|
||||||
"Usage: ./vmrcli.exe [-h] [-i] [-k] [-D] [-v] <api commands>\n"
|
"Usage: ./vmrcli.exe [-h] [-i] [-k] [-D] [-v] <api commands>\n"
|
||||||
"Where: \n"
|
"Where: \n"
|
||||||
"\th: Prints the help dialogue\n"
|
"\th: Prints the help message\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"
|
||||||
"\tD: Set log level 0=TRACE, 1=DEBUG, 2=INFO, 3=WARN, 4=ERROR, 5=FATAL"
|
"\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");
|
"\tv: Enable extra console output (toggle, set messages)");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -167,6 +176,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 init_voicemeeter(T_VBVMR_INTERFACE *vmr, int kind)
|
||||||
{
|
{
|
||||||
int rep = initialize_dll_interfaces(vmr);
|
int rep = initialize_dll_interfaces(vmr);
|
||||||
@@ -193,6 +210,13 @@ int init_voicemeeter(T_VBVMR_INTERFACE *vmr, int kind)
|
|||||||
return 0;
|
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)
|
void interactive(T_VBVMR_INTERFACE *vmr)
|
||||||
{
|
{
|
||||||
char input[MAX_LINE];
|
char input[MAX_LINE];
|
||||||
@@ -213,6 +237,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)
|
void parse_input(T_VBVMR_INTERFACE *vmr, char *input, int len)
|
||||||
{
|
{
|
||||||
char *token;
|
char *token;
|
||||||
@@ -226,6 +258,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)
|
void parse_command(T_VBVMR_INTERFACE *vmr, char *command)
|
||||||
{
|
{
|
||||||
log_debug("Parsing %s", command);
|
log_debug("Parsing %s", command);
|
||||||
@@ -279,6 +319,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)
|
void get(T_VBVMR_INTERFACE *vmr, char *command, struct result *res)
|
||||||
{
|
{
|
||||||
clear_dirty(vmr);
|
clear_dirty(vmr);
|
||||||
|
|||||||
Reference in New Issue
Block a user