voicemeeter/vban.go

198 lines
3.8 KiB
Go
Raw Permalink Normal View History

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
2022-06-25 04:00:15 +01:00
SetName(val string)
Ip() string
2022-06-25 04:00:15 +01:00
SetIp(val string)
Port() int
2022-06-25 04:00:15 +01:00
SetPort(val int)
Sr() int
2022-06-25 04:00:15 +01:00
SetSr(val int)
Channel() int
2022-06-25 04:00:15 +01:00
SetChannel(val int)
Bit() int
2022-06-25 04:00:15 +01:00
SetBit(val int)
Quality() int
2022-06-25 04:00:15 +01:00
SetQuality(val int)
Route() int
2022-06-25 04:00:15 +01:00
SetRoute(val int)
}
type stream struct {
iRemote
}
// On returns the value of the On parameter
func (v *stream) On() bool {
return v.getter_bool("On")
}
// SetOn sets the value of the On parameter
func (v *stream) SetOn(val bool) {
v.setter_bool("On", val)
}
// Name returns the value of the Name parameter
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
func (v *stream) SetName(val string) {
2022-06-25 04:00:15 +01:00
v.setter_string("Name", val)
}
// Ip returns the value of the Ip parameter
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
func (v *stream) SetIp(val string) {
2022-06-25 04:00:15 +01:00
v.setter_string("Ip", val)
}
// Port returns the value of the Port parameter
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
func (v *stream) SetPort(val int) {
2022-06-25 04:00:15 +01:00
v.setter_int("Port", val)
}
// Sr returns the value of the Sr parameter
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
func (v *stream) SetSr(val int) {
2022-06-25 04:00:15 +01:00
v.setter_int("Sr", val)
}
// Channel returns the value of the Channel parameter
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
func (v *stream) SetChannel(val int) {
2022-06-25 04:00:15 +01:00
v.setter_int("Channel", val)
}
// Bit returns the value of the Bit parameter
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
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:
log.Warn("expected value 16 or 24")
return
2022-06-25 04:00:15 +01:00
}
v.setter_int("Bit", val)
}
// Quality returns the value of the Quality parameter
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
func (v *stream) SetQuality(val int) {
2022-06-25 04:00:15 +01:00
v.setter_int("Quality", val)
}
// Route returns the value of the Route parameter
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
func (v *stream) SetRoute(val int) {
2022-06-25 04:00:15 +01:00
v.setter_int("Route", val)
}
type VbanInstream struct {
stream
}
func newVbanInStream(i int) iVban {
vbi := VbanInstream{stream{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")
2022-06-25 04:00:15 +01:00
}
// SetChannel logs a warning reason read only
func (vbi *VbanInstream) SetChannel(val int) {
log.Warn("channel is readonly for vban instreams")
2022-06-25 04:00:15 +01:00
}
// SetBit logs a warning reason read only
func (vbi *VbanInstream) SetBit(val int) {
log.Warn("bit is readonly for vban instreams")
2022-06-25 04:00:15 +01:00
}
type VbanOutStream struct {
stream
}
func newVbanOutStream(i int) iVban {
vbo := VbanOutStream{stream{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,
}
}
2022-06-25 04:00:15 +01:00
func (v *vban) Enable() {
setParameterFloat("vban.Enable", 1)
}
func (v *vban) Disable() {
setParameterFloat("vban.Enable", 0)
}