Sonnenstrahl / traktor-now-playing

A Node.JS script that reads the Tracks on Deck A and B from Traktor via midi.
27 stars 6 forks source link

Taking very long time to load tracks / some tracks won't load #1

Open Marak opened 6 years ago

Marak commented 6 years ago

Hello. Thank you for making this project! It's helped me in understanding how to interact with the Denon HC4500 driver to get track data out of the MIDI signal.

I've noticed that certain tracks ( long named ) were taking a very long time to load / sometimes didn't load at all.

I've added some debug statements and found that the string that builds the track name seems to add the chars of the track one by one, but then resets the string to empty before it has time to complete building the entire title. This causes the process of building the string to restart. It seems to be a race condition as to when the string actually completely builds.

I suspect that we might have bug / inefficiency in MIDI parsing code causing string building process to take longer then it should.

@Sonnenstrahl - Are you aware of any issues in the parsing code which could cause the behavior I'm seeing?

I'm glad to add more debugging information if it helps.

Marak commented 6 years ago

So as a temporary work-around I ended up setting up an icecast server, broadcasting the Traktor signal to icecast, then having separate application query /status.xsl JSON file on icecast server ( which responds with currently playing track ).

This isn't ideal because it only returns the last played track ( with no specification of which deck ), but it does work for all tracks regardless of length of title.

I'd prefer to use a MIDI solution instead of having to maintain icecast server, but I'm not sure this will be possible without rewrite of MIDI parsing code.

Sonnenstrahl commented 6 years ago

Hi Marak, I will have time over the weekend to look at the code, thanks for your interest in my project. I started out with the icecast solution, but deemed it to be not too user friendly for others to setup. Concerning the parsing, have you tried just sending the denon midi data to a virtual midi port and logging it? So we can rule out that its not the denon controller messing up with bigger track names? Have a look at the readme to see which commands contain the track information.

Marak commented 6 years ago

Greetings @Sonnenstrahl, thank you for the prompt response!

I'm slightly confused about your question. I don't have a Denon controller here, I'm just using the denon option in Traktor and using traktor-now-playing to parse the MIDI data.

I've tried reducing the MIDI capture code to it's most minimal case, but it's still much data to parse / go through. Wasn't really sure how to validate the data without parsing it, so I temporarily gave up.

Pretty much, the behavior I found was that certain track events ( I added an event emitter ) were never firing. I added this debug statement:

function FindStart ( line_idx ) {
    console.log(line_idx, line_static_str_SHADOW[line_idx])

and was able to see the string or track name being built, but seemingly restarting to zero length string several times before string could complete. I found for longer track names, the string never had a chance to complete ( and is why I was seeing behavior of event not fire ).

I'm not 100% certain I've identified the root cause of the issue, but my instinct tells me that the parsing code in traktor-now-playing isn't fully in sync with the data being sent from the Denon driver. Let me know if you are able to at least reproduce the behavior I'm seeing. If a long string doesn't trigger the bug, try also a long string with some odd characters like _ or .

Sonnenstrahl commented 6 years ago

Hi Marak, sorry for the long silence.

I don't own a Denon either, it just happens that the Denon is the only controller that sends Track information via MIDI. This is the reason we use it in Traktor and catch the MIDI information.

I'm trying to test the errors you're experiencing, but so far I get successful strings. Track: CVRL - Crossin34324/))%=g23947898933242348390248skdajsalrjiowru24DS4io34 Artist: the_accidental_poet I'm unable to reproduce your String error, but I do agree on the load time. Please have a look at the Table provided in the Readme to see which Characters are supported by the Denon controller.

From what I've read about the Denon controller, the controller has 2 displays on top(Deck A and Deck B), that display the Track, but they are moved from right to left 1 char at a time. I can only parse as they get sent across the screen and am limited by the speed that the controller is moving the chars. If you have any input on the bug you're seeing or a test file/track I'd be happy to run further tests.

I think an interesting solution are the CDJ's 2000, as they have a program called Rekordbox to manage sending tracks via ethernet to the CDJ. If I understand that correctly they get sent via Network, including Track title. So in theory the Packages could be logged and Track information extracted. This would eliminate the need for Traktor. (A lot of DJS don't use DJ software and play just via Decks, they can't profit from this script). A friend of mine owns CDJ's and I would need to get my hands on them and log the network traffic to get a better understanding.