2023-09-23 22:55:58 +01:00
|
|
|
import ctypes as ct
|
|
|
|
|
|
|
|
from logHandler import log
|
|
|
|
|
|
|
|
from .binds import Binds
|
2023-09-24 17:25:43 +01:00
|
|
|
from .cdll import BITS
|
2023-09-23 22:55:58 +01:00
|
|
|
from .context import Context, StripStrategy
|
|
|
|
from .kinds import KindId
|
|
|
|
|
|
|
|
|
2023-09-24 17:25:43 +01:00
|
|
|
class Controller(Binds):
|
2023-09-23 22:55:58 +01:00
|
|
|
def __init__(self):
|
|
|
|
self.ctx = Context(StripStrategy(self, 0))
|
|
|
|
|
|
|
|
def login(self):
|
2023-09-24 17:25:43 +01:00
|
|
|
retval = self.call(self.bind_login, ok=(0, 1))
|
2023-09-23 22:55:58 +01:00
|
|
|
log.info("INFO - logged into Voicemeeter Remote API")
|
|
|
|
return retval
|
|
|
|
|
|
|
|
def logout(self):
|
2023-09-24 17:25:43 +01:00
|
|
|
self.call(self.bind_logout)
|
2023-09-23 22:55:58 +01:00
|
|
|
log.info("NFO - logged out of Voicemeeter Remote API")
|
|
|
|
|
|
|
|
@property
|
|
|
|
def kind_id(self):
|
|
|
|
c_type = ct.c_long()
|
2023-09-24 17:25:43 +01:00
|
|
|
self.call(self.bind_get_voicemeeter_type, ct.byref(c_type))
|
2023-09-23 22:55:58 +01:00
|
|
|
return KindId(c_type.value).name.lower()
|
|
|
|
|
2023-09-27 15:58:08 +01:00
|
|
|
@property
|
|
|
|
def version(self):
|
|
|
|
ver = ct.c_long()
|
|
|
|
self.call(self.bind_get_voicemeeter_version, ct.byref(ver))
|
|
|
|
return "{}.{}.{}.{}".format(
|
|
|
|
(ver.value & 0xFF000000) >> 24,
|
|
|
|
(ver.value & 0x00FF0000) >> 16,
|
|
|
|
(ver.value & 0x0000FF00) >> 8,
|
|
|
|
ver.value & 0x000000FF,
|
|
|
|
)
|
|
|
|
|
2023-09-23 22:55:58 +01:00
|
|
|
def run_voicemeeter(self, kind_id):
|
|
|
|
val = kind_id.value
|
2023-09-24 17:25:43 +01:00
|
|
|
if val == 3 and BITS == 64:
|
2023-09-23 22:55:58 +01:00
|
|
|
val = 6
|
2023-09-24 17:25:43 +01:00
|
|
|
self.call(self.bind_run_voicemeeter, val)
|
2023-09-23 22:55:58 +01:00
|
|
|
|
|
|
|
def __clear(self):
|
2023-09-24 17:25:43 +01:00
|
|
|
while self.call(self.bind_is_parameters_dirty, ok=(0, 1)) == 1:
|
2023-09-23 22:55:58 +01:00
|
|
|
pass
|
|
|
|
|
|
|
|
def _get(self, param):
|
|
|
|
self.__clear()
|
|
|
|
buf = ct.c_float()
|
2023-09-24 17:25:43 +01:00
|
|
|
self.call(self.bind_get_parameter_float, param.encode(), ct.byref(buf))
|
2023-09-23 22:55:58 +01:00
|
|
|
return buf.value
|
|
|
|
|
|
|
|
def _set(self, param, val):
|
2023-09-24 17:25:43 +01:00
|
|
|
self.call(self.bind_set_parameter_float, param.encode(), ct.c_float(float(val)))
|