mirror of
https://github.com/onyx-and-iris/voicemeeter.git
synced 2024-11-25 06:10:52 +00:00
common embedded methods defined as iremote struct.
This commit is contained in:
parent
751200951b
commit
a07df8f7b8
@ -20,7 +20,7 @@ type t_bus interface {
|
||||
// bus represents a bus channel
|
||||
// embeds channel struct
|
||||
type bus struct {
|
||||
channel
|
||||
iRemote
|
||||
}
|
||||
|
||||
// String implements the stringer interface
|
||||
@ -86,7 +86,7 @@ type physicalBus struct {
|
||||
}
|
||||
|
||||
func newPhysicalBus(i int, k *kind) t_bus {
|
||||
pb := physicalBus{bus{channel{"bus", i, *k}}}
|
||||
pb := physicalBus{bus{iRemote{"bus", i, k}}}
|
||||
return t_bus(&pb)
|
||||
}
|
||||
|
||||
@ -95,6 +95,6 @@ type virtualBus struct {
|
||||
}
|
||||
|
||||
func newVirtualBus(i int, k *kind) t_bus {
|
||||
vb := virtualBus{bus{channel{"bus", i, *k}}}
|
||||
vb := virtualBus{bus{iRemote{"bus", i, k}}}
|
||||
return t_bus(&vb)
|
||||
}
|
||||
|
@ -1,65 +0,0 @@
|
||||
package voicemeeter
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type channel struct {
|
||||
identifier string
|
||||
index int
|
||||
kind kind
|
||||
}
|
||||
|
||||
// getter_bool returns the value of a boolean parameter
|
||||
func (c *channel) getter_bool(p string) bool {
|
||||
param := fmt.Sprintf("%s[%d].%s", c.identifier, c.index, p)
|
||||
return getParameterFloat(param) == 1
|
||||
}
|
||||
|
||||
// setter_bool sets the value of a boolean parameter
|
||||
func (c *channel) setter_bool(p string, v bool) {
|
||||
param := fmt.Sprintf("%s[%d].%s", c.identifier, c.index, p)
|
||||
var value float32
|
||||
if v {
|
||||
value = 1
|
||||
} else {
|
||||
value = 0
|
||||
}
|
||||
setParameterFloat(param, float32(value))
|
||||
}
|
||||
|
||||
// getter_int returns the value of an int parameter p
|
||||
func (c *channel) getter_int(p string) int {
|
||||
param := fmt.Sprintf("%s[%d].%s", c.identifier, c.index, p)
|
||||
return int(getParameterFloat(param))
|
||||
}
|
||||
|
||||
// setter_int sets the value v of an int parameter p
|
||||
func (c *channel) setter_int(p string, v int) {
|
||||
param := fmt.Sprintf("%s[%d].%s", c.identifier, c.index, p)
|
||||
setParameterFloat(param, float32(v))
|
||||
}
|
||||
|
||||
// getter_float returns the value of an int parameter p
|
||||
func (c *channel) getter_float(p string) float64 {
|
||||
param := fmt.Sprintf("%s[%d].%s", c.identifier, c.index, p)
|
||||
return getParameterFloat(param)
|
||||
}
|
||||
|
||||
// setter_float sets the value v of an int parameter p
|
||||
func (c *channel) setter_float(p string, v float32) {
|
||||
param := fmt.Sprintf("%s[%d].%s", c.identifier, c.index, p)
|
||||
setParameterFloat(param, float32(v))
|
||||
}
|
||||
|
||||
// getter_string returns the value of a string parameter p
|
||||
func (c *channel) getter_string(p string) string {
|
||||
param := fmt.Sprintf("%s[%d].%s", c.identifier, c.index, p)
|
||||
return getParameterString(param)
|
||||
}
|
||||
|
||||
// setter_string sets the value v of a string parameter p
|
||||
func (c *channel) setter_string(p, v string) {
|
||||
param := fmt.Sprintf("%s[%d].%s", c.identifier, c.index, p)
|
||||
setParameterString(param, v)
|
||||
}
|
70
voicemeeter/iremote.go
Normal file
70
voicemeeter/iremote.go
Normal file
@ -0,0 +1,70 @@
|
||||
package voicemeeter
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// iRemote provides a set of common forwarding methods
|
||||
type iRemote struct {
|
||||
_identifier string
|
||||
index int
|
||||
kind *kind
|
||||
}
|
||||
|
||||
func (c *iRemote) identifier() string {
|
||||
return c._identifier
|
||||
}
|
||||
|
||||
// getter_bool returns the value of a boolean parameter
|
||||
func (c *iRemote) getter_bool(p string) bool {
|
||||
param := fmt.Sprintf("%s[%d].%s", c.identifier(), c.index, p)
|
||||
return getParameterFloat(param) == 1
|
||||
}
|
||||
|
||||
// setter_bool sets the value of a boolean parameter
|
||||
func (c *iRemote) setter_bool(p string, v bool) {
|
||||
param := fmt.Sprintf("%s[%d].%s", c.identifier(), c.index, p)
|
||||
var value float32
|
||||
if v {
|
||||
value = 1
|
||||
} else {
|
||||
value = 0
|
||||
}
|
||||
setParameterFloat(param, float32(value))
|
||||
}
|
||||
|
||||
// getter_int returns the value of an int parameter p
|
||||
func (c *iRemote) getter_int(p string) int {
|
||||
param := fmt.Sprintf("%s[%d].%s", c.identifier(), c.index, p)
|
||||
return int(getParameterFloat(param))
|
||||
}
|
||||
|
||||
// setter_int sets the value v of an int parameter p
|
||||
func (c *iRemote) setter_int(p string, v int) {
|
||||
param := fmt.Sprintf("%s[%d].%s", c.identifier(), c.index, p)
|
||||
setParameterFloat(param, float32(v))
|
||||
}
|
||||
|
||||
// getter_float returns the value of an int parameter p
|
||||
func (c *iRemote) getter_float(p string) float64 {
|
||||
param := fmt.Sprintf("%s[%d].%s", c.identifier(), c.index, p)
|
||||
return getParameterFloat(param)
|
||||
}
|
||||
|
||||
// setter_float sets the value v of an int parameter p
|
||||
func (c *iRemote) setter_float(p string, v float32) {
|
||||
param := fmt.Sprintf("%s[%d].%s", c.identifier(), c.index, p)
|
||||
setParameterFloat(param, float32(v))
|
||||
}
|
||||
|
||||
// getter_string returns the value of a string parameter p
|
||||
func (c *iRemote) getter_string(p string) string {
|
||||
param := fmt.Sprintf("%s[%d].%s", c.identifier(), c.index, p)
|
||||
return getParameterString(param)
|
||||
}
|
||||
|
||||
// setter_string sets the value v of a string parameter p
|
||||
func (c *iRemote) setter_string(p, v string) {
|
||||
param := fmt.Sprintf("%s[%d].%s", c.identifier(), c.index, p)
|
||||
setParameterString(param, v)
|
||||
}
|
@ -30,7 +30,7 @@ type t_strip interface {
|
||||
// strip represents a strip channel
|
||||
// embeds channel struct
|
||||
type strip struct {
|
||||
channel
|
||||
iRemote
|
||||
}
|
||||
|
||||
// implement stringer interface in fmt
|
||||
@ -106,7 +106,7 @@ type physicalStrip struct {
|
||||
}
|
||||
|
||||
func newPhysicalStrip(i int, k *kind) t_strip {
|
||||
ps := physicalStrip{strip{channel{"strip", i, *k}}}
|
||||
ps := physicalStrip{strip{iRemote{"strip", i, k}}}
|
||||
return t_strip(&ps)
|
||||
}
|
||||
|
||||
@ -155,7 +155,7 @@ type virtualStrip struct {
|
||||
}
|
||||
|
||||
func newVirtualStrip(i int, k *kind) t_strip {
|
||||
vs := virtualStrip{strip{channel{"strip", i, *k}}}
|
||||
vs := virtualStrip{strip{iRemote{"strip", i, k}}}
|
||||
return t_strip(&vs)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user