Skip to content

Instantly share code, notes, and snippets.

@marcan
Created December 10, 2020 10:52
Show Gist options
  • Select an option

  • Save marcan/ac89490843389ee0919f2a56c9f5ff3a to your computer and use it in GitHub Desktop.

Select an option

Save marcan/ac89490843389ee0919f2a56c9f5ff3a to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import time, math, threading, struct, sys, os.path, random
import obswebsocket, obswebsocket.requests
client = obswebsocket.obsws("localhost", 4444)
client.connect()
source_patterns = [
"RTMP", "JACK", "AUX"
]
sources = client.call(obswebsocket.requests.GetCurrentScene()).getSources()
audio_sources = [source["name"] for source in sources if any(i in source["name"] for i in source_patterns)]
while True:
#time.sleep(random.uniform(0, 0.1))
source = random.choice(audio_sources)
mode = random.choice(("monitorAndOutput", "monitorOnly", "none"))
x = client.call(obswebsocket.requests.SetAudioMonitorType(source, mode))
print(x)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment