Stagelinq protocol API availability? (Part 2)

Continuing the discussion from Stagelinq protocol API availability? (Part 1) - #507 by kkirjala.

Previous discussions:

1 Like

@kkirjala Does this version work for you, this uses the go StageLinq library: Release Added Mixxx support ¡ erikrichardlarson/unbox ¡ GitHub

Yes, using that build I get log output in the UI (“Denon Logs”) and it also detects the players and correctly determines which track is currently playing.

AFAIK the NodeJS library has only been tested using Prime 2 and not stand-alone players (SC5000/SC6000) so there probably is something missing from it’s implementation of the StageLinq protocol (?)

Hi there! Thanks for testing this! I only tested it on a Prime Go, so perhaps the stand-alone players use some variation of the protocol. Would it be possible to create an issue on Github here:

with repro steps, so I can take a look at it? When you say it crashes, what exactly happens?

Finally, would you be able to run the NodeJS StageLinq project separately from unbox? Just checkout the github project and hit run and let me know what happens.

One of the areas where my code deviates from the Go code, is the FileTransfer service that I use to download album art. So I’m curious to see which line it crashes when you run the code.

Thanks!

Good to know, may have to revert the Denon mode to the go library in the meantime. @DJRobF I believe @kkirjala tested against your library directly, given the go library is working we could look at differences in how connections are set up and go from there.

Ah yeah I wonder if dropping the FileTransfer connect here would help: StageLinq/main.ts at 6a5e7420678f9f46b3783ba8681bf7f575036ec4 ¡ MarByteBeep/StageLinq ¡ GitHub

@kkirjala Can you try commenting out lines 33-52 in main.ts and seeing if you can connect then?

Exactly, try commenting those lines and see what happens.

I ran the NodeJS StageLinq library and the crashes are caused by different issues, depending on whether the library first detects the mixer or either one of the players:

  1. In case it first gets the UDP broadcast message from the mixer, the crash is caused by the Controller.connect() function throwing an exception (trying to connect to mixer’s port 50010 will give a E_CONNREFUSED, see my previous post). More specifically the tcp.connect() function:

[02:21:03] [INFO] Found ‘DN-X1800Prime’ Controller at ‘192.168.1.100:50010’ with following software: { name: ‘JM08’, version: ‘1.00’ }

[02:21:05] [ERROR] Error: Failed to connect to ‘192.168.1.100:50010’ at /Users/kkirjala/Documents/StageLinq/dist/utils/tcp.js:12:15 at processTicksAndRejections (node:internal/process/task_queues:96:5) at async Object.connect (/Users/kkirjala/Documents/StageLinq/dist/utils/tcp.js:11:5) at async Controller.connect (/Users/kkirjala/Documents/StageLinq/dist/Controller.js:72:27) at async main (/Users/kkirjala/Documents/StageLinq/dist/main.js:29:5) at async /Users/kkirjala/Documents/StageLinq/dist/main.js:72:9

  1. In case either one of the players is detected first, the library will connect (Controller.connect()) to the player and get a successful TCP connection, but the library will crash because “await this.requestAllServicePorts()” will timeout:

[02:17:52] [INFO] Found ‘sc5000’ Controller at ‘192.168.1.226:44011’ with following software: { name: ‘JP07’, version: ‘2.1.1’ }

[02:17:52] [LOG] TCP connection to ‘192.168.1.226:44011’ local port: 64205

[02:17:57] [ERROR] Error: Failed to requestServices at Timeout._onTimeout (/Users/kkirjala/Documents/StageLinq/dist/Controller.js:234:24) at listOnTimeout (node:internal/timers:557:17) at processTimers (node:internal/timers:500:7)

@DJRobF, I will create a bug ticket on Github. And just so you know: I’m very much willing to participate in debugging and reverse engineering the protocol, so in case you need any help from me, just let me know. I haven’t had time to really dig into the Go -based StageLinq implementation in order to understand how the handshake and overall flow between the client (player/mixer) and server (library) is expected to work.

Thanks for this! I’ll give it some thought tomorrow! Perhaps you’re able to step through the code in VS code to see which specific line is problematic? And feel free to post a pull request on Github, should you find a solution :slight_smile:

I also noticed that if WiFi on my MacBook is set to ‘on’ then the Unbox app crashes after around 10 seconds of being open in Denon DJ mode.

Turn MacBook WiFi off snd it doesn’t crash, HOWEVER, Interestingly I also see that the “localhost” path names aren’t filled in, I get a javascript error and the user-definable colours & backgrounds are reverted back to black.

Screenshot 2021-12-30 at 00.17.08

@erikrichardlarson @DJRobF commenting out the rows 33-52 in main.ts didn’t make any change.

got it… someone should get me a SC5000 :slight_smile:

1 Like

I’ve come up with a “Now Playing” tool which leverages the @icedream reference Go library for the Stagelinq protocol.

I’ve only tested it on the Prime4, but I’ve tried to code it in a way that provides compatibility with other standalone Prime series systems.

If there is anyone on an Intel Mac that wants to give it a try and get back to me, that would be great.

Usage:

./denonctl trainspot --log.level=debug --outfile.featured=featured.txt

If you want to stop it from trying to connect to everything detected as a Stagelinq device on the network, you can use the --target.device and --target.software flags to constrain what discovered endpoints you will connect to. You should be able to spot what these are in the debug level output.

Use --outfile.featured flag to specify the text file to output the “featured” now playing song. You can customize the output line using --outfile.format where $SONG$ and $ARTIST$ in this string are dynamically substituted. Note that currently by default unless you specify an --outfile.featured flag, no file will be written. If you had planned on using this with OBS, you’ll want to set this flag.

If you want to see all the gory details, use --log.level=debug.

A note about the “featured” / now-playing algorithm…

A track is featured if it is the only audible track. This means if you use the crossfader, the other track has to fully faded out. If you start to bring in another track using line faders in thru or the crossfader, it won’t shift to featured status until no other track is audible.

It seems like a perfectly reasonable algorithm for my playing style, but I realize my playing style may not be yours.

-M

I’ve been after a ‘now playing’ app that does this forever. Most of these kinda apps are on a timer so once the fader comes up you have around 30 seconds before it changes so long subtle blends have the next track pop up far too early. Nice!

Your style is my style. Amen!

1 Like

Interesting, does this JavaScript error happen every time you open Unbox?

Also can you download the latest version again just to double check: https://github.com/erikrichardlarson/unbox/releases/download/10.0/unbox_mac_intel.zip

The latest unbox version takes the max playing volume fader, I’ll incorporate cross-fader as well. @DJRobF Can you remind me again, does /Mixer/CrossfaderPosition go from 0 to n as you fade to decks 2 / 4?

1 Like

Nice!

Not every time. Generally if the app crashed due to the WiFii being turned on then it will startup the next time with this error.

EDIT: So I have realised that with WiFi set to on the app crashes after around 30 seconds. With the WiFi set to off, I get the javascript error and the settings are either blank or default.

I didn’t realise that Unbox had gone pay only now. Maybe this is the problem as I don’t have an account. There is only the option to ‘go pro’ now on step 4 with only a ‘back’ button on screen.

Ah that makes sense, it’s failing to set the IP Address in the config store since you’re briefly disconnected from your network and the IP can’t be found. I’ll put in a check here that allows you to fall back to localhost / avoid this popup. When you turn the WiFi off does your computer connect via Ethernet?

Oh Unbox’s core desktop features are still free for y’all, a subscription gets you access to the Twitch Panel extension / real-time db, but not having one won’t cause any issues.

1 Like

Haha would love to get some Denon gear too

@MrWilks Just updated Unbox to handle being offline, you can download here: https://github.com/erikrichardlarson/unbox/releases/download/10.0/unbox_mac_intel.zip

1 Like