2022-09-14 21:16:29 +01:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2022-09-29 18:05:21 +01:00
|
|
|
|
|
|
|
log "github.com/sirupsen/logrus"
|
2022-09-14 21:16:29 +01:00
|
|
|
|
|
|
|
"github.com/eiannone/keyboard"
|
2022-12-08 10:52:15 +00:00
|
|
|
"github.com/onyx-and-iris/voicemeeter/v2"
|
2022-09-14 21:16:29 +01:00
|
|
|
)
|
|
|
|
|
2022-09-29 18:05:21 +01:00
|
|
|
func init() {
|
|
|
|
log.SetLevel(log.InfoLevel)
|
|
|
|
}
|
|
|
|
|
2022-09-14 21:16:29 +01:00
|
|
|
func main() {
|
|
|
|
if err := keyboard.Open(); err != nil {
|
2022-09-18 05:35:53 +01:00
|
|
|
log.Fatal(err)
|
2022-09-14 21:16:29 +01:00
|
|
|
}
|
|
|
|
defer func() {
|
|
|
|
_ = keyboard.Close()
|
|
|
|
}()
|
|
|
|
|
2022-09-18 05:35:53 +01:00
|
|
|
vm, err := vmConnect()
|
2022-09-14 21:16:29 +01:00
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
defer vm.Logout()
|
|
|
|
|
|
|
|
fmt.Println("Press ESC to quit")
|
2022-09-14 21:17:20 +01:00
|
|
|
Loop:
|
|
|
|
for {
|
|
|
|
char, key, err := keyboard.GetKey()
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2022-09-14 21:16:29 +01:00
|
|
|
|
2022-09-14 21:17:20 +01:00
|
|
|
switch char {
|
|
|
|
case '0':
|
|
|
|
fmt.Printf("Logged into Voicemeeter %s, version %s\n", vm.Type(), vm.Version())
|
|
|
|
case '1':
|
2022-12-08 10:52:15 +00:00
|
|
|
vm.Strip[0].SetMute(!vm.Strip[0].Mute())
|
2022-09-14 21:17:20 +01:00
|
|
|
case '2':
|
2022-12-08 10:52:15 +00:00
|
|
|
if vm.Strip[3].Gain() == -12.8 {
|
2022-09-14 21:17:20 +01:00
|
|
|
vm.Strip[3].FadeBy(-8.3, 500)
|
|
|
|
} else {
|
|
|
|
vm.Strip[3].FadeTo(-12.8, 500)
|
|
|
|
}
|
|
|
|
case '3':
|
|
|
|
vm.Strip[5].AppMute("Spotify", true)
|
|
|
|
default:
|
|
|
|
if key == keyboard.KeyEsc {
|
|
|
|
break Loop
|
|
|
|
}
|
2022-09-14 21:16:29 +01:00
|
|
|
}
|
2022-09-14 21:17:20 +01:00
|
|
|
}
|
2022-09-14 21:16:29 +01:00
|
|
|
}
|
2022-09-18 05:35:53 +01:00
|
|
|
|
|
|
|
func vmConnect() (*voicemeeter.Remote, error) {
|
|
|
|
vm, err := voicemeeter.NewRemote("potato", 0)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
err = vm.Login()
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return vm, nil
|
|
|
|
}
|