audio_manager icon indicating copy to clipboard operation
audio_manager copied to clipboard

Fix inconsistent behavior when in shuffle mode

Open PatriceVignola opened this issue 3 years ago • 2 comments

The shuffle mode has a few inconsistent behavior. For example, take the following shuffled indices:

[0]:1
[1]:11
[2]:5
[3]:6
[4]:9
[5]:2
[6]:10
[7]:8
[8]:3
[9]:0
[10]:4
[11]:7

If we are currently playing index 8, calling previous() while in shuffle mode will decrement the index by 1 so it becomes 7, and then we will re-select the index 8. Instead of generating a shuffled array that can make loops possible or may make it impossible to go back or go forward, we can just generate random indices on the fly instead, while making sure that we don't generate the same index as the currently selected one.

PatriceVignola avatar Oct 11 '21 00:10 PatriceVignola

Wouldn't this make some indexes play more frequently, while some don't even have a chance of playing?

rares45 avatar Oct 12 '21 08:10 rares45

Wouldn't this make some indexes play more frequently, while some don't even have a chance of playing?

Hmm that's right, the generator should be initialized only once and reused.

PatriceVignola avatar Oct 12 '21 08:10 PatriceVignola