gainlayers implemented

tests adjusted for potato.
gainlayer unit test added

factory method for bus mode added.
This commit is contained in:
onyx-and-iris 2022-06-28 19:30:37 +01:00
parent 0fb0daf558
commit 80a561d7fc
5 changed files with 68 additions and 19 deletions

View File

@ -8,7 +8,7 @@ import (
)
var (
vmRem = voicemeeter.GetRemote("banana")
vmRem = voicemeeter.GetRemote("potato")
)
func TestMain(m *testing.M) {

View File

@ -37,12 +37,12 @@ func TestStrip4Label(t *testing.T) {
//t.Skip("skipping test")
vmRem.Strip[4].SetLabel("test0")
t.Run("Should return test0 when SetLimit('test0')", func(t *testing.T) {
assert.Equal(t, vmRem.Strip[4].GetLabel(), "test0")
assert.Equal(t, "test0", vmRem.Strip[4].GetLabel())
})
vmRem.Strip[4].SetLabel("test1")
t.Run("Should return test1 when SetLimit('test1')", func(t *testing.T) {
assert.Equal(t, vmRem.Strip[4].GetLabel(), "test1")
assert.Equal(t, "test1", vmRem.Strip[4].GetLabel())
})
}
@ -59,16 +59,29 @@ func TestStrip5Gain(t *testing.T) {
})
}
func TestStrip3Mc(t *testing.T) {
func TestStrip5Mc(t *testing.T) {
//t.Skip("skipping test")
vmRem.Strip[3].SetMc(true)
vmRem.Strip[5].SetMc(true)
t.Run("Should return true when SetMc(true)", func(t *testing.T) {
assert.True(t, vmRem.Strip[3].GetMc())
assert.True(t, vmRem.Strip[5].GetMc())
})
vmRem.Strip[3].SetMc(false)
vmRem.Strip[5].SetMc(false)
t.Run("Should return false when SetMc(false)", func(t *testing.T) {
assert.False(t, vmRem.Strip[3].GetMc())
assert.False(t, vmRem.Strip[5].GetMc())
})
}
func TestStrip2GainLayer3(t *testing.T) {
//t.Skip("skipping test")
vmRem.Strip[2].GainLayer()[3].Set(-18.3)
t.Run("Should return -18.3 when SetMc(true)", func(t *testing.T) {
assert.Equal(t, vmRem.Strip[2].GainLayer()[3].Get(), -18.3)
})
vmRem.Strip[2].GainLayer()[3].Set(-25.6)
t.Run("Should return -25.6 when SetMc(true)", func(t *testing.T) {
assert.Equal(t, vmRem.Strip[2].GainLayer()[3].Get(), -25.6)
})
}
@ -89,12 +102,12 @@ func TestBus4Label(t *testing.T) {
//t.Skip("skipping test")
vmRem.Bus[4].SetLabel("test0")
t.Run("Should return test0 when SetEq('test0')", func(t *testing.T) {
assert.Equal(t, vmRem.Bus[4].GetLabel(), "test0")
assert.Equal(t, "test0", vmRem.Bus[4].GetLabel())
})
vmRem.Bus[4].SetLabel("test1")
t.Run("Should return test1 when SetEq('test1')", func(t *testing.T) {
assert.Equal(t, vmRem.Bus[4].GetLabel(), "test1")
assert.Equal(t, "test1", vmRem.Bus[4].GetLabel())
})
}
@ -133,20 +146,20 @@ func TestVbanOutStream6On(t *testing.T) {
}
func TestVbanOutStream3Name(t *testing.T) {
//t.Skip("skipping test")
t.Skip("skipping test")
vmRem.Vban.OutStream[3].SetName("test0")
t.Run("Should return test0 when SetName('test0')", func(t *testing.T) {
assert.Equal(t, vmRem.Vban.OutStream[3].GetName(), "test0")
assert.Equal(t, "test0", vmRem.Vban.OutStream[3].GetName())
})
vmRem.Vban.OutStream[3].SetName("test1")
t.Run("Should return test1 when SetName('test1')", func(t *testing.T) {
assert.Equal(t, vmRem.Vban.OutStream[3].GetName(), "test1")
assert.Equal(t, "test1", vmRem.Vban.OutStream[3].GetName())
})
}
func TestVbanInStream4Bit(t *testing.T) {
//t.Skip("skipping test")
t.Skip("skipping test")
t.Run("Should panic when instream SetBit(16)", func(t *testing.T) {
defer func() {
if r := recover(); r == nil {

View File

@ -112,7 +112,7 @@ func mdirty() bool {
}
func sync() {
time.Sleep(20 * time.Millisecond)
time.Sleep(30 * time.Millisecond)
for pdirty() || mdirty() {
}
}

View File

@ -87,7 +87,7 @@ type physicalBus struct {
func newPhysicalBus(i int) t_bus {
pb := physicalBus{bus{
iRemote{fmt.Sprintf("bus[%d]", i), i},
busMode{iRemote{fmt.Sprintf("bus[%d].mode", i), i}},
newBusMode(i),
}}
return t_bus(&pb)
}
@ -104,7 +104,7 @@ type virtualBus struct {
func newVirtualBus(i int) t_bus {
vb := virtualBus{bus{
iRemote{fmt.Sprintf("bus[%d]", i), i},
busMode{iRemote{fmt.Sprintf("bus[%d].mode", i), i}},
newBusMode(i),
}}
return t_bus(&vb)
}
@ -145,6 +145,10 @@ type busMode struct {
iRemote
}
func newBusMode(i int) busMode {
return busMode{iRemote{fmt.Sprintf("bus[%d].mode", i), i}}
}
func (bm *busMode) SetNormal(val bool) {
bm.setter_bool("Normal", val)
}

View File

@ -26,6 +26,7 @@ type t_strip interface {
SetGate(val bool)
GetAudibility() bool
SetAudibility(val bool)
GainLayer() []gainLayer
t_outputs
}
@ -33,6 +34,7 @@ type t_strip interface {
type strip struct {
iRemote
outputs
gainLayer []gainLayer
}
// GetMute returns the value of the Mute parameter
@ -95,13 +97,22 @@ func (s *strip) SetGain(val float32) {
s.setter_float("Gain", val)
}
// Mode returns address of a busMode struct
func (s *strip) GainLayer() []gainLayer {
return s.gainLayer
}
type physicalStrip struct {
strip
}
func newPhysicalStrip(i int) t_strip {
o := newOutputs("strip", i)
ps := physicalStrip{strip{iRemote{fmt.Sprintf("strip[%d]", i), i}, o}}
gl := make([]gainLayer, 8)
for j := 0; j < 8; j++ {
gl[j] = newGainLayer(i, j)
}
ps := physicalStrip{strip{iRemote{fmt.Sprintf("strip[%d]", i), i}, o, gl}}
return t_strip(&ps)
}
@ -156,7 +167,11 @@ type virtualStrip struct {
func newVirtualStrip(i int) t_strip {
o := newOutputs("strip", i)
vs := virtualStrip{strip{iRemote{fmt.Sprintf("strip[%d]", i), i}, o}}
gl := make([]gainLayer, 8)
for j := 0; j < 8; j++ {
gl[j] = newGainLayer(i, j)
}
vs := virtualStrip{strip{iRemote{fmt.Sprintf("strip[%d]", i), i}, o, gl}}
return t_strip(&vs)
}
@ -204,3 +219,20 @@ func (v *virtualStrip) GetAudibility() bool {
func (v *virtualStrip) SetAudibility(val bool) {
panic("invalid parameter Audibility for virtualStrip")
}
type gainLayer struct {
iRemote
index int
}
func newGainLayer(i, j int) gainLayer {
return gainLayer{iRemote{fmt.Sprintf("strip[%d]", i), i}, j}
}
func (gl *gainLayer) Get() float64 {
return gl.getter_float(fmt.Sprintf("gainlayer[%d]", gl.index))
}
func (gl *gainLayer) Set(val float32) {
gl.setter_float(fmt.Sprintf("gainlayer[%d]", gl.index), val)
}