From 80a561d7fcf287fefb319367943900e7919863e7 Mon Sep 17 00:00:00 2001 From: onyx-and-iris <75868496+onyx-and-iris@users.noreply.github.com> Date: Tue, 28 Jun 2022 19:30:37 +0100 Subject: [PATCH] gainlayers implemented tests adjusted for potato. gainlayer unit test added factory method for bus mode added. --- tests/helper_test.go | 2 +- tests/higher_test.go | 39 ++++++++++++++++++++++++++------------- voicemeeter/base.go | 2 +- voicemeeter/bus.go | 8 ++++++-- voicemeeter/strip.go | 36 ++++++++++++++++++++++++++++++++++-- 5 files changed, 68 insertions(+), 19 deletions(-) diff --git a/tests/helper_test.go b/tests/helper_test.go index e98e4d6..8cf0c08 100644 --- a/tests/helper_test.go +++ b/tests/helper_test.go @@ -8,7 +8,7 @@ import ( ) var ( - vmRem = voicemeeter.GetRemote("banana") + vmRem = voicemeeter.GetRemote("potato") ) func TestMain(m *testing.M) { diff --git a/tests/higher_test.go b/tests/higher_test.go index 85526f7..25bb85d 100644 --- a/tests/higher_test.go +++ b/tests/higher_test.go @@ -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 { diff --git a/voicemeeter/base.go b/voicemeeter/base.go index 63501ca..a15d260 100644 --- a/voicemeeter/base.go +++ b/voicemeeter/base.go @@ -112,7 +112,7 @@ func mdirty() bool { } func sync() { - time.Sleep(20 * time.Millisecond) + time.Sleep(30 * time.Millisecond) for pdirty() || mdirty() { } } diff --git a/voicemeeter/bus.go b/voicemeeter/bus.go index 42cb320..7313c25 100644 --- a/voicemeeter/bus.go +++ b/voicemeeter/bus.go @@ -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) } diff --git a/voicemeeter/strip.go b/voicemeeter/strip.go index 734952a..0eda6d7 100644 --- a/voicemeeter/strip.go +++ b/voicemeeter/strip.go @@ -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) +}