2022-06-22 20:51:25 +01:00
|
|
|
package voicemeeter
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2022-07-10 23:08:14 +01:00
|
|
|
"time"
|
2022-06-22 20:51:25 +01:00
|
|
|
)
|
|
|
|
|
2022-07-10 23:08:14 +01:00
|
|
|
// iStrip defines the interface bus types must satisfy
|
|
|
|
type iStrip interface {
|
2022-06-25 01:18:20 +01:00
|
|
|
String() string
|
2022-06-23 10:42:11 +01:00
|
|
|
GetMute() bool
|
|
|
|
SetMute(val bool)
|
|
|
|
GetMono() bool
|
|
|
|
SetMono(val bool)
|
|
|
|
GetSolo() bool
|
|
|
|
SetSolo(val bool)
|
|
|
|
GetLimit() int
|
|
|
|
SetLimit(val int)
|
|
|
|
GetLabel() string
|
|
|
|
SetLabel(val string)
|
|
|
|
GetGain() float64
|
|
|
|
SetGain(val float32)
|
|
|
|
GetMc() bool
|
|
|
|
SetMc(val bool)
|
2022-06-30 22:20:18 +01:00
|
|
|
GetComp() float64
|
|
|
|
SetComp(val float32)
|
|
|
|
GetGate() float64
|
|
|
|
SetGate(val float32)
|
|
|
|
GetAudibility() float64
|
|
|
|
SetAudibility(val float32)
|
2022-06-28 19:30:37 +01:00
|
|
|
GainLayer() []gainLayer
|
2022-06-30 20:08:46 +01:00
|
|
|
Levels() *levels
|
2022-07-10 23:08:14 +01:00
|
|
|
FadeTo(target float32, time_ int)
|
|
|
|
FadeBy(change float32, time_ int)
|
|
|
|
AppGain(name string, gain float32)
|
|
|
|
AppMute(name string, val bool)
|
|
|
|
iOutputs
|
2022-06-22 20:51:25 +01:00
|
|
|
}
|
|
|
|
|
2022-06-23 10:42:11 +01:00
|
|
|
// strip represents a strip channel
|
|
|
|
type strip struct {
|
2022-06-23 14:03:00 +01:00
|
|
|
iRemote
|
2022-06-25 04:01:19 +01:00
|
|
|
outputs
|
2022-06-28 19:30:37 +01:00
|
|
|
gainLayer []gainLayer
|
2022-06-30 20:08:46 +01:00
|
|
|
levels
|
2022-06-22 20:51:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// GetMute returns the value of the Mute parameter
|
|
|
|
func (s *strip) GetMute() bool {
|
|
|
|
return s.getter_bool("Mute")
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetMute sets the value of the Mute parameter
|
|
|
|
func (s *strip) SetMute(val bool) {
|
|
|
|
s.setter_bool("Mute", val)
|
|
|
|
}
|
|
|
|
|
2022-06-24 14:54:17 +01:00
|
|
|
// GetMono returns the value of the Mono parameter
|
2022-06-23 10:42:11 +01:00
|
|
|
func (s *strip) GetMono() bool {
|
|
|
|
return s.getter_bool("Mono")
|
|
|
|
}
|
|
|
|
|
2022-06-24 14:54:17 +01:00
|
|
|
// SetMono sets the value of the Mono parameter
|
2022-06-23 10:42:11 +01:00
|
|
|
func (s *strip) SetMono(val bool) {
|
|
|
|
s.setter_bool("Mono", val)
|
|
|
|
}
|
|
|
|
|
2022-06-24 14:54:17 +01:00
|
|
|
// GetSolo returns the value of the Solo parameter
|
2022-06-23 10:42:11 +01:00
|
|
|
func (s *strip) GetSolo() bool {
|
|
|
|
return s.getter_bool("Solo")
|
|
|
|
}
|
|
|
|
|
2022-06-24 14:54:17 +01:00
|
|
|
// SetSolo sets the value of the Solo parameter
|
2022-06-23 10:42:11 +01:00
|
|
|
func (s *strip) SetSolo(val bool) {
|
|
|
|
s.setter_bool("Solo", val)
|
|
|
|
}
|
|
|
|
|
2022-06-22 20:51:25 +01:00
|
|
|
// GetLimit returns the value of the Limit parameter
|
|
|
|
func (s *strip) GetLimit() int {
|
|
|
|
return s.getter_int("Limit")
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetLimit sets the value of the Limit parameter
|
|
|
|
func (s *strip) SetLimit(val int) {
|
|
|
|
s.setter_int("Limit", val)
|
|
|
|
}
|
|
|
|
|
2022-06-24 14:54:17 +01:00
|
|
|
// GetLabel returns the value of the Label parameter
|
2022-06-22 20:51:25 +01:00
|
|
|
func (s *strip) GetLabel() string {
|
|
|
|
return s.getter_string("Label")
|
|
|
|
}
|
|
|
|
|
2022-06-24 14:54:17 +01:00
|
|
|
// SetLabel sets the value of the Label parameter
|
2022-06-22 20:51:25 +01:00
|
|
|
func (s *strip) SetLabel(val string) {
|
|
|
|
s.setter_string("Label", val)
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetGain returns the value of the Gain parameter
|
|
|
|
func (s *strip) GetGain() float64 {
|
|
|
|
return s.getter_float("Gain")
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetGain sets the value of the Gain parameter
|
|
|
|
func (s *strip) SetGain(val float32) {
|
|
|
|
s.setter_float("Gain", val)
|
|
|
|
}
|
2022-06-23 10:42:11 +01:00
|
|
|
|
2022-06-30 20:08:46 +01:00
|
|
|
// GainLayer returns the gainlayer field
|
2022-06-28 19:30:37 +01:00
|
|
|
func (s *strip) GainLayer() []gainLayer {
|
|
|
|
return s.gainLayer
|
|
|
|
}
|
|
|
|
|
2022-07-10 23:08:14 +01:00
|
|
|
// Levels returns the levels field
|
2022-06-30 20:08:46 +01:00
|
|
|
func (s *strip) Levels() *levels {
|
|
|
|
return &s.levels
|
|
|
|
}
|
|
|
|
|
2022-07-10 23:08:14 +01:00
|
|
|
// FadeTo sets the value of gain to target over at time interval of time_
|
|
|
|
func (s *strip) FadeTo(target float32, time_ int) {
|
|
|
|
s.setter_string("FadeTo", fmt.Sprintf("(\"%f\", %d)", target, time_))
|
|
|
|
time.Sleep(time.Millisecond)
|
|
|
|
}
|
|
|
|
|
|
|
|
// FadeBy adjusts the value of gain by change over a time interval of time_
|
|
|
|
func (s *strip) FadeBy(change float32, time_ int) {
|
|
|
|
s.setter_string("FadeBy", fmt.Sprintf("(\"%f\", %d)", change, time_))
|
|
|
|
time.Sleep(time.Millisecond)
|
|
|
|
}
|
|
|
|
|
|
|
|
//physicalStrip represents a single physical strip
|
2022-06-23 10:42:11 +01:00
|
|
|
type physicalStrip struct {
|
|
|
|
strip
|
|
|
|
}
|
|
|
|
|
2022-07-10 23:08:14 +01:00
|
|
|
// newPhysicalStrip returns a physicalStrip type cast to an iStrip
|
|
|
|
func newPhysicalStrip(i int, k *kind) iStrip {
|
2022-07-01 01:35:54 +01:00
|
|
|
o := newOutputs(fmt.Sprintf("strip[%d]", i), i)
|
2022-06-28 19:30:37 +01:00
|
|
|
gl := make([]gainLayer, 8)
|
|
|
|
for j := 0; j < 8; j++ {
|
|
|
|
gl[j] = newGainLayer(i, j)
|
|
|
|
}
|
2022-06-30 20:08:46 +01:00
|
|
|
l := newStripLevels(i, k)
|
|
|
|
ps := physicalStrip{strip{iRemote{fmt.Sprintf("strip[%d]", i), i}, o, gl, l}}
|
2022-07-10 23:08:14 +01:00
|
|
|
return iStrip(&ps)
|
2022-06-23 10:42:11 +01:00
|
|
|
}
|
|
|
|
|
2022-07-10 23:08:14 +01:00
|
|
|
// String implements fmt.stringer interface
|
2022-06-25 01:18:20 +01:00
|
|
|
func (p *physicalStrip) String() string {
|
|
|
|
return fmt.Sprintf("PhysicalStrip%d", p.index)
|
|
|
|
}
|
|
|
|
|
2022-06-24 14:54:17 +01:00
|
|
|
// GetComp returns the value of the Comp parameter
|
2022-06-30 22:20:18 +01:00
|
|
|
func (p *physicalStrip) GetComp() float64 {
|
|
|
|
return p.getter_float("Comp")
|
2022-06-23 10:42:11 +01:00
|
|
|
}
|
|
|
|
|
2022-06-24 14:54:17 +01:00
|
|
|
// SetComp sets the value of the Comp parameter
|
2022-06-30 22:20:18 +01:00
|
|
|
func (p *physicalStrip) SetComp(val float32) {
|
|
|
|
p.setter_float("Comp", val)
|
2022-06-23 10:42:11 +01:00
|
|
|
}
|
|
|
|
|
2022-06-24 14:54:17 +01:00
|
|
|
// GetGate returns the value of the Gate parameter
|
2022-06-30 22:20:18 +01:00
|
|
|
func (p *physicalStrip) GetGate() float64 {
|
|
|
|
return p.getter_float("Gate")
|
2022-06-23 10:42:11 +01:00
|
|
|
}
|
|
|
|
|
2022-06-24 14:54:17 +01:00
|
|
|
// SetGate sets the value of the Gate parameter
|
2022-06-30 22:20:18 +01:00
|
|
|
func (p *physicalStrip) SetGate(val float32) {
|
|
|
|
p.setter_float("Gate", val)
|
2022-06-23 10:42:11 +01:00
|
|
|
}
|
|
|
|
|
2022-06-24 14:54:17 +01:00
|
|
|
// GetAudibility returns the value of the Audibility parameter
|
2022-06-30 22:20:18 +01:00
|
|
|
func (p *physicalStrip) GetAudibility() float64 {
|
|
|
|
return p.getter_float("Audibility")
|
2022-06-23 10:42:11 +01:00
|
|
|
}
|
|
|
|
|
2022-06-24 14:54:17 +01:00
|
|
|
// SetAudibility sets the value of the Audibility parameter
|
2022-06-30 22:20:18 +01:00
|
|
|
func (p *physicalStrip) SetAudibility(val float32) {
|
|
|
|
p.setter_float("Audibility", val)
|
2022-06-23 10:42:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// GetMc panics reason invalid parameter
|
|
|
|
func (p *physicalStrip) GetMc() bool {
|
|
|
|
panic("invalid parameter MC for physicalStrip")
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetMc panics reason invalid parameter
|
|
|
|
func (p *physicalStrip) SetMc(val bool) {
|
|
|
|
panic("invalid parameter MC for physicalStrip")
|
|
|
|
}
|
|
|
|
|
2022-07-10 23:08:14 +01:00
|
|
|
//virtualStrip represents a single virtual strip
|
2022-06-23 10:42:11 +01:00
|
|
|
type virtualStrip struct {
|
|
|
|
strip
|
|
|
|
}
|
|
|
|
|
2022-07-10 23:08:14 +01:00
|
|
|
// newVirtualStrip returns a virtualStrip type cast to an iStrip
|
|
|
|
func newVirtualStrip(i int, k *kind) iStrip {
|
2022-07-01 01:35:54 +01:00
|
|
|
o := newOutputs(fmt.Sprintf("strip[%d]", i), i)
|
2022-06-28 19:30:37 +01:00
|
|
|
gl := make([]gainLayer, 8)
|
|
|
|
for j := 0; j < 8; j++ {
|
|
|
|
gl[j] = newGainLayer(i, j)
|
|
|
|
}
|
2022-06-30 20:08:46 +01:00
|
|
|
l := newStripLevels(i, k)
|
|
|
|
vs := virtualStrip{strip{iRemote{fmt.Sprintf("strip[%d]", i), i}, o, gl, l}}
|
2022-07-10 23:08:14 +01:00
|
|
|
return iStrip(&vs)
|
2022-06-23 10:42:11 +01:00
|
|
|
}
|
|
|
|
|
2022-07-10 23:08:14 +01:00
|
|
|
// String implements fmt.stringer interface
|
2022-06-25 01:18:20 +01:00
|
|
|
func (v *virtualStrip) String() string {
|
|
|
|
return fmt.Sprintf("VirtualStrip%d", v.index)
|
|
|
|
}
|
|
|
|
|
2022-06-23 10:42:11 +01:00
|
|
|
// GetMc returns the value of the MC parameter
|
|
|
|
func (v *virtualStrip) GetMc() bool {
|
|
|
|
return v.getter_bool("MC")
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetMc sets the value of the MC parameter
|
|
|
|
func (v *virtualStrip) SetMc(val bool) {
|
|
|
|
v.setter_bool("MC", val)
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetComp panics reason invalid parameter
|
2022-06-30 22:20:18 +01:00
|
|
|
func (v *virtualStrip) GetComp() float64 {
|
2022-06-23 10:42:11 +01:00
|
|
|
panic("invalid parameter Comp for virtualStrip")
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetComp panics reason invalid parameter
|
2022-06-30 22:20:18 +01:00
|
|
|
func (v *virtualStrip) SetComp(val float32) {
|
2022-06-23 10:42:11 +01:00
|
|
|
panic("invalid parameter Comp for virtualStrip")
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetGate panics reason invalid parameter
|
2022-06-30 22:20:18 +01:00
|
|
|
func (v *virtualStrip) GetGate() float64 {
|
2022-06-23 10:42:11 +01:00
|
|
|
panic("invalid parameter Gate for virtualStrip")
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetGate panics reason invalid parameter
|
2022-06-30 22:20:18 +01:00
|
|
|
func (v *virtualStrip) SetGate(val float32) {
|
2022-06-23 10:42:11 +01:00
|
|
|
panic("invalid parameter Gate for virtualStrip")
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetAudibility panics reason invalid parameter
|
2022-06-30 22:20:18 +01:00
|
|
|
func (v *virtualStrip) GetAudibility() float64 {
|
2022-06-23 10:42:11 +01:00
|
|
|
panic("invalid parameter Audibility for virtualStrip")
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetAudibility panics reason invalid parameter
|
2022-06-30 22:20:18 +01:00
|
|
|
func (v *virtualStrip) SetAudibility(val float32) {
|
2022-06-23 10:42:11 +01:00
|
|
|
panic("invalid parameter Audibility for virtualStrip")
|
|
|
|
}
|
2022-06-28 19:30:37 +01:00
|
|
|
|
2022-07-10 23:08:14 +01:00
|
|
|
// AppGain sets the gain in db by val for the app matching name.
|
|
|
|
func (v *strip) AppGain(name string, val float32) {
|
|
|
|
v.setter_string("AppGain", fmt.Sprintf("(\"%s\", %f)", name, val))
|
|
|
|
}
|
|
|
|
|
|
|
|
// AppMute sets mute state as val for the app matching name.
|
|
|
|
func (v *strip) AppMute(name string, val bool) {
|
|
|
|
var value int
|
|
|
|
if val {
|
|
|
|
value = 1
|
|
|
|
} else {
|
|
|
|
value = 0
|
|
|
|
}
|
|
|
|
v.setter_string("AppMute", fmt.Sprintf("(\"%s\", %f)", name, float32(value)))
|
|
|
|
}
|
|
|
|
|
|
|
|
// gainLayer represents the 8 gainlayers for a single strip
|
2022-06-28 19:30:37 +01:00
|
|
|
type gainLayer struct {
|
|
|
|
iRemote
|
|
|
|
index int
|
|
|
|
}
|
|
|
|
|
2022-07-10 23:08:14 +01:00
|
|
|
// newGainLayer returns a gainlayer struct
|
2022-06-28 19:30:37 +01:00
|
|
|
func newGainLayer(i, j int) gainLayer {
|
|
|
|
return gainLayer{iRemote{fmt.Sprintf("strip[%d]", i), i}, j}
|
|
|
|
}
|
|
|
|
|
2022-07-10 23:08:14 +01:00
|
|
|
// Get gets the gain value for a single gainlayer
|
2022-06-28 19:30:37 +01:00
|
|
|
func (gl *gainLayer) Get() float64 {
|
|
|
|
return gl.getter_float(fmt.Sprintf("gainlayer[%d]", gl.index))
|
|
|
|
}
|
|
|
|
|
2022-07-10 23:08:14 +01:00
|
|
|
// Set sets the gain value for a single gainlayer
|
2022-06-28 19:30:37 +01:00
|
|
|
func (gl *gainLayer) Set(val float32) {
|
|
|
|
gl.setter_float(fmt.Sprintf("gainlayer[%d]", gl.index), val)
|
|
|
|
}
|
2022-06-30 20:08:46 +01:00
|
|
|
|
2022-07-10 23:08:14 +01:00
|
|
|
// newStripLevels returns a levels struct
|
2022-06-30 20:08:46 +01:00
|
|
|
func newStripLevels(i int, k *kind) levels {
|
|
|
|
var init int
|
|
|
|
var os int
|
2022-07-18 16:23:15 +01:00
|
|
|
if i < k.PhysIn {
|
2022-06-30 20:08:46 +01:00
|
|
|
init = i * 2
|
|
|
|
os = 2
|
|
|
|
} else {
|
2022-07-18 16:23:15 +01:00
|
|
|
init = (k.PhysIn * 2) + ((i - k.PhysIn) * 8)
|
2022-06-30 20:08:46 +01:00
|
|
|
os = 8
|
|
|
|
}
|
2022-07-09 19:01:58 +01:00
|
|
|
return levels{iRemote{fmt.Sprintf("strip[%d]", i), i}, k, init, os, "strip"}
|
2022-06-30 20:08:46 +01:00
|
|
|
}
|
|
|
|
|
2022-07-12 17:33:50 +01:00
|
|
|
// PreFader returns the level values for this strip, PREFADER mode
|
2022-06-30 20:08:46 +01:00
|
|
|
func (l *levels) PreFader() []float32 {
|
2022-07-09 19:01:58 +01:00
|
|
|
_levelCache.stripMode = 0
|
2022-06-30 20:08:46 +01:00
|
|
|
var levels []float32
|
|
|
|
for i := l.init; i < l.init+l.offset; i++ {
|
2022-07-10 23:08:14 +01:00
|
|
|
levels = append(levels, convertLevel(_levelCache.stripLevels[i]))
|
2022-06-30 20:08:46 +01:00
|
|
|
}
|
|
|
|
return levels
|
|
|
|
}
|
|
|
|
|
2022-07-12 17:33:50 +01:00
|
|
|
// PostFader returns the level values for this strip, POSTFADER mode
|
2022-06-30 20:08:46 +01:00
|
|
|
func (l *levels) PostFader() []float32 {
|
2022-07-09 19:01:58 +01:00
|
|
|
_levelCache.stripMode = 1
|
2022-06-30 20:08:46 +01:00
|
|
|
var levels []float32
|
|
|
|
for i := l.init; i < l.init+l.offset; i++ {
|
2022-07-10 23:08:14 +01:00
|
|
|
levels = append(levels, convertLevel(_levelCache.stripLevels[i]))
|
2022-06-30 20:08:46 +01:00
|
|
|
}
|
|
|
|
return levels
|
|
|
|
}
|
|
|
|
|
2022-07-12 17:33:50 +01:00
|
|
|
// PostMute returns the level values for this strip, POSTMUTE mode
|
2022-06-30 20:08:46 +01:00
|
|
|
func (l *levels) PostMute() []float32 {
|
2022-07-09 19:01:58 +01:00
|
|
|
_levelCache.stripMode = 2
|
2022-06-30 20:08:46 +01:00
|
|
|
var levels []float32
|
|
|
|
for i := l.init; i < l.init+l.offset; i++ {
|
2022-07-10 23:08:14 +01:00
|
|
|
levels = append(levels, convertLevel(_levelCache.stripLevels[i]))
|
2022-06-30 20:08:46 +01:00
|
|
|
}
|
|
|
|
return levels
|
|
|
|
}
|