Syrinscape Online Discord Bot Player

Hello,

I’ve recently begun work on a project to stream audio from Syrinscape online via a Discord bot using Discord.js.

I’ve made some progress so far, and the github repo can be found here for anyone interested: https://github.com/jmccuen/SyrinscapeDiscordBot (MIT License)

Right now, it will connect to the websocket endpoint, register the device and link it to the game. The websocket stream then received JSON messages with the .ogg files.

Once you connect to the websocket endpoint, you can register your device by sending the following two messages:

{
“message”: “register”,
“device_uuid”: “” //add the auth UUID from your player here
};

{
“message”: “request_linkup”,
“params”: {
“device_name”: “SyrinscapeBot”,
“player_version”: “1.4.6-20200115”,
“is_stopped”: false
}
};

and you will begin to see json response messages with mood elements such as:

{
“stream”:true,
“s_id”:“sample_322451”,
“url”:url.ogg,
“file”:“556d0aaf37d249144b7cca312acdd520.ogg”,
“id”:“playlist_2824871”,
“len”:“132.26”,
“name”:“Environmental systems hum”,
“e_id”:“element_486783”
}

From here, we can parse the .ogg files and stream them in to the Discord voice channel – but this seems a little odd to me, I would’ve expected the audio to just stream over the WebSocket channel (and be mixed on the server), so I thought I would post here first to see if anyone could confirm this is the case.

Let me know if anyone has any thoughts and feel free to submit a pull request directly to the repo.

Thanks!

Edit: You can get it to play a single element pretty easily by just passing the .ogg file url into the Discord dispatcher’s play method when the message comes in, by the way – there just seems to be a lot of complicated logic around mixing the files.

2 Likes

I sent a note to Ben and just heard back.

It looks like the player does actually mix all of the audio on the client side – this actually makes sense, now that I consider it, since it caches all of the .ogg files locally and thus only need to download the audio once, which is much more cost effective.

Unfortunately, he mentioned that the player uses some pseudo-randomness trickery to keep the players in sync, so I don’t think I will be able to keep the discord bot in sync with the other players without the source code (not that important for this usecase, really).

The other option would be to use node to read the system audio stream and just pick up the audio stream from the Online Player when it is running and pipe that to Discord, although this method has a number of drawbacks, too, and would be much less portable for others to use.

Audio mixing is a bit out of my wheelhouse, but I’m probably going to take a stab at it, anyway. Let me know if you have any thoughts!

1 Like

I’ve been using


to great success as I work on my script to control Syrinscape via Twitch/Discord Chat.

3 Likes