DEV Community

Discussion on: Smart playlist shuffle using Travelling Salesman

Collapse
 
n8chz profile image
Lorraine Lee

This is utterly fascinating. It describes something I've dreamed of having but never got around to coding. I put it off because I couldn't even imagine finding enough time to write a music player app. Now I'm reading the present post and zonking myself on the head realizing all I really needed was a playlist. Traveling Salesperson is a hard computation. I'd settle for a random walk along a Markov chain; maybe a certain probability of the next track queued being in the same key, with a slightly lower probability of it being in an adjacent key (per the circle of fifths) or alternatively, the relative major or minor (as the case may be) of the current track's key. Likewise for tempo. There are open source libraries available for key detection, beat detection and tempo detection, although of course in a classical (or any other) composition all of those are subject to change mid-course. And of course there's the whole atonal music thing. But I would assume that algorithms can be made to detect key or tempo with varying levels of "signal strength" or maybe even notice multimodal patterns.

Collapse
 
felixhilden profile image
Felix Hildén • Edited

Thanks a bunch! Yeah there are certainly many options, and that Markov chain idea sounds interesting! Randomness would allow for variation instead of this rigid order. Actually, the Web API has even more in depth analysis for tracks, as a timeline that contains all sorts of statistics. I haven't played around with it though, but it could surely be used to map song endings to more closely similar song beginnings.