VRChatOSC is a library for sending and receiving messages to/from VRChat that supports the OpenSoundControl 1.0 protocol.
This library was forked from ex_osc and made some modifications to support VRChat OSC protocol.
VRChatOSC requires Elixir v1.14. To use it, add :vrchat_osc
to your list of dependencies in mix.exs
:
def deps do
[
{:vrchat_osc, github: "kentaro/vrchat_osc", branch: :main}
]
end
Here's an example of using VRChatOSC.OSC
to send a message and receives messages to/from VRChat.
defmodule MyConsumer do
use GenStage
def init(:ok) do
{:consumer, nil}
end
def handle_events(events, {_, _}, state) do
events |> Enum.each(&IO.inspect/1)
{:noreply, [], state}
end
end
{:ok, osc} = VRChatOSC.OSC.start_link(
vrchat: [
ip: {127, 0, 0, 1},
port: 9000
],
client: [
port: 9001
],
consumer: [
module: MyConsumer,
args: :ok,
opts: []
]
)
VRChatOSC.send_message(
osc,
path: "/chatbox/input",
args: ["Hello, world!", true]
)
Process.sleep(:infinity)
Output:
You can see the message sent to VRChat and the messages received from VRChat.
%VRChatOSC.OSC.Message{
path: "/avatar/parameters/scarf_Angle",
args: [5.154856480658054e-4]
}
%VRChatOSC.OSC.Message{
path: "/avatar/parameters/scarf_Angle",
args: [3.2970565371215343e-4]
}
%VRChatOSC.OSC.Message{
path: "/avatar/parameters/scarf_Angle",
args: [6.501884781755507e-4]
}
...
Full documentation can be found at https://hexdocs.pm/vrchat_osc.
Copyright © 2023 Kentaro Kuribayashi
Copyright © 2023 Adrian Irving-Beer (the original author of ex_osc)
VRChatOSC is released under the MIT license and is provided with no warranty.