mirror of
https://github.com/onyx-and-iris/voicemeeter.git
synced 2024-11-22 04:40:53 +00:00
observer example updated with midi event.
ldirty now enabled explicitly in observer example.
This commit is contained in:
parent
dd895daffb
commit
cba2ac85ec
@ -2,7 +2,6 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/onyx-and-iris/voicemeeter-api-go"
|
||||
@ -12,14 +11,27 @@ type observer struct {
|
||||
vm *voicemeeter.Remote
|
||||
}
|
||||
|
||||
func (o observer) Register() {
|
||||
o.vm.Register(o)
|
||||
}
|
||||
|
||||
func (o observer) Deregister() {
|
||||
o.vm.Register(o)
|
||||
}
|
||||
|
||||
func (o observer) OnUpdate(subject string) {
|
||||
if strings.Compare(subject, "pdirty") == 0 {
|
||||
if subject == "pdirty" {
|
||||
fmt.Println("pdirty!")
|
||||
}
|
||||
if strings.Compare(subject, "mdirty") == 0 {
|
||||
if subject == "mdirty" {
|
||||
fmt.Println("mdirty!")
|
||||
}
|
||||
if strings.Compare(subject, "ldirty") == 0 {
|
||||
if subject == "midi" {
|
||||
var current = o.vm.Midi.Current()
|
||||
var val = o.vm.Midi.Get(current)
|
||||
fmt.Printf("Value of midi button %d: %d\n", current, val)
|
||||
}
|
||||
if subject == "ldirty" {
|
||||
fmt.Printf("%v %v %v %v %v %v %v %v\n",
|
||||
o.vm.Bus[0].Levels().IsDirty(),
|
||||
o.vm.Bus[1].Levels().IsDirty(),
|
||||
@ -36,11 +48,13 @@ func (o observer) OnUpdate(subject string) {
|
||||
func main() {
|
||||
vm := voicemeeter.NewRemote("potato")
|
||||
vm.Login()
|
||||
// enable level updates (disabled by default)
|
||||
vm.EventAdd("ldirty")
|
||||
|
||||
o := observer{vm}
|
||||
vm.Register(o)
|
||||
o.Register()
|
||||
time.Sleep(30 * time.Second)
|
||||
vm.Deregister(o)
|
||||
o.Deregister()
|
||||
|
||||
vm.Logout()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user