2022-06-25 20:11:15 +01:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2022-08-23 03:35:34 +01:00
|
|
|
"log"
|
2022-06-25 20:11:15 +01:00
|
|
|
"time"
|
|
|
|
|
2022-07-09 19:01:58 +01:00
|
|
|
"github.com/onyx-and-iris/voicemeeter-api-go"
|
2022-06-25 20:11:15 +01:00
|
|
|
)
|
|
|
|
|
2022-06-25 20:36:34 +01:00
|
|
|
type observer struct {
|
2022-07-09 19:01:58 +01:00
|
|
|
vm *voicemeeter.Remote
|
2022-06-25 20:36:34 +01:00
|
|
|
}
|
2022-06-25 20:11:15 +01:00
|
|
|
|
2022-08-22 22:34:32 +01:00
|
|
|
func (o observer) Register() {
|
|
|
|
o.vm.Register(o)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (o observer) Deregister() {
|
2022-08-22 22:54:38 +01:00
|
|
|
o.vm.Deregister(o)
|
2022-08-22 22:34:32 +01:00
|
|
|
}
|
|
|
|
|
2022-06-25 20:11:15 +01:00
|
|
|
func (o observer) OnUpdate(subject string) {
|
2022-08-22 22:34:32 +01:00
|
|
|
if subject == "pdirty" {
|
2022-07-09 19:01:58 +01:00
|
|
|
fmt.Println("pdirty!")
|
2022-08-23 03:58:49 +01:00
|
|
|
} else if subject == "mdirty" {
|
2022-07-09 19:01:58 +01:00
|
|
|
fmt.Println("mdirty!")
|
2022-08-23 03:58:49 +01:00
|
|
|
} else if subject == "midi" {
|
2022-08-22 22:34:32 +01:00
|
|
|
var current = o.vm.Midi.Current()
|
|
|
|
var val = o.vm.Midi.Get(current)
|
|
|
|
fmt.Printf("Value of midi button %d: %d\n", current, val)
|
2022-08-23 03:58:49 +01:00
|
|
|
} else if subject == "ldirty" {
|
2022-07-09 19:01:58 +01:00
|
|
|
fmt.Printf("%v %v %v %v %v %v %v %v\n",
|
|
|
|
o.vm.Bus[0].Levels().IsDirty(),
|
|
|
|
o.vm.Bus[1].Levels().IsDirty(),
|
|
|
|
o.vm.Bus[2].Levels().IsDirty(),
|
|
|
|
o.vm.Bus[3].Levels().IsDirty(),
|
|
|
|
o.vm.Bus[4].Levels().IsDirty(),
|
|
|
|
o.vm.Bus[5].Levels().IsDirty(),
|
|
|
|
o.vm.Bus[6].Levels().IsDirty(),
|
|
|
|
o.vm.Bus[7].Levels().IsDirty(),
|
|
|
|
)
|
|
|
|
}
|
2022-06-25 20:11:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
2022-08-23 03:16:43 +01:00
|
|
|
vm, err := voicemeeter.NewRemote("potato")
|
|
|
|
if err != nil {
|
2022-08-23 03:35:34 +01:00
|
|
|
log.Fatal(err)
|
2022-08-23 03:16:43 +01:00
|
|
|
}
|
|
|
|
|
2022-09-07 20:59:55 +01:00
|
|
|
err = vm.Login()
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
defer vm.Logout()
|
2022-08-22 22:34:32 +01:00
|
|
|
// enable level updates (disabled by default)
|
|
|
|
vm.EventAdd("ldirty")
|
2022-06-25 20:11:15 +01:00
|
|
|
|
2022-07-18 16:23:15 +01:00
|
|
|
o := observer{vm}
|
2022-08-22 22:34:32 +01:00
|
|
|
o.Register()
|
2022-07-09 19:01:58 +01:00
|
|
|
time.Sleep(30 * time.Second)
|
2022-08-22 22:34:32 +01:00
|
|
|
o.Deregister()
|
2022-06-25 20:11:15 +01:00
|
|
|
}
|