voicemeeter/vban.go
onyx-and-iris b116f04f51 Get prefix removed from getters
True for Bus, Strip, Vban and Output types.

Bus[i].Eq() and Strip[i].Eq() now return pointers to eQ structs.
This makes it easier to extend Eq types in future if desired.

Strip[i].Comp()  now return pointer to comp struct
Strip[i].Gain() now return pointer to gain struct
This is to support the new API features in Potato 3.0.2.8

Removed casting in factory function return statements.
Since types are satisfied implicitly.

eQ struct type tests added
2022-12-08 10:23:35 +00:00

198 lines
3.9 KiB
Go

package voicemeeter
import (
"fmt"
log "github.com/sirupsen/logrus"
)
// iVban defines the interface vban types must satisfy
type iVban interface {
On() bool
SetOn(val bool)
Name() string
SetName(val string)
Ip() string
SetIp(val string)
Port() int
SetPort(val int)
Sr() int
SetSr(val int)
Channel() int
SetChannel(val int)
Bit() int
SetBit(val int)
Quality() int
SetQuality(val int)
Route() int
SetRoute(val int)
}
type vbanStream struct {
iRemote
}
// On returns the value of the On parameter
func (v *vbanStream) On() bool {
return v.getter_bool("On")
}
// SetOn sets the value of the On parameter
func (v *vbanStream) SetOn(val bool) {
v.setter_bool("On", val)
}
// Name returns the value of the Name parameter
func (v *vbanStream) Name() string {
return v.getter_string("Name")
}
// SetLabel sets the value of the Name parameter
func (v *vbanStream) SetName(val string) {
v.setter_string("Name", val)
}
// Ip returns the value of the Ip parameter
func (v *vbanStream) Ip() string {
return v.getter_string("Ip")
}
// SetIp sets the value of the Ip parameter
func (v *vbanStream) SetIp(val string) {
v.setter_string("Ip", val)
}
// Port returns the value of the Port parameter
func (v *vbanStream) Port() int {
return v.getter_int("Port")
}
// SetPort sets the value of the Port parameter
func (v *vbanStream) SetPort(val int) {
v.setter_int("Port", val)
}
// Sr returns the value of the Sr parameter
func (v *vbanStream) Sr() int {
return v.getter_int("Sr")
}
// SetSr sets the value of the Sr parameter
func (v *vbanStream) SetSr(val int) {
v.setter_int("Sr", val)
}
// Channel returns the value of the Channel parameter
func (v *vbanStream) Channel() int {
return v.getter_int("Channel")
}
// SetChannel sets the value of the Channel parameter
func (v *vbanStream) SetChannel(val int) {
v.setter_int("Channel", val)
}
// Bit returns the value of the Bit parameter
func (v *vbanStream) Bit() int {
val := v.getter_int("Bit")
if val == 1 {
return 16
}
return 24
}
// SetBit sets the value of the Bit parameter
func (v *vbanStream) SetBit(val int) {
switch val {
case 16:
val = 1
case 24:
val = 2
default:
log.Warn("expected value 16 or 24")
return
}
v.setter_int("Bit", val)
}
// Quality returns the value of the Quality parameter
func (v *vbanStream) Quality() int {
return v.getter_int("Quality")
}
// SetQuality sets the value of the Quality parameter
func (v *vbanStream) SetQuality(val int) {
v.setter_int("Quality", val)
}
// Route returns the value of the Route parameter
func (v *vbanStream) Route() int {
return v.getter_int("Route")
}
// SetRoute sets the value of the Route parameter
func (v *vbanStream) SetRoute(val int) {
v.setter_int("Route", val)
}
type vbanInStream struct {
vbanStream
}
func newVbanInStream(i int) iVban {
vbi := vbanInStream{vbanStream{iRemote{fmt.Sprintf("vban.instream[%d]", i), i}}}
return &vbi
}
// SetSr logs a warning reason read only
func (vbi *vbanInStream) SetSr(val int) {
log.Warn("SR is readonly for vban instreams")
}
// SetChannel logs a warning reason read only
func (vbi *vbanInStream) SetChannel(val int) {
log.Warn("channel is readonly for vban instreams")
}
// SetBit logs a warning reason read only
func (vbi *vbanInStream) SetBit(val int) {
log.Warn("bit is readonly for vban instreams")
}
type vbanOutStream struct {
vbanStream
}
func newVbanOutStream(i int) iVban {
vbo := vbanOutStream{vbanStream{iRemote{fmt.Sprintf("vban.outstream[%d]", i), i}}}
return &vbo
}
type vban struct {
InStream []iVban
OutStream []iVban
}
func newVban(k *kind) *vban {
vbanIn := make([]iVban, k.VbanIn)
for i := 0; i < k.VbanIn; i++ {
vbanIn[i] = newVbanInStream(i)
}
vbanOut := make([]iVban, k.VbanOut)
for i := 0; i < k.VbanOut; i++ {
vbanOut[i] = newVbanOutStream(i)
}
return &vban{
InStream: vbanIn,
OutStream: vbanOut,
}
}
func (v *vban) Enable() {
setParameterFloat("vban.Enable", 1)
}
func (v *vban) Disable() {
setParameterFloat("vban.Enable", 0)
}