From 13f7e3d1ad74bc77f946177618ebded77a1bf6db Mon Sep 17 00:00:00 2001 From: onyx-and-iris <75868496+onyx-and-iris@users.noreply.github.com> Date: Fri, 24 Jun 2022 14:54:17 +0100 Subject: [PATCH] move kindMap, fix doc strings fix doc strings move kindMap into kinds.go rename kind_id to kindId --- voicemeeter/base.go | 8 ++++---- voicemeeter/command.go | 6 ++++++ voicemeeter/kinds.go | 17 ++++++++++------- voicemeeter/remote.go | 12 +++--------- voicemeeter/strip.go | 24 ++++++++++++------------ 5 files changed, 35 insertions(+), 32 deletions(-) diff --git a/voicemeeter/base.go b/voicemeeter/base.go index 5ab049d..47b2e91 100644 --- a/voicemeeter/base.go +++ b/voicemeeter/base.go @@ -40,10 +40,10 @@ var ( // login logs into the API, // then attempts to launch Voicemeeter if it's not running. -func login(kind_id string) { +func login(kindId string) { res, _, _ := vmLogin.Call() if res == 1 { - runVoicemeeter(kind_id) + runVoicemeeter(kindId) time.Sleep(time.Second) } else if res != 0 { err := fmt.Errorf("VBVMR_Login returned %d", res) @@ -68,13 +68,13 @@ func logout() { } // runVoicemeeter attempts to launch a Voicemeeter GUI of a kind. -func runVoicemeeter(kind_id string) { +func runVoicemeeter(kindId string) { vals := map[string]uint64{ "basic": 1, "banana": 2, "potato": 3, } - res, _, _ := vmRunvm.Call(uintptr(vals[kind_id])) + res, _, _ := vmRunvm.Call(uintptr(vals[kindId])) if res != 0 { err := fmt.Errorf("VBVMR_RunVoicemeeter returned %d", res) fmt.Println(err) diff --git a/voicemeeter/command.go b/voicemeeter/command.go index 879feb7..7c2f90b 100644 --- a/voicemeeter/command.go +++ b/voicemeeter/command.go @@ -15,22 +15,28 @@ func (c *command) setter(p string, v float32) { setParameterFloat(param, v) } +// Show shows the Voicemeete GUI if it's hidden func (c *command) Show() { c.setter("Show", 1) } +// Hide hides the Voicemeete GUI if it's shown func (c *command) Hide() { c.setter("Show", 0) } +// Shutdown shutdown the Voicemeeter GUI func (c *command) Shutdown() { c.setter("Shutdown", 1) } +// Restart restarts the Voicemeeter audio engine func (c *command) Restart() { c.setter("Restart", 1) } +// Lock locks or unlocks the Voiceemeter GUI +// it accepts a boolean value func (c *command) Lock(val bool) { var value float32 if val { diff --git a/voicemeeter/kinds.go b/voicemeeter/kinds.go index 1c8c184..9e42d5f 100644 --- a/voicemeeter/kinds.go +++ b/voicemeeter/kinds.go @@ -7,13 +7,8 @@ import ( // A kind represents a Voicemeeter kinds layout type kind struct { - name string - physIn int - virtIn int - physOut int - virtOut int - vbanIn int - vbanOut int + name string + physIn, virtIn, physOut, virtOut, vbanIn, vbanOut int } func (k *kind) numStrip() int { @@ -44,3 +39,11 @@ func newBananaKind() *kind { func newPotatoKind() *kind { return &kind{"potato", 5, 3, 5, 3, 8, 8} } + +var ( + kindMap = map[string]*kind{ + "basic": newBasicKind(), + "banana": newBananaKind(), + "potato": newPotatoKind(), + } +) diff --git a/voicemeeter/remote.go b/voicemeeter/remote.go index 1c0bba0..fcd53aa 100644 --- a/voicemeeter/remote.go +++ b/voicemeeter/remote.go @@ -43,16 +43,10 @@ func (r *remote) SendText(script string) { // NewRemote returns a remote type of a kind, // this is the interface entry point. -func NewRemote(kind_id string) *remote { - kindMap := map[string]*kind{ - "basic": newBasicKind(), - "banana": newBananaKind(), - "potato": newPotatoKind(), - } - - _kind, ok := kindMap[kind_id] +func NewRemote(kindId string) *remote { + _kind, ok := kindMap[kindId] if !ok { - err := fmt.Errorf("unknown Voicemeeter kind '%s'", kind_id) + err := fmt.Errorf("unknown Voicemeeter kind '%s'", kindId) fmt.Println(err) os.Exit(1) } diff --git a/voicemeeter/strip.go b/voicemeeter/strip.go index a9552fe..c0295a3 100644 --- a/voicemeeter/strip.go +++ b/voicemeeter/strip.go @@ -51,22 +51,22 @@ func (s *strip) SetMute(val bool) { s.setter_bool("Mute", val) } -// GetMono returns the value of the Mute parameter +// GetMono returns the value of the Mono parameter func (s *strip) GetMono() bool { return s.getter_bool("Mono") } -// SetMono sets the value of the Mute parameter +// SetMono sets the value of the Mono parameter func (s *strip) SetMono(val bool) { s.setter_bool("Mono", val) } -// GetSolo returns the value of the Mute parameter +// GetSolo returns the value of the Solo parameter func (s *strip) GetSolo() bool { return s.getter_bool("Solo") } -// SetSolo sets the value of the Mute parameter +// SetSolo sets the value of the Solo parameter func (s *strip) SetSolo(val bool) { s.setter_bool("Solo", val) } @@ -81,12 +81,12 @@ func (s *strip) SetLimit(val int) { s.setter_int("Limit", val) } -// GetLabel returns the value of the MC parameter +// GetLabel returns the value of the Label parameter func (s *strip) GetLabel() string { return s.getter_string("Label") } -// SetLabel sets the value of the MC parameter +// SetLabel sets the value of the Label parameter func (s *strip) SetLabel(val string) { s.setter_string("Label", val) } @@ -110,32 +110,32 @@ func newPhysicalStrip(i int, k *kind) t_strip { return t_strip(&ps) } -// GetComp returns the value of the Mute parameter +// GetComp returns the value of the Comp parameter func (p *physicalStrip) GetComp() bool { return p.getter_bool("Comp") } -// SetComp sets the value of the Mute parameter +// SetComp sets the value of the Comp parameter func (p *physicalStrip) SetComp(val bool) { p.setter_bool("Comp", val) } -// GetGate returns the value of the Mute parameter +// GetGate returns the value of the Gate parameter func (p *physicalStrip) GetGate() bool { return p.getter_bool("Gate") } -// SetGate sets the value of the Mute parameter +// SetGate sets the value of the Gate parameter func (p *physicalStrip) SetGate(val bool) { p.setter_bool("Gate", val) } -// GetAudibility returns the value of the Mute parameter +// GetAudibility returns the value of the Audibility parameter func (p *physicalStrip) GetAudibility() bool { return p.getter_bool("Audibility") } -// SetAudibility sets the value of the Mute parameter +// SetAudibility sets the value of the Audibility parameter func (p *physicalStrip) SetAudibility(val bool) { p.setter_bool("Audibility", val) }