2022-06-23 14:03:00 +01:00
|
|
|
package voicemeeter
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2022-12-08 10:27:34 +00:00
|
|
|
|
|
|
|
log "github.com/sirupsen/logrus"
|
2022-06-23 14:03:00 +01:00
|
|
|
)
|
|
|
|
|
2022-12-08 19:45:02 +00:00
|
|
|
// iRemote provides an interface between higher types and functions that
|
|
|
|
// wrap CAPI calls
|
2022-06-23 14:03:00 +01:00
|
|
|
type iRemote struct {
|
|
|
|
_identifier string
|
|
|
|
index int
|
|
|
|
}
|
|
|
|
|
2022-07-10 23:08:14 +01:00
|
|
|
// identifier returns a string identifier
|
2022-06-28 14:34:03 +01:00
|
|
|
func (ir *iRemote) identifier() string {
|
|
|
|
return ir._identifier
|
2022-06-23 14:03:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// getter_bool returns the value of a boolean parameter
|
2022-06-28 14:34:03 +01:00
|
|
|
func (ir *iRemote) getter_bool(p string) bool {
|
|
|
|
param := fmt.Sprintf("%s.%s", ir.identifier(), p)
|
2022-12-08 10:27:34 +00:00
|
|
|
log.Debug("getter_bool::", param)
|
2022-09-07 20:59:55 +01:00
|
|
|
val, err := getParameterFloat(param)
|
|
|
|
if err != nil {
|
|
|
|
fmt.Println(err)
|
|
|
|
}
|
|
|
|
return val == 1
|
2022-06-23 14:03:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// setter_bool sets the value of a boolean parameter
|
2022-06-28 14:34:03 +01:00
|
|
|
func (ir *iRemote) setter_bool(p string, v bool) {
|
|
|
|
param := fmt.Sprintf("%s.%s", ir.identifier(), p)
|
2022-06-23 14:03:00 +01:00
|
|
|
var value float32
|
|
|
|
if v {
|
|
|
|
value = 1
|
|
|
|
} else {
|
|
|
|
value = 0
|
|
|
|
}
|
2022-12-08 10:27:34 +00:00
|
|
|
log.Debug("setter_bool::", param, "=", v)
|
2022-09-14 00:58:05 +01:00
|
|
|
err := setParameterFloat(param, float64(value))
|
2022-09-07 20:59:55 +01:00
|
|
|
if err != nil {
|
|
|
|
fmt.Println(err)
|
|
|
|
}
|
2022-06-23 14:03:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// getter_int returns the value of an int parameter p
|
2022-06-28 14:34:03 +01:00
|
|
|
func (ir *iRemote) getter_int(p string) int {
|
|
|
|
param := fmt.Sprintf("%s.%s", ir.identifier(), p)
|
2022-12-08 10:27:34 +00:00
|
|
|
log.Debug("getter_int::", param)
|
2022-09-07 20:59:55 +01:00
|
|
|
val, err := getParameterFloat(param)
|
|
|
|
if err != nil {
|
|
|
|
fmt.Println(err)
|
|
|
|
}
|
|
|
|
return int(val)
|
2022-06-23 14:03:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// setter_int sets the value v of an int parameter p
|
2022-06-28 14:34:03 +01:00
|
|
|
func (ir *iRemote) setter_int(p string, v int) {
|
|
|
|
param := fmt.Sprintf("%s.%s", ir.identifier(), p)
|
2022-12-08 10:27:34 +00:00
|
|
|
log.Debug("setter_int::", param, "=", v)
|
2022-09-14 00:58:05 +01:00
|
|
|
err := setParameterFloat(param, float64(v))
|
2022-09-07 20:59:55 +01:00
|
|
|
if err != nil {
|
|
|
|
fmt.Println(err)
|
|
|
|
}
|
2022-06-23 14:03:00 +01:00
|
|
|
}
|
|
|
|
|
2022-12-08 10:27:34 +00:00
|
|
|
// getter_float returns the value of a float parameter p
|
2022-06-28 14:34:03 +01:00
|
|
|
func (ir *iRemote) getter_float(p string) float64 {
|
2022-12-08 10:27:34 +00:00
|
|
|
var param string
|
|
|
|
if p != "" {
|
|
|
|
param = fmt.Sprintf("%s.%s", ir.identifier(), p)
|
|
|
|
} else {
|
|
|
|
param = ir.identifier()
|
|
|
|
}
|
|
|
|
log.Debug("getter_float::", param)
|
2022-09-07 20:59:55 +01:00
|
|
|
val, err := getParameterFloat(param)
|
|
|
|
if err != nil {
|
|
|
|
fmt.Println(err)
|
|
|
|
}
|
|
|
|
return val
|
2022-06-23 14:03:00 +01:00
|
|
|
}
|
|
|
|
|
2022-12-08 10:27:34 +00:00
|
|
|
// setter_float sets the value v of an float parameter p
|
2022-09-14 00:58:05 +01:00
|
|
|
func (ir *iRemote) setter_float(p string, v float64) {
|
2022-12-08 10:27:34 +00:00
|
|
|
var param string
|
|
|
|
if p != "" {
|
|
|
|
param = fmt.Sprintf("%s.%s", ir.identifier(), p)
|
|
|
|
} else {
|
|
|
|
param = ir.identifier()
|
|
|
|
}
|
|
|
|
log.Debug("setter_float::", param, "=", v)
|
2022-09-14 00:58:05 +01:00
|
|
|
err := setParameterFloat(param, float64(v))
|
2022-09-07 20:59:55 +01:00
|
|
|
if err != nil {
|
|
|
|
fmt.Println(err)
|
|
|
|
}
|
2022-06-23 14:03:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// getter_string returns the value of a string parameter p
|
2022-06-28 14:34:03 +01:00
|
|
|
func (ir *iRemote) getter_string(p string) string {
|
|
|
|
param := fmt.Sprintf("%s.%s", ir.identifier(), p)
|
2022-12-08 10:27:34 +00:00
|
|
|
log.Debug("getter_string::", param)
|
2022-09-07 20:59:55 +01:00
|
|
|
val, err := getParameterString(param)
|
|
|
|
if err != nil {
|
|
|
|
fmt.Println(err)
|
|
|
|
}
|
|
|
|
return val
|
2022-06-23 14:03:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// setter_string sets the value v of a string parameter p
|
2022-06-28 14:34:03 +01:00
|
|
|
func (ir *iRemote) setter_string(p, v string) {
|
|
|
|
param := fmt.Sprintf("%s.%s", ir.identifier(), p)
|
2022-12-08 10:27:34 +00:00
|
|
|
log.Debug("setter_string::", param, "=", v)
|
2022-09-07 20:59:55 +01:00
|
|
|
err := setParameterString(param, v)
|
|
|
|
if err != nil {
|
|
|
|
fmt.Println(err)
|
|
|
|
}
|
2022-06-23 14:03:00 +01:00
|
|
|
}
|