Results 1 to 2 of 2

Thread: shuffle without repetition

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2015

    Lightbulb shuffle without repetition

    A forum with a wishlist - great :-)

    I wish that at least the mobile edition avoids repetitions which I observed in the desktop edition:

    1. Repeating some songs more often than others, in "random" playmode.
    2. Repeating the same order of a playlist, in "shuffle" mode.
    3. Playing a song again, although it was just played, or played just a few songs ago, I guess it was in "random" mode.

    In case it's not only me, I prepared the detailed pseudo code of a mode avoiding them all ... :-)

    Each playlist gains two new ordered lists, invisible to the user, which I just call "ORDER" and "HISTORY".
    • To clarify: There is no global "ORDER" and no global "HISTORY"
    • Playlists are not altered in any other way and in no way visible to the user.

    When the user triggers play ...

    1. If ORDER contains no unflagged songs:

      Empty HISTORY.
      Move all entries from ORDER to HISTORY, leaving ORDER empty.

    2. If ORDER is emtpy:

      For each song in the playlist create one entry inside of ORDER:
      • Each entry is one song plus one flag set to "unflagged". (unflagged = still to be played)

      Reshuffle ORDER's entries (to be a suprisingly new sequence of songs never heard before in that order :-)

      If HISTORY is not empty: (Here we prevent playing a song again that was played recently :-)
      For each of the first 20% of ORDER's entries: (20%, rounded down. E.g. 0 for a tiny playlist of 3 songs. Or. E.g. 22 for 114 entries.)
      • If the song is also found in the last FEW entries of HISTORY, (FEW=20% of size of ORDER, not of HISTORY. Safer if HISTORY > ORDER)
      • then play it later. In other words: move this entry from it's place in the first 20% to some random place in the last 60% of ORDER.

    3. If there are songs in the playlist which are not inside ORDER (the user recently added them)
      then add entries for them into ORDER at random positions between the other entries, but not before the last entry with a flag.

    4. Find ORDER's first song which does not have a flag and play that song.
      Instantly flag it, even if it can't be played due to a missing file or if the user skips to the next song instantly.

    5. If ORDER contains songs without flag then go to 3.

    6. If "repeat playlist" is on then go to 1.

    7. Stop playing.

    When the user triggers/skips "song forward" while a song is being played:
    • Go to 1. (Pseudo Code "1.", not song number one. Just saying.)

    When the user triggers "song forward" while no song is played:
    • If ORDER contains an unflagged song then do 3 but not 4, and flag the first song without a flag.
    • If ORDER contains no unflagged song then do 1,2,3 but not 4.

    When the user triggers "back" a.k.a. previous song while there is no song being played:
    • Find an ORDER's entry with flag, search from the bottom up.
    • If there is one, remove it's flag.
    • If there are none, move the last entry(if present) of HISTORY to the start of ORDER and unflag this one.

    When the user triggers "back" a.k.a. previous song while there is a song being played:
    • Stop playing the song and unflag it.
    • Find an ORDER's entry with flag, search from the bottom up.
    • If there is one, remove it's flag and go to 4.
    • If there are none but an entry in HISTORY, then: move HISTORY's bottom entry to ORDER'S top, unflag it and go to 4. (Else: playing stays stopped.)

    Thanks for taking the time to read this ;-)
    Last edited by klaus_thorn; June 6th, 2015 at 04:48 PM. Reason: adding last clarification I can currnetly think of.

  2. #2

    Re: shuffle without repetition

    random doesn't mean an absence of pattern, given a fixed amount of songs, repetition is inevitable.

    what you want is a fixed playlist with its contents randomized.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts