mirror of
https://github.com/onyx-and-iris/voicemeeter.git
synced 2026-04-18 05:23:31 +00:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
505b5969a2 | ||
|
|
7f992a1a87 | ||
|
|
fa8e9f3e76 | ||
|
|
7a79555cb8 | ||
|
|
6fabc43998 |
@@ -42,21 +42,24 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log"
|
||||||
|
|
||||||
"github.com/onyx-and-iris/voicemeeter-api-go"
|
"github.com/onyx-and-iris/voicemeeter-api-go"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
kindId := "banana"
|
kindId := "banana"
|
||||||
vm := voicemeeter.NewRemote(kindId)
|
vm, err := voicemeeter.NewRemote(kindId)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
defer vm.Logout()
|
||||||
|
|
||||||
vm.Login()
|
vm.Login()
|
||||||
|
|
||||||
vm.Strip[0].SetLabel("rode podmic")
|
vm.Strip[0].SetLabel("rode podmic")
|
||||||
vm.Strip[0].SetMute(true)
|
vm.Strip[0].SetMute(true)
|
||||||
fmt.Printf("Strip 0 (%s) mute was set to %v\n", vm.Strip[0].GetLabel(), vm.Strip[0].GetMute())
|
fmt.Printf("Strip 0 (%s) mute was set to %v\n", vm.Strip[0].GetLabel(), vm.Strip[0].GetMute())
|
||||||
|
|
||||||
vm.Logout()
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
9
base.go
9
base.go
@@ -54,14 +54,14 @@ func login(kindId string) {
|
|||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
fmt.Println("Logged into API")
|
fmt.Printf("Logged into Voicemeeter %s\n", kindId)
|
||||||
for pdirty() || mdirty() {
|
for pdirty() || mdirty() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// logout logs out of the API,
|
// logout logs out of the API,
|
||||||
// delayed for 100ms to allow final operation to complete.
|
// delayed for 100ms to allow final operation to complete.
|
||||||
func logout() {
|
func logout(kindId string) {
|
||||||
time.Sleep(100 * time.Millisecond)
|
time.Sleep(100 * time.Millisecond)
|
||||||
res, _, _ := vmLogout.Call()
|
res, _, _ := vmLogout.Call()
|
||||||
if res != 0 {
|
if res != 0 {
|
||||||
@@ -69,7 +69,7 @@ func logout() {
|
|||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
fmt.Println("Logged out of API")
|
fmt.Printf("Logged out of Voicemeeter %s\n", kindId)
|
||||||
}
|
}
|
||||||
|
|
||||||
// runVoicemeeter attempts to launch a Voicemeeter GUI of a kind.
|
// runVoicemeeter attempts to launch a Voicemeeter GUI of a kind.
|
||||||
@@ -326,7 +326,8 @@ func getMidiMessage() bool {
|
|||||||
uintptr(unsafe.Pointer(&b1[0])),
|
uintptr(unsafe.Pointer(&b1[0])),
|
||||||
uintptr(1024),
|
uintptr(1024),
|
||||||
)
|
)
|
||||||
if int(res) < 0 {
|
x := int(res)
|
||||||
|
if x < 0 {
|
||||||
err := fmt.Errorf("VBVMR_GetMidiMessage returned %d", res)
|
err := fmt.Errorf("VBVMR_GetMidiMessage returned %d", res)
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
|||||||
16
examples/obs/go.mod
Normal file
16
examples/obs/go.mod
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
module main
|
||||||
|
|
||||||
|
go 1.18
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/andreykaipov/goobs v0.10.0
|
||||||
|
github.com/onyx-and-iris/voicemeeter-api-go v1.4.1
|
||||||
|
)
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/buger/jsonparser v1.1.1 // indirect
|
||||||
|
github.com/gorilla/websocket v1.5.0 // indirect
|
||||||
|
github.com/hashicorp/logutils v1.0.0 // indirect
|
||||||
|
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d // indirect
|
||||||
|
golang.org/x/sys v0.0.0-20220708085239-5a0f0661e09d // indirect
|
||||||
|
)
|
||||||
18
examples/obs/go.sum
Normal file
18
examples/obs/go.sum
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
github.com/andreykaipov/goobs v0.10.0 h1:wa4CxbYu/NqwUmx5E4/baDqYRYEmfHwg2T23RAg3jlU=
|
||||||
|
github.com/andreykaipov/goobs v0.10.0/go.mod h1:EqG73Uu/4npyhXIWWszgRelNkEeIz+d0slUT6NKWYs4=
|
||||||
|
github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs=
|
||||||
|
github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0=
|
||||||
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
|
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
|
||||||
|
github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||||
|
github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y=
|
||||||
|
github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64=
|
||||||
|
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d h1:VhgPp6v9qf9Agr/56bj7Y/xa04UccTW04VP0Qed4vnQ=
|
||||||
|
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d/go.mod h1:YUTz3bUH2ZwIWBy3CJBeOBEugqcmXREj14T+iG/4k4U=
|
||||||
|
github.com/onyx-and-iris/voicemeeter-api-go v1.4.1 h1:2vGaRGCPwN9PlWspbdkDelsfxWHHkZqxozkd6FOcl28=
|
||||||
|
github.com/onyx-and-iris/voicemeeter-api-go v1.4.1/go.mod h1:zAdBhHXQ9n37CUbLizbOPmAutyZI8Ncqeu5e9u1Fy14=
|
||||||
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
|
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
|
||||||
|
golang.org/x/sys v0.0.0-20220708085239-5a0f0661e09d h1:/m5NbqQelATgoSPVC2Z23sR4kVNokFwDDyWh/3rGY+I=
|
||||||
|
golang.org/x/sys v0.0.0-20220708085239-5a0f0661e09d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
78
examples/obs/main.go
Normal file
78
examples/obs/main.go
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"log"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/onyx-and-iris/voicemeeter-api-go"
|
||||||
|
|
||||||
|
"github.com/andreykaipov/goobs"
|
||||||
|
"github.com/andreykaipov/goobs/api/events"
|
||||||
|
)
|
||||||
|
|
||||||
|
func onStart(vm *voicemeeter.Remote) {
|
||||||
|
vm.Strip[0].SetMute(true)
|
||||||
|
vm.Strip[1].SetB1(true)
|
||||||
|
vm.Strip[2].SetB1(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
func onBrb(vm *voicemeeter.Remote) {
|
||||||
|
vm.Strip[7].FadeTo(0, 500)
|
||||||
|
vm.Bus[0].SetMute(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
func onLive(vm *voicemeeter.Remote) {
|
||||||
|
vm.Strip[0].SetMute(false)
|
||||||
|
vm.Strip[7].FadeTo(-6, 500)
|
||||||
|
vm.Strip[7].SetA3(true)
|
||||||
|
vm.Vban.InStream[0].SetOn(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
func onEnd(vm *voicemeeter.Remote) {
|
||||||
|
vm.Strip[0].SetMute(true)
|
||||||
|
vm.Strip[1].SetMute(true)
|
||||||
|
vm.Strip[1].SetB1(false)
|
||||||
|
vm.Strip[2].SetMute(true)
|
||||||
|
vm.Strip[2].SetB1(false)
|
||||||
|
vm.Vban.InStream[0].SetOn(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
vm, err := voicemeeter.NewRemote("potato")
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
defer vm.Logout()
|
||||||
|
|
||||||
|
vm.Login()
|
||||||
|
|
||||||
|
obs, err := goobs.New("localhost:4455", goobs.WithPassword("mystrongpass"))
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
defer obs.Disconnect()
|
||||||
|
|
||||||
|
version, _ := obs.General.GetVersion()
|
||||||
|
fmt.Printf("OBS Studio version: %s\n", version.ObsVersion)
|
||||||
|
fmt.Printf("Websocket server version: %s\n", version.ObsWebSocketVersion)
|
||||||
|
|
||||||
|
go obs.Listen(func(event any) {
|
||||||
|
switch e := event.(type) {
|
||||||
|
case *events.CurrentProgramSceneChanged:
|
||||||
|
fmt.Printf("Switched to scene %s\n", e.SceneName)
|
||||||
|
switch e.SceneName {
|
||||||
|
case "START":
|
||||||
|
onStart(vm)
|
||||||
|
case "BRB":
|
||||||
|
onBrb(vm)
|
||||||
|
case "LIVE":
|
||||||
|
onLive(vm)
|
||||||
|
case "END":
|
||||||
|
onEnd(vm)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
time.Sleep(30 * time.Second)
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/onyx-and-iris/voicemeeter-api-go"
|
"github.com/onyx-and-iris/voicemeeter-api-go"
|
||||||
@@ -22,16 +23,13 @@ func (o observer) Deregister() {
|
|||||||
func (o observer) OnUpdate(subject string) {
|
func (o observer) OnUpdate(subject string) {
|
||||||
if subject == "pdirty" {
|
if subject == "pdirty" {
|
||||||
fmt.Println("pdirty!")
|
fmt.Println("pdirty!")
|
||||||
}
|
} else if subject == "mdirty" {
|
||||||
if subject == "mdirty" {
|
|
||||||
fmt.Println("mdirty!")
|
fmt.Println("mdirty!")
|
||||||
}
|
} else if subject == "midi" {
|
||||||
if subject == "midi" {
|
|
||||||
var current = o.vm.Midi.Current()
|
var current = o.vm.Midi.Current()
|
||||||
var val = o.vm.Midi.Get(current)
|
var val = o.vm.Midi.Get(current)
|
||||||
fmt.Printf("Value of midi button %d: %d\n", current, val)
|
fmt.Printf("Value of midi button %d: %d\n", current, val)
|
||||||
}
|
} else if subject == "ldirty" {
|
||||||
if subject == "ldirty" {
|
|
||||||
fmt.Printf("%v %v %v %v %v %v %v %v\n",
|
fmt.Printf("%v %v %v %v %v %v %v %v\n",
|
||||||
o.vm.Bus[0].Levels().IsDirty(),
|
o.vm.Bus[0].Levels().IsDirty(),
|
||||||
o.vm.Bus[1].Levels().IsDirty(),
|
o.vm.Bus[1].Levels().IsDirty(),
|
||||||
@@ -46,7 +44,12 @@ func (o observer) OnUpdate(subject string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
vm := voicemeeter.NewRemote("potato")
|
vm, err := voicemeeter.NewRemote("potato")
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
defer vm.Logout()
|
||||||
|
|
||||||
vm.Login()
|
vm.Login()
|
||||||
// enable level updates (disabled by default)
|
// enable level updates (disabled by default)
|
||||||
vm.EventAdd("ldirty")
|
vm.EventAdd("ldirty")
|
||||||
@@ -55,6 +58,4 @@ func main() {
|
|||||||
o.Register()
|
o.Register()
|
||||||
time.Sleep(30 * time.Second)
|
time.Sleep(30 * time.Second)
|
||||||
o.Deregister()
|
o.Deregister()
|
||||||
|
|
||||||
vm.Logout()
|
|
||||||
}
|
}
|
||||||
@@ -1,16 +1,21 @@
|
|||||||
package voicemeeter
|
package voicemeeter
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
vm = NewRemote("potato")
|
vm, err = NewRemote("potato")
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestMain(m *testing.M) {
|
func TestMain(m *testing.M) {
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
vm.Login()
|
vm.Login()
|
||||||
code := m.Run()
|
code := m.Run()
|
||||||
vm.Logout()
|
vm.Logout()
|
||||||
|
|||||||
5
path.go
5
path.go
@@ -3,7 +3,7 @@ package voicemeeter
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"log"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -49,8 +49,7 @@ func dllPath() (string, error) {
|
|||||||
func getDllPath() string {
|
func getDllPath() string {
|
||||||
path, err := dllPath()
|
path, err := dllPath()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
log.Fatal(err)
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
return path
|
return path
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ func (p *pooler) macrobuttons() {
|
|||||||
|
|
||||||
func (p *pooler) midi() {
|
func (p *pooler) midi() {
|
||||||
for p.run {
|
for p.run {
|
||||||
if getMidiMessage() {
|
if p.event.midi && getMidiMessage() {
|
||||||
p.notify("midi")
|
p.notify("midi")
|
||||||
}
|
}
|
||||||
time.Sleep(33 * time.Millisecond)
|
time.Sleep(33 * time.Millisecond)
|
||||||
|
|||||||
10
remote.go
10
remote.go
@@ -2,7 +2,6 @@ package voicemeeter
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// A Remote type represents the API for a kind
|
// A Remote type represents the API for a kind
|
||||||
@@ -36,7 +35,7 @@ func (r *Remote) Login() {
|
|||||||
// it also terminates the pooler
|
// it also terminates the pooler
|
||||||
func (r *Remote) Logout() {
|
func (r *Remote) Logout() {
|
||||||
r.pooler.run = false
|
r.pooler.run = false
|
||||||
logout()
|
logout(r.Kind.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Type returns the type of Voicemeeter (basic, banana, potato)
|
// Type returns the type of Voicemeeter (basic, banana, potato)
|
||||||
@@ -289,12 +288,11 @@ func (potb *potatoBuilder) Build() remoteBuilder {
|
|||||||
|
|
||||||
// NewRemote returns a Remote type for a kind
|
// NewRemote returns a Remote type for a kind
|
||||||
// this is the interface entry point
|
// this is the interface entry point
|
||||||
func NewRemote(kindId string) *Remote {
|
func NewRemote(kindId string) (*Remote, error) {
|
||||||
_kind, ok := kindMap[kindId]
|
_kind, ok := kindMap[kindId]
|
||||||
if !ok {
|
if !ok {
|
||||||
err := fmt.Errorf("unknown Voicemeeter kind '%s'", kindId)
|
err := fmt.Errorf("unknown Voicemeeter kind '%s'", kindId)
|
||||||
fmt.Println(err)
|
return nil, err
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
director := director{}
|
director := director{}
|
||||||
@@ -307,5 +305,5 @@ func NewRemote(kindId string) *Remote {
|
|||||||
director.SetBuilder(&potatoBuilder{genericBuilder{_kind, Remote{}}})
|
director.SetBuilder(&potatoBuilder{genericBuilder{_kind, Remote{}}})
|
||||||
}
|
}
|
||||||
director.Construct()
|
director.Construct()
|
||||||
return director.Get()
|
return director.Get(), nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import (
|
|||||||
|
|
||||||
func TestGetBasicRemote(t *testing.T) {
|
func TestGetBasicRemote(t *testing.T) {
|
||||||
//t.Skip("skipping test")
|
//t.Skip("skipping test")
|
||||||
__rem := NewRemote("basic")
|
__rem, _ := NewRemote("basic")
|
||||||
t.Run("Should return a remote basic type", func(t *testing.T) {
|
t.Run("Should return a remote basic type", func(t *testing.T) {
|
||||||
assert.NotNil(t, __rem)
|
assert.NotNil(t, __rem)
|
||||||
})
|
})
|
||||||
@@ -34,7 +34,7 @@ func TestGetBasicRemote(t *testing.T) {
|
|||||||
|
|
||||||
func TestGetBananaRemote(t *testing.T) {
|
func TestGetBananaRemote(t *testing.T) {
|
||||||
//t.Skip("skipping test")
|
//t.Skip("skipping test")
|
||||||
__rem := NewRemote("banana")
|
__rem, _ := NewRemote("banana")
|
||||||
t.Run("Should return a remote banana type", func(t *testing.T) {
|
t.Run("Should return a remote banana type", func(t *testing.T) {
|
||||||
assert.NotNil(t, __rem)
|
assert.NotNil(t, __rem)
|
||||||
})
|
})
|
||||||
@@ -60,7 +60,7 @@ func TestGetBananaRemote(t *testing.T) {
|
|||||||
|
|
||||||
func TestGetPotatoRemote(t *testing.T) {
|
func TestGetPotatoRemote(t *testing.T) {
|
||||||
//t.Skip("skipping test")
|
//t.Skip("skipping test")
|
||||||
__rem := NewRemote("potato")
|
__rem, _ := NewRemote("potato")
|
||||||
t.Run("Should return a remote basic type", func(t *testing.T) {
|
t.Run("Should return a remote basic type", func(t *testing.T) {
|
||||||
assert.NotNil(t, __rem)
|
assert.NotNil(t, __rem)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package voicemeeter_test
|
package voicemeeter_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
@@ -9,10 +10,15 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
vm = voicemeeter.NewRemote("potato")
|
vm, err = voicemeeter.NewRemote("potato")
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestMain(m *testing.M) {
|
func TestMain(m *testing.M) {
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
defer vm.Logout()
|
||||||
|
|
||||||
vm.Login()
|
vm.Login()
|
||||||
code := m.Run()
|
code := m.Run()
|
||||||
vm.Logout()
|
vm.Logout()
|
||||||
|
|||||||
Reference in New Issue
Block a user