move kindMap, fix doc strings

fix doc strings

move kindMap into kinds.go

rename kind_id to kindId
This commit is contained in:
onyx-and-iris 2022-06-24 14:54:17 +01:00
parent 3f6a2c90c5
commit 13f7e3d1ad
5 changed files with 35 additions and 32 deletions

View File

@ -40,10 +40,10 @@ var (
// login logs into the API, // login logs into the API,
// then attempts to launch Voicemeeter if it's not running. // then attempts to launch Voicemeeter if it's not running.
func login(kind_id string) { func login(kindId string) {
res, _, _ := vmLogin.Call() res, _, _ := vmLogin.Call()
if res == 1 { if res == 1 {
runVoicemeeter(kind_id) runVoicemeeter(kindId)
time.Sleep(time.Second) time.Sleep(time.Second)
} else if res != 0 { } else if res != 0 {
err := fmt.Errorf("VBVMR_Login returned %d", res) err := fmt.Errorf("VBVMR_Login returned %d", res)
@ -68,13 +68,13 @@ func logout() {
} }
// runVoicemeeter attempts to launch a Voicemeeter GUI of a kind. // runVoicemeeter attempts to launch a Voicemeeter GUI of a kind.
func runVoicemeeter(kind_id string) { func runVoicemeeter(kindId string) {
vals := map[string]uint64{ vals := map[string]uint64{
"basic": 1, "basic": 1,
"banana": 2, "banana": 2,
"potato": 3, "potato": 3,
} }
res, _, _ := vmRunvm.Call(uintptr(vals[kind_id])) res, _, _ := vmRunvm.Call(uintptr(vals[kindId]))
if res != 0 { if res != 0 {
err := fmt.Errorf("VBVMR_RunVoicemeeter returned %d", res) err := fmt.Errorf("VBVMR_RunVoicemeeter returned %d", res)
fmt.Println(err) fmt.Println(err)

View File

@ -15,22 +15,28 @@ func (c *command) setter(p string, v float32) {
setParameterFloat(param, v) setParameterFloat(param, v)
} }
// Show shows the Voicemeete GUI if it's hidden
func (c *command) Show() { func (c *command) Show() {
c.setter("Show", 1) c.setter("Show", 1)
} }
// Hide hides the Voicemeete GUI if it's shown
func (c *command) Hide() { func (c *command) Hide() {
c.setter("Show", 0) c.setter("Show", 0)
} }
// Shutdown shutdown the Voicemeeter GUI
func (c *command) Shutdown() { func (c *command) Shutdown() {
c.setter("Shutdown", 1) c.setter("Shutdown", 1)
} }
// Restart restarts the Voicemeeter audio engine
func (c *command) Restart() { func (c *command) Restart() {
c.setter("Restart", 1) c.setter("Restart", 1)
} }
// Lock locks or unlocks the Voiceemeter GUI
// it accepts a boolean value
func (c *command) Lock(val bool) { func (c *command) Lock(val bool) {
var value float32 var value float32
if val { if val {

View File

@ -8,12 +8,7 @@ import (
// A kind represents a Voicemeeter kinds layout // A kind represents a Voicemeeter kinds layout
type kind struct { type kind struct {
name string name string
physIn int physIn, virtIn, physOut, virtOut, vbanIn, vbanOut int
virtIn int
physOut int
virtOut int
vbanIn int
vbanOut int
} }
func (k *kind) numStrip() int { func (k *kind) numStrip() int {
@ -44,3 +39,11 @@ func newBananaKind() *kind {
func newPotatoKind() *kind { func newPotatoKind() *kind {
return &kind{"potato", 5, 3, 5, 3, 8, 8} return &kind{"potato", 5, 3, 5, 3, 8, 8}
} }
var (
kindMap = map[string]*kind{
"basic": newBasicKind(),
"banana": newBananaKind(),
"potato": newPotatoKind(),
}
)

View File

@ -43,16 +43,10 @@ func (r *remote) SendText(script string) {
// NewRemote returns a remote type of a kind, // NewRemote returns a remote type of a kind,
// this is the interface entry point. // this is the interface entry point.
func NewRemote(kind_id string) *remote { func NewRemote(kindId string) *remote {
kindMap := map[string]*kind{ _kind, ok := kindMap[kindId]
"basic": newBasicKind(),
"banana": newBananaKind(),
"potato": newPotatoKind(),
}
_kind, ok := kindMap[kind_id]
if !ok { if !ok {
err := fmt.Errorf("unknown Voicemeeter kind '%s'", kind_id) err := fmt.Errorf("unknown Voicemeeter kind '%s'", kindId)
fmt.Println(err) fmt.Println(err)
os.Exit(1) os.Exit(1)
} }

View File

@ -51,22 +51,22 @@ func (s *strip) SetMute(val bool) {
s.setter_bool("Mute", val) 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 { func (s *strip) GetMono() bool {
return s.getter_bool("Mono") 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) { func (s *strip) SetMono(val bool) {
s.setter_bool("Mono", val) 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 { func (s *strip) GetSolo() bool {
return s.getter_bool("Solo") 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) { func (s *strip) SetSolo(val bool) {
s.setter_bool("Solo", val) s.setter_bool("Solo", val)
} }
@ -81,12 +81,12 @@ func (s *strip) SetLimit(val int) {
s.setter_int("Limit", val) 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 { func (s *strip) GetLabel() string {
return s.getter_string("Label") 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) { func (s *strip) SetLabel(val string) {
s.setter_string("Label", val) s.setter_string("Label", val)
} }
@ -110,32 +110,32 @@ func newPhysicalStrip(i int, k *kind) t_strip {
return t_strip(&ps) 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 { func (p *physicalStrip) GetComp() bool {
return p.getter_bool("Comp") 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) { func (p *physicalStrip) SetComp(val bool) {
p.setter_bool("Comp", val) 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 { func (p *physicalStrip) GetGate() bool {
return p.getter_bool("Gate") 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) { func (p *physicalStrip) SetGate(val bool) {
p.setter_bool("Gate", val) 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 { func (p *physicalStrip) GetAudibility() bool {
return p.getter_bool("Audibility") 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) { func (p *physicalStrip) SetAudibility(val bool) {
p.setter_bool("Audibility", val) p.setter_bool("Audibility", val)
} }