mirror of
https://github.com/onyx-and-iris/voicemeeter.git
synced 2024-11-15 17:40:51 +00:00
obs example added.
This commit is contained in:
parent
7a79555cb8
commit
fa8e9f3e76
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)
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user