brentvollebregt / emotionify

Webapp than can create emotionally gradiented Spotify playlists and more 🎵🎧🔀

Home Page:https://emotionify.nitratine.net/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

"Sort" Party Mode

Xyaren opened this issue · comments

I want to sort my playlist for a party.
It would be nice to be able to "sort" the playlist in a way that it hast multiple up and down phases with more/less dancable/engergetic songs.

One way I can imagine is that you can "draw" on the graph and it picks the "nearest" songs.

Maybe letting the algorithm pick a few up and down "anchor" points and sorting the other songs inbetween.

If we step away from the drawing part for now, how do you imagine we can do this mathematically? Maybe a diagram might help get your exact idea across?

Is this kind of something you are thinking?

image

Green is target, red is actual, blue are songs

The nearest neighbours sorting transitions well around the scatter plot to give multiple different phases.

Yes ! 🚀

That is what I imagined.
It get's a bit difficult when the green line intersects with itself.
It can also go back and forth on the X axis. 🤔

Maybe I am overthinking it...

In the end I would like to have a party playlist with alternating high and low energy/dance phases of about 20min (customizable?) each.
The transition should be smooth.
The start and end should start on the lower end.

Using a sine wave like the one above will not intersect itself. A sine wave won't be able to get your specific duration in each period because it's simply going back and forth and we would match the closest points on the line for each song. Although, trying to calculate the nearest point to a sine wave function like y=a+b*sin(cx+d) is not very straight-forward, as described in this StackOverlow question.

It sounds like what you're describing can't really be solved easily using a function - getting a target duration when moving from one side of the axis to the other along a target line doesn't sound trivial. What if you get 1/4 of the way across and have already hit your target duration? Could randomly remove songs from the whole movement from one side to the other to get to the target duration - but in this case the songs that you removed might not be seen again?

Existing sort functions can be found in PointSorting.ts - these can give you an idea of what currently can be done. We can also inject the whole song object into these sorting objects if needed (to get duration).

One idea I had was to:

  1. Sort all songs by one axis in one direction
  2. Randomly reduce this list down to get the target duration
  3. Sort all remaining songs on the same axis in the opposite direction
  4. Randomly reduce this list down to get the target duration
  5. Repeat steps 3 & 4 until there are no more songs left

While this will work great one one axis - it doesn't account for the other axis (which might not really be an issue).

Open to ideas on expanding how the sorting works, like being able to set additional arguments.