2022-06-23 14:07:26 +01:00
|
|
|
package voicemeeter
|
|
|
|
|
2022-10-10 18:51:30 +01:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
log "github.com/sirupsen/logrus"
|
|
|
|
)
|
2022-06-28 14:34:03 +01:00
|
|
|
|
2022-07-10 23:08:14 +01:00
|
|
|
// iVban defines the interface vban types must satisfy
|
|
|
|
type iVban interface {
|
2022-12-08 10:23:35 +00:00
|
|
|
On() bool
|
2022-06-23 14:07:26 +01:00
|
|
|
SetOn(val bool)
|
2022-12-08 10:23:35 +00:00
|
|
|
Name() string
|
2022-06-25 04:00:15 +01:00
|
|
|
SetName(val string)
|
2022-12-08 10:23:35 +00:00
|
|
|
Ip() string
|
2022-06-25 04:00:15 +01:00
|
|
|
SetIp(val string)
|
2022-12-08 10:23:35 +00:00
|
|
|
Port() int
|
2022-06-25 04:00:15 +01:00
|
|
|
SetPort(val int)
|
2022-12-08 10:23:35 +00:00
|
|
|
Sr() int
|
2022-06-25 04:00:15 +01:00
|
|
|
SetSr(val int)
|
2022-12-08 10:23:35 +00:00
|
|
|
Channel() int
|
2022-06-25 04:00:15 +01:00
|
|
|
SetChannel(val int)
|
2022-12-08 10:23:35 +00:00
|
|
|
Bit() int
|
2022-06-25 04:00:15 +01:00
|
|
|
SetBit(val int)
|
2022-12-08 10:23:35 +00:00
|
|
|
Quality() int
|
2022-06-25 04:00:15 +01:00
|
|
|
SetQuality(val int)
|
2022-12-08 10:23:35 +00:00
|
|
|
Route() int
|
2022-06-25 04:00:15 +01:00
|
|
|
SetRoute(val int)
|
2022-06-23 14:07:26 +01:00
|
|
|
}
|
|
|
|
|
2022-12-08 19:44:06 +00:00
|
|
|
type stream struct {
|
2022-06-23 14:07:26 +01:00
|
|
|
iRemote
|
|
|
|
}
|
|
|
|
|
2022-12-08 10:23:35 +00:00
|
|
|
// On returns the value of the On parameter
|
2022-12-08 19:44:06 +00:00
|
|
|
func (v *stream) On() bool {
|
2022-06-23 14:07:26 +01:00
|
|
|
return v.getter_bool("On")
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetOn sets the value of the On parameter
|
2022-12-08 19:44:06 +00:00
|
|
|
func (v *stream) SetOn(val bool) {
|
2022-06-23 14:07:26 +01:00
|
|
|
v.setter_bool("On", val)
|
|
|
|
}
|
|
|
|
|
2022-12-08 10:23:35 +00:00
|
|
|
// Name returns the value of the Name parameter
|
2022-12-08 19:44:06 +00:00
|
|
|
func (v *stream) Name() string {
|
2022-06-25 04:00:15 +01:00
|
|
|
return v.getter_string("Name")
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetLabel sets the value of the Name parameter
|
2022-12-08 19:44:06 +00:00
|
|
|
func (v *stream) SetName(val string) {
|
2022-06-25 04:00:15 +01:00
|
|
|
v.setter_string("Name", val)
|
|
|
|
}
|
|
|
|
|
2022-12-08 10:23:35 +00:00
|
|
|
// Ip returns the value of the Ip parameter
|
2022-12-08 19:44:06 +00:00
|
|
|
func (v *stream) Ip() string {
|
2022-06-25 04:00:15 +01:00
|
|
|
return v.getter_string("Ip")
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetIp sets the value of the Ip parameter
|
2022-12-08 19:44:06 +00:00
|
|
|
func (v *stream) SetIp(val string) {
|
2022-06-25 04:00:15 +01:00
|
|
|
v.setter_string("Ip", val)
|
|
|
|
}
|
|
|
|
|
2022-12-08 10:23:35 +00:00
|
|
|
// Port returns the value of the Port parameter
|
2022-12-08 19:44:06 +00:00
|
|
|
func (v *stream) Port() int {
|
2022-06-25 04:00:15 +01:00
|
|
|
return v.getter_int("Port")
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetPort sets the value of the Port parameter
|
2022-12-08 19:44:06 +00:00
|
|
|
func (v *stream) SetPort(val int) {
|
2022-06-25 04:00:15 +01:00
|
|
|
v.setter_int("Port", val)
|
|
|
|
}
|
|
|
|
|
2022-12-08 10:23:35 +00:00
|
|
|
// Sr returns the value of the Sr parameter
|
2022-12-08 19:44:06 +00:00
|
|
|
func (v *stream) Sr() int {
|
2022-06-25 04:00:15 +01:00
|
|
|
return v.getter_int("Sr")
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetSr sets the value of the Sr parameter
|
2022-12-08 19:44:06 +00:00
|
|
|
func (v *stream) SetSr(val int) {
|
2022-06-25 04:00:15 +01:00
|
|
|
v.setter_int("Sr", val)
|
|
|
|
}
|
|
|
|
|
2022-12-08 10:23:35 +00:00
|
|
|
// Channel returns the value of the Channel parameter
|
2022-12-08 19:44:06 +00:00
|
|
|
func (v *stream) Channel() int {
|
2022-06-25 04:00:15 +01:00
|
|
|
return v.getter_int("Channel")
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetChannel sets the value of the Channel parameter
|
2022-12-08 19:44:06 +00:00
|
|
|
func (v *stream) SetChannel(val int) {
|
2022-06-25 04:00:15 +01:00
|
|
|
v.setter_int("Channel", val)
|
|
|
|
}
|
|
|
|
|
2022-12-08 10:23:35 +00:00
|
|
|
// Bit returns the value of the Bit parameter
|
2022-12-08 19:44:06 +00:00
|
|
|
func (v *stream) Bit() int {
|
2022-06-25 04:00:15 +01:00
|
|
|
val := v.getter_int("Bit")
|
|
|
|
if val == 1 {
|
|
|
|
return 16
|
|
|
|
}
|
|
|
|
return 24
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetBit sets the value of the Bit parameter
|
2022-12-08 19:44:06 +00:00
|
|
|
func (v *stream) SetBit(val int) {
|
2022-06-25 04:00:15 +01:00
|
|
|
switch val {
|
|
|
|
case 16:
|
|
|
|
val = 1
|
|
|
|
case 24:
|
|
|
|
val = 2
|
|
|
|
default:
|
2022-10-10 18:51:30 +01:00
|
|
|
log.Warn("expected value 16 or 24")
|
|
|
|
return
|
2022-06-25 04:00:15 +01:00
|
|
|
}
|
|
|
|
v.setter_int("Bit", val)
|
|
|
|
}
|
|
|
|
|
2022-12-08 10:23:35 +00:00
|
|
|
// Quality returns the value of the Quality parameter
|
2022-12-08 19:44:06 +00:00
|
|
|
func (v *stream) Quality() int {
|
2022-06-25 04:00:15 +01:00
|
|
|
return v.getter_int("Quality")
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetQuality sets the value of the Quality parameter
|
2022-12-08 19:44:06 +00:00
|
|
|
func (v *stream) SetQuality(val int) {
|
2022-06-25 04:00:15 +01:00
|
|
|
v.setter_int("Quality", val)
|
|
|
|
}
|
|
|
|
|
2022-12-08 10:23:35 +00:00
|
|
|
// Route returns the value of the Route parameter
|
2022-12-08 19:44:06 +00:00
|
|
|
func (v *stream) Route() int {
|
2022-06-25 04:00:15 +01:00
|
|
|
return v.getter_int("Route")
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetRoute sets the value of the Route parameter
|
2022-12-08 19:44:06 +00:00
|
|
|
func (v *stream) SetRoute(val int) {
|
2022-06-25 04:00:15 +01:00
|
|
|
v.setter_int("Route", val)
|
|
|
|
}
|
|
|
|
|
2022-12-08 19:44:06 +00:00
|
|
|
type VbanInstream struct {
|
|
|
|
stream
|
2022-06-23 14:07:26 +01:00
|
|
|
}
|
|
|
|
|
2022-07-10 23:08:14 +01:00
|
|
|
func newVbanInStream(i int) iVban {
|
2022-12-08 19:44:06 +00:00
|
|
|
vbi := VbanInstream{stream{iRemote{fmt.Sprintf("vban.instream[%d]", i), i}}}
|
2022-12-08 10:23:35 +00:00
|
|
|
return &vbi
|
2022-06-23 14:07:26 +01:00
|
|
|
}
|
|
|
|
|
2022-10-10 18:51:30 +01:00
|
|
|
// SetSr logs a warning reason read only
|
2022-12-08 19:44:06 +00:00
|
|
|
func (vbi *VbanInstream) SetSr(val int) {
|
2022-10-10 18:51:30 +01:00
|
|
|
log.Warn("SR is readonly for vban instreams")
|
2022-06-25 04:00:15 +01:00
|
|
|
}
|
|
|
|
|
2022-10-10 18:51:30 +01:00
|
|
|
// SetChannel logs a warning reason read only
|
2022-12-08 19:44:06 +00:00
|
|
|
func (vbi *VbanInstream) SetChannel(val int) {
|
2022-10-10 18:51:30 +01:00
|
|
|
log.Warn("channel is readonly for vban instreams")
|
2022-06-25 04:00:15 +01:00
|
|
|
}
|
|
|
|
|
2022-10-10 18:51:30 +01:00
|
|
|
// SetBit logs a warning reason read only
|
2022-12-08 19:44:06 +00:00
|
|
|
func (vbi *VbanInstream) SetBit(val int) {
|
2022-10-10 18:51:30 +01:00
|
|
|
log.Warn("bit is readonly for vban instreams")
|
2022-06-25 04:00:15 +01:00
|
|
|
}
|
|
|
|
|
2022-12-08 19:44:06 +00:00
|
|
|
type VbanOutStream struct {
|
|
|
|
stream
|
2022-06-23 14:07:26 +01:00
|
|
|
}
|
|
|
|
|
2022-07-10 23:08:14 +01:00
|
|
|
func newVbanOutStream(i int) iVban {
|
2022-12-08 19:44:06 +00:00
|
|
|
vbo := VbanOutStream{stream{iRemote{fmt.Sprintf("vban.outstream[%d]", i), i}}}
|
2022-12-08 10:23:35 +00:00
|
|
|
return &vbo
|
2022-06-23 14:07:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
type vban struct {
|
2022-07-10 23:08:14 +01:00
|
|
|
InStream []iVban
|
|
|
|
OutStream []iVban
|
2022-06-23 14:07:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func newVban(k *kind) *vban {
|
2022-12-08 10:23:35 +00:00
|
|
|
vbanIn := make([]iVban, k.VbanIn)
|
2022-07-18 16:23:15 +01:00
|
|
|
for i := 0; i < k.VbanIn; i++ {
|
2022-12-08 10:23:35 +00:00
|
|
|
vbanIn[i] = newVbanInStream(i)
|
2022-06-23 14:07:26 +01:00
|
|
|
}
|
2022-12-08 10:23:35 +00:00
|
|
|
vbanOut := make([]iVban, k.VbanOut)
|
2022-07-18 16:23:15 +01:00
|
|
|
for i := 0; i < k.VbanOut; i++ {
|
2022-12-08 10:23:35 +00:00
|
|
|
vbanOut[i] = newVbanOutStream(i)
|
2022-06-23 14:07:26 +01:00
|
|
|
}
|
|
|
|
return &vban{
|
2022-12-08 10:23:35 +00:00
|
|
|
InStream: vbanIn,
|
|
|
|
OutStream: vbanOut,
|
2022-06-23 14:07:26 +01:00
|
|
|
}
|
|
|
|
}
|
2022-06-25 04:00:15 +01:00
|
|
|
|
|
|
|
func (v *vban) Enable() {
|
|
|
|
setParameterFloat("vban.Enable", 1)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (v *vban) Disable() {
|
|
|
|
setParameterFloat("vban.Enable", 0)
|
|
|
|
}
|