diff --git a/voicemeeter/bus.go b/voicemeeter/bus.go index 7d8e3cd..53d6f4f 100644 --- a/voicemeeter/bus.go +++ b/voicemeeter/bus.go @@ -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) } diff --git a/voicemeeter/channel.go b/voicemeeter/channel.go deleted file mode 100644 index bee7d66..0000000 --- a/voicemeeter/channel.go +++ /dev/null @@ -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) -} diff --git a/voicemeeter/iremote.go b/voicemeeter/iremote.go new file mode 100644 index 0000000..dc373e4 --- /dev/null +++ b/voicemeeter/iremote.go @@ -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) +} diff --git a/voicemeeter/strip.go b/voicemeeter/strip.go index b5fb2ab..a9552fe 100644 --- a/voicemeeter/strip.go +++ b/voicemeeter/strip.go @@ -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) }